मैं एक डोमेन संचालित डिजाइन दृष्टिकोण का उपयोग करता हूं। डीडीडी पर एक बहुत अच्छी किताब निम्नलिखित है: .NET Domain-Driven Design with C#: Problem-Design-Solution। फाउलर्स एंटरप्राइज़ पैटर्न और इवांस डोमेन संचालित डिजाइन पुस्तकें भी देखें। मूल विचार यह है कि एक भंडार मूल रूप से आधारभूत संरचना है। सभी डोमेन तर्क आपके मॉडल में जाते हैं।
उदाहरण भंडार विधि इस प्रकार है:
public void InsertAddresse(Company company)
{
foreach (Address address in company.Addresses)
{
this.InsertAddress(address, company.Key, (company.HeadquartersAddress == address));
}
}
दूसरी ओर एक मॉडल वस्तु इस तरह दिखता है:,
public class Contact : Person, IAggregateRoot, IHasAddresses
{
private string jobTitle;
private string email;
private string phoneNumber;
private string mobilePhoneNumber;
private string faxNumber;
private string remarks;
private Company currentCompany;
private IList<Address> addresses;
public Contact()
: this(null)
{
}
public Contact(object key)
: this(key, null, null)
{
}
public Contact(object key, string firstName, string lastName)
: base(key, firstName, lastName)
{
this.jobTitle = string.Empty;
this.email = string.Empty;
this.phoneNumber = string.Empty;
this.mobilePhoneNumber = string.Empty;
this.faxNumber = string.Empty;
this.remarks = string.Empty;
this.currentCompany = null;
this.addresses = new List<Address>();
}
public string JobTitle
{
get { return this.jobTitle; }
set { this.jobTitle = value; }
}
public string Email
{
get { return this.email; }
set { this.email = value; }
}
public string PhoneNumber
{
get { return this.phoneNumber; }
set { this.phoneNumber = value; }
}
public string MobilePhoneNumber
{
get { return this.mobilePhoneNumber; }
set { this.mobilePhoneNumber = value; }
}
public string FaxNumber
{
get { return this.faxNumber; }
set { this.faxNumber = value; }
}
public string Remarks
{
get { return this.remarks; }
set { this.remarks = value; }
}
public Company CurrentCompany
{
get { return this.currentCompany; }
set { this.currentCompany = value; }
}
public IList<Address> Addresses
{
get { return this.addresses; }
}
protected override void Validate()
{
//some logic here
}
protected override BrokenRuleMessages GetBrokenRuleMessages()
{
return new ContactRuleMessages();
}
}
स्रोत
2010-12-17 20:39:37
डैरिन इस संदर्भ क्या विभिन्न खजाने तक पहुँचने के लिए सबसे अच्छा तरीका है के भीतर एक सेवा से? क्या आप कृपया मुझे बता सकते हैं कि आईओसी/डीआई में समाधान का समाधान क्या होगा? – Chandu
धन्यवाद डारिन! –
स्पष्टीकरण के लिए धन्यवाद डारिन – Chandu