में एप्लिकेशन परतों को परिभाषित करना मेरे पास डीडीडी के बारे में एक प्रश्न है। मैं डीडीडी सीखने के लिए एक आवेदन बना रहा हूं और मेरे पास लेयरिंग के बारे में एक सवाल है। मुझे लगता है कि इस तरह से काम करता है एक आवेदन है: -> डोमेन परत -डोमेन-संचालित-डिजाइन
यूआई परत कॉल => आवेदन परत> डाटाबेस
यहाँ कैसे कोड लग रहा है की एक छोटा सा उदाहरण है:
//****************UI LAYER************************
//Uses Ioc to get the service from the factory.
//This factory would be in the MyApp.Infrastructure.dll
IImplementationFactory factory = new ImplementationFactory();
//Interface and implementation for Shopping Cart service would be in MyApp.ApplicationLayer.dll
IShoppingCartService service = factory.GetImplementationFactory<IShoppingCartService>();
//This is the UI layer,
//Calling into Application Layer
//to get the shopping cart for a user.
//Interface for IShoppingCart would be in MyApp.ApplicationLayer.dll
//and implementation for IShoppingCart would be in MyApp.Model.
IShoppingCart shoppingCart = service.GetShoppingCartByUserName(userName);
//Show shopping cart information.
//For example, items bought, price, taxes..etc
...
//Pressed Purchase button, so even for when
//button is pressed.
//Uses Ioc to get the service from the factory again.
IImplementationFactory factory = new ImplementationFactory();
IShoppingCartService service = factory.GetImplementationFactory<IShoppingCartService>();
service.Purchase(shoppingCart);
//**********************Application Layer**********************
public class ShoppingCartService : IShoppingCartService
{
public IShoppingCart GetShoppingCartByUserName(string userName)
{
//Uses Ioc to get the service from the factory.
//This factory would be in the MyApp.Infrastructure.dll
IImplementationFactory factory = new ImplementationFactory();
//Interface for repository would be in MyApp.Infrastructure.dll
//but implementation would by in MyApp.Model.dll
IShoppingCartRepository repository = factory.GetImplementationFactory<IShoppingCartRepository>();
IShoppingCart shoppingCart = repository.GetShoppingCartByUserName(username);
//Do shopping cart logic like calculating taxes and stuff
//I would put these in services but not sure?
...
return shoppingCart;
}
public void Purchase(IShoppingCart shoppingCart)
{
//Do Purchase logic and calling out to repository
...
}
}
मुझे लगता है कि मॉडल के बजाए मेरे अधिकांश व्यवसाय नियमों को सेवाओं में रखा गया है और मुझे यकीन नहीं है कि यह सही है या नहीं? इसके अलावा, अगर मुझे सही बिछाने का अधिकार है तो मुझे पूरी तरह से यकीन नहीं है? क्या मेरे पास सही जगह पर सही टुकड़े हैं? मेरे मॉडल भी मेरे डोमेन मॉडल छोड़ देना चाहिए? आम तौर पर मैं डीडीडी के अनुसार यह सही कर रहा हूँ?
धन्यवाद!
मेरे लिए अच्छा लग रहा है !!! –