I am creating an n-tier wep app with asp.net mvc which calls a stateless service layer.
so, in addition to the "model" that the service layer handles with an ORM, I have a DTO for each model class which maps to a specific controller. Then for each DTO class I have a UI model class, which i populate with appropriate data from the DTO then use with the view. Then, in the controller on post, i send information from the UI view to the service layer. does that sound right?
Yes, that sounds like you are following the Single Responsibility Principle instead of munching everything together in God Classes.
You can rarely have too many classes, but the most important point is not the number, but the clear demarcation and encapsulation of responsibilies.
From the short description given, it doesn't sound completely off.
Yes - it does sound right. Only - i would use ORM like NHibernate, that supports POCO in order to drop service DTOs.
On the other hand - it's all about context.
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