도메인 간 개발 전문가에게 ...이 도메인 기반 디자인입니까?
저는 DDD의 개념을 정말로 파악하려고합니다. 지금까지 저는 도메인 구동보다는 데이터 구동을위한 모델을 설계했습니다. DDD에 관한 몇 가지 기사를 읽었으며 특히 큰 규모의 응용 프로그램에서 특히 흥미로운 것 같았습니다. 그래서 나는 정확하게하기 위해 나의 모델을 맞추려고 노력하고있다.
모든 고객 계정을 사용할 수 없게하는 메소드 FreezeAccounts를 표시하는 고객 엔티티를 말하고 있습니다. 이 방법은 데이터 접근과 관련이 없습니다 (Persistence Ignorance 규칙 기반). 필요에 따라로드되는 각 고객 계정의 플래그를 업데이트하고 변경 사항을 데이터베이스에 저장합니다. 이 모델을 기반으로 올바른가요? DDD에서 반드시 테이블 엔티티 당 하나의 클래스 만있는 것은 아닙니다. 이 기능은 별도의 클래스에 있어야합니까? 엔티티에 그래서 CRUD 작업을 모두
public class Customer : ICustomer, ICustomerAction
{
#region Initialization
public Customer()
{
}
internal Customer(ICustomer view)
{
this.CustomerId = view.CustomerId;
this.Name = view.Name;
this.Email = view.Email;
this.IsActive = view.IsActive;
}
#endregion
#region Instances
private AccountCollection _accounts;
#endregion
#region Properties
#region ICustomer
public int CustomerId { get; private set; }
public string Name { get; set; }
public string Email { get; set; }
#endregion
#region Derived
public AccountCollection Accounts
{
get
{
if (_accounts == null)
_accounts = Account.GetListByCustomerId(CustomerId);
return _accounts;
}
}
#endregion
#endregion
#region Methods
#region CRUD
// Data Access Object accepts interface ICustomer
internal void Update()
{
CustomerDb.Update(this);
}
#endregion
#region ICustomerAction
// Exposed business Persistence Ignorance action
internal void FreezeAccounts()
{
foreach (Account account in this.Accounts)
{
account.IsEnabled = false;
account.Update();
}
}
#endregion
#endregion
}
이제 모든 것이 명확합니다. 내 사례는 DDD가 아닌 기존의 Active Record Pattern을 따르고있었습니다. 응용 프로그램 서비스가 리포지토리와 도메인 (서비스/엔터티)과 상호 작용하는 대신 비즈니스 개체가 리포지토리와 상호 작용하고있었습니다. 키워드 : Unit Of Work, Entity 뿌리 및 서비스는 그림을 지우는 데 도움이되었습니다. 감사! – fips
그럼 왜 옳은 대답을 받아들이지 않았 니? :-) – inf3rno