This has been repeated over and over again. Not only is this a pretty substantial fraud, but the answer is subjective and reasoned. ViewModels is a response to DDD and the concept of nonviolence of perseverance.
Saying that using ViewModels is wrong, ignoring the fact that Django and Rails and most PHP ORM / MVC frameworks don't care about these concepts at all. Do you want someone to tell you that all these other languages ββand frameworks βdo it wrong?β.
Regardless of whether you want to use ViewModels, it is 100% dependent on what styles of architecture you are planning and what are the goals of the application.
Does this look like a drag request for GridViews in a WebForm application? Depends on many things.
There is also a misconception about DRY that you have. Do WCF Proxy classes violate DRY? Does the ViewModel have logic? The main purpose of DRY is to not have duplicated logic with a meaningful purpose. Did a couple of DTOs that share object templates break that?
The DDD limited context principle would also serve as a good read. If the ShoppingCart should work differently on the store website or on the e-commerce website, does that mean you have to share these types? What happens when the only common functionality is the total price (price + tax + shipping)? Do you create a base class just for this, thereby increasing the connection? What are the time / cost / service tradeoffs for 100% DRY for a simple method like GetTotal (). Does DRY break when it makes sense to actually reduce the complexity and overall cost of maintaining your code base?
I'm sorry that I answer so many questions, but I hope now you can see the nuances and subtleties of the question you asked.;)
jfar
source share