Reputation: 223
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?
Upvotes: 4
Views: 586
Reputation: 136627
It depends on why you're doing it. Are you doing it because it actually buys you anything or because you feel you should because you've seen this on some blog/whatever?
To me it sounds painful.
Upvotes: 0
Reputation: 47597
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.
Upvotes: 4
Reputation: 233150
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.
Upvotes: 4