Some confusion about MVP and MVVM
Before ask this question, I have read a lof of article about MVP and MVVM. (eg: http://martinfowler.com/eaaDev/uiArchs.html)
But when starting a rich client application development, I still have some confusion about these two patterns.
- What is the Model's meaning in the MVP and MVVM?
For instance, a rich client application will use local database and remote service at the same time.
In the business layer, there are two kinds of object!
Domain object which is read from my local database.
Session object which used for keeping persistent connection (eg: watch online user asynchronously)
The Domain object are Model that is right, but do I need a special model layer to manager online user (or char message) and then mapping to ViewModel? or set these data to ViewModel directly? (Is the mapping redundant? Since one ViewModel can have several views, ViewModel is very similar with Model)
- In MVVM, the ViewModel can be persisted to database?
For instance, imagine a chat application, even though you open the application in offline enviorment, you should still be able to see the recent messages in the chat window.
But these recent message are in ViewModel, should we persist ViewModel to database? (They are exactly Model or ViewModel?)
- Is MVP better than MVVM?
In MVP, There is only one "Model layer", so I can manager and store domian object and session object in this Model Layer. All view special states are in the View which won't be persisted. Presenter will control view state and synchronize data between Model and View.
In MVVM, There are two "Model layer" (Model and ViewModel), view state and a copy of Model are stored in ViewModel. So the copy of the Model are redundant?
- Should Presenter or ViewModel be able to see Data transfer object (DTO) for special external service?
Or just place external service call in separated model layer?
Very thanks :-)