Currently I'm working on a project exploiting multi layer architecture as described in Application Architecture Guide 2.0 with 5 layers(DAL, BLL, Facade, Presentation Layer and Common Layer).
Here we have a Business Logic Layer which consists of Business Components and Business Entities(which are entities generated using an O/R Mapper), regularly we need this entities in our presentation layer for binding and presenting data to the user so we bubble this entities up to the Presentation Layer through other layers.
Now the question is:
Is it a right approach? (As I know by definition if we are supposed to share these we should place them in Common Layer so we can use them in all layers).
Shouldn't we move this entities to common layer? or should we define something like Data Transfer Objects(DTOs) and pass them through the layers(which of course seems redundant).
Any clarification would be appreciated.
A properly layered application will generally use DTO's to prevent business entities from being adulterated and distorted to suit the needs of other layers, among other reasons.
However, in very small apps you could spare yourself the burden of DTO mapping and have the business entities passed all the way to the UI. You can keep them in the BLL, it's not dramatic if all layers have a reference to it. It is not really a layered application any more anyway since you sort of crunched the architecture into one big layer.
Mark Seemann has an interesting blog post on this problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With