1
votes

It looks like VM = Business Logic Layer and that the Model = Entities/DTO. In my business logic I am doing the validating of business rules like if FirstName is empty, etc. and it looks like this can also be a job of ViewModel so where should the business validation reside if we need to utilize the MVVM design pattern in an N-Tier architected app? And the Model's is just the DTO so will there be a need for a Model in an N-Tier app?

Thanks!

1

1 Answers

2
votes

According to Wikipedia, the model represents "concepts and the relationships between them". Generally, in a multi-tiered architecture the notion of a model is local to the tier. Why? Because you don't want to pollute the entire application with information that may only be relevant in one of the tiers. For example, the concept of a Customer in the UI layer may be a very different beast from concept of Customer in the Data Access layer (you may expect them to expose different methods).

The M in MVVM therefore refers to the Model in the presentation layer - which is (say) the object representing the Customer concept in the world of the UI. It may be entirely appropriate for this to be a simple DTO, or you may want to endow the incoming DTO object with extra behaviour (maybe using an Adapter pattern) before considering it to represent an element of your model. I would love to add a diagram here for clarification unfortunately my reputation does not allow me to!