Asp.net mvc Am I using too many classes for my models?

I am creating an n-level wep application with asp.net mvc that calls a stateless service level.

therefore, in addition to the β€œmodel” that the service level processes using ORM, I have a DTO for each model class that maps to a specific controller. Then for each DTO class, I have a user interface model model that I populate with the appropriate data from the DTO, and then use it with the view. Then, in the controller in the mail, I send information from the user interface view to the service level. does this sound right?

+4
source share
3 answers

Yes, it seems that you are following the principle of single responsibility, instead of being united into Divine classes .

You rarely have too many classes, but the most important point is not the number, but the clear demarcation and encapsulation of responsibility.

From the above brief description, it does not sound completely.

+4
source

Yes - that sounds right. Only - I would use ORM, for example NHibernate, which supports POCO, to refuse DTO services.


On the other hand, it's all about context .

+4
source

It depends on why you are doing this. Do you do this because he really buys you something or because you feel that you should, because you saw it on some blog / whatever?

It seems painful to me.

+1
source

Source: https://habr.com/ru/post/1299649/


All Articles