Jak powinien poprawnie wyglądać model biznesowy

0

Jak powinien poprawnie wyglądać model biznesowy na przykładzie klasy User która ma reprezentować użytkownika aplikacji. Napisałem coś takiego:

public class User
{
  public string Name{get;set;}
  public string Lastname{get;set;}
  public string Email{get;set;}
  public string Password{get;set;}
  public string Salt{get;set;}
  public DateTime Created{get;set;}

  public User(string email,string username, string password, string salt)
  {        
       Email = email;
       Username = username;
       Password = password;
       Salt = salt;
       Created = DateTime.UtcNow;
  }
}

Czy to jest dobrze napisana klasa? Czy trzeba tu dodać jeszcze jakieś elementy, pola, metody?

0

https://pl.wikipedia.org/wiki/Hermetyzacja_(informatyka)

public class User
{
	public string Name { get; protected set; }
	public string Email { get; protected set; }
	public string Password { get; protected set; }
	public DateTime CreatedAt { get; protected set; }

	protected User()
	{
	}

	public User(Guid id, string role, string name, string email, string password)
	{   
		Id = id;
		SetRole(role);
		SetName(name);
		SetEmail(email);
		SetPassword(password);
		CreatedAt = DateTime.UtcNow;
	}

	public void SetName(string name)
	{
		if(string.IsNullOrWhiteSpace(name))
		{
			throw new Exception($"Name cannot be empty.");
		}
		Name = name;
	}

	public void SetEmail(string email)
	{
		if(string.IsNullOrWhiteSpace(email))
		{
			throw new Exception($"Email cannot be empty.");
		}
		Email = email;
	}
	...
}
0

Użytkownik to infrastruktura, a nie model biznesowy.

1 użytkowników online, w tym zalogowanych: 0, gości: 1