State of the art in MVC architecture?
Seems lik开发者_如何学Ce there are a ton of possible MVC configurations/architectures (MVC, MVVM, MVP, HMVC, PAC, document-view...). Is there any currently accepted 'best' or state-of-the-art MVC architecture? What is the newest thinking? Or is it all a free-for-all and/or simply tied to whichever platform one develops on (e.g. MVVM for WPF)?
(Specifically I'm interested in MVC as applied in desktop/rich-client applications.)
No. You will not get any agreement on what is the "currently accepted" best architecture.
It is certainly not MVC or MVP. These architectures originated in the late 70s and early 90s respectively. MVP is an improvement on MVC, but in the twenty years since MVP was invented, it has become clear that it suffers from many, many flaws. This is why there are so many new competing architectures.
The concepts of "model" and "view" are well-accepted and seem to be common to all current architecture models nowadays. The real question is how to best link them together. You need something else in addition to the model and view, but what?
Most of the newer architectures tend to do this by having the view link or bind directly to the model and the "something else" using data-binding, expressions, or similar mechanisms. That way anything in the model that can be bound directly by the view has no need of involving the "something else" at all.
My personal favorite is MVVM. I love the fact that a "view model" is conceptually just a "model" with all the aspects of any other model except that it doesn't (normally) ever get written out to disk. In fact, if it weren't confusing "MVVM" could be renamed to "MV", since it pretty much dispenses with the need for anything else but views and models. MVVM can be used not only with WPF but with any presentation framework that has advanced data binding capabilities. Unfortunately this excludes GWT and Cocoa. I also like MVVM because it tends to entirely eliminate redundant or repetitive code.
MVVM is not the only advanced player in town. Aspect-oriented approaches and command archtectures built on traditional models and views also have similar aspirations.
The bottom line is, this is still an actively researched area and there has been no consensus reached at this time. MVVM is the most popular of the new architectures but not the only one. The jury is still out.
Note: To get some idea of how the newer architectures are improvements over MVC and MVP, check out this comparison of Cocoa and WPF starting at the heading "Repetitive code" and going down to the end of the "Command Architecture" section.
The newest architectural research being done these days for Thick Clients is being done by Google. with the MVP architecture.
Check out the GWT articles on MVP
http://code.google.com/webtoolkit/articles/mvp-architecture.html
http://code.google.com/webtoolkit/articles/mvp-architecture-2.html
Also look at this http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/8b0ae5eaf84d8bc2?hide_quotes=no
Also check out this YouTube Video http://www.youtube.com/watch?v=PDuhR18-EdM
As far as answering your question, except for saying that MVC is kind of dated, I think it is very subjective on which way to go. It is not platform specific, except that the Framework you pick might dictate the Architecture :(
精彩评论