Saturday 15 June 2013

architecture - Mapping vs. service layer, or business logic position -


I found a product and a collection of donors. The donor can pay for the product in three different ways, either manually set the percentage, by the value of the payer's income or the respective holdings of the payer. How the product is paid is determined by an NF on the product.

In my persistence layer, I have been paid three sections, product, payer and product manually, which is several-to-many classes between the product and the payer if the product is paid manually , Then each payer must pay the percentage.

How should I map it to see? I would like to make a new multiple-to-many class (in which the payer's reference, a reference to the product and that payer must pay the exact amount)?

I think the calculation should be done in the service layer, but a View Model / DTO version of the service layer product / payer should be added to a new multiple-class, or it should be Should be handled later? If it should be handled later, should there be a list of many new-to-many sections in that unit, but must be ignored in the persistence layer? DDD may suggest that you should adopt a line of thinking which is focused on the first and foremost design. Object model instead of ER / data model I think how you should look at the data model (with multiple tables etc.), but maybe you should consider how the object model can look first then that As the object model shows the domain (business logic, business behavior), think about how you can map that object model to the database.

For example, there may be more understanding in bringing back that product, a collection of payments and each payment has a link to the payer unit. According to your design, pair links can be copies of pair information, which you want to access, or perhaps the link knows how to load the full payer unit with the necessary information / prices. In addition, in the example of each payer, there may be a collection of payments (class type as above), which links back to the product.

This design uses OO principals better and better than domain methods can be a relational database In addition, these objects can be easier to handle in services and UI layers because their original object The structure already provides you with the things you need, logically, that is There are payments for a product, including payee, etc.

I am quite new to think of myself as DDD. And DDD scares you before the word, take a look at this. It is free to read and download a light. It can give you only those gems you want.


No comments:

Post a Comment