views:

57

answers:

3

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?

+3  A: 

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.

Mark Seemann
+2  A: 

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.

Arnis L.
Yeah I agree, drop service DTOs, that's one layer too many.
mare
A: 

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.

Greg Beech