I will start a Java project to develop a desktop application. What to use as presentation layer pattern (MVC, MVP,MVVM or....)?
...if it is possible, with some working small example... :-)
I will start a Java project to develop a desktop application. What to use as presentation layer pattern (MVC, MVP,MVVM or....)?
...if it is possible, with some working small example... :-)
I would also recommend you to use Google to find more information since your question is really vague. Anyway, since you want to do your desktop application in Java, and you'll probably use Swing, I just want to point that Swing is designed with a MVC pattern in mind. Anyway you can easily modify it to a MVP using some extra interfaces.
If you're unsure about the pattern, I would recommend to use the MVC. You'll find much more examples.
My 2 cents.
Actually, the ultimate post you're looking for is
this answerthis answer from Karsten Lentzsch (of JGoodies fame) in theSwing Frameworks and Best PracticesSwing Frameworks and Best Practices thread.If you don't know Karsten and JGoodies, then believe me, this guy really knows what he's talking about. I warmly recommend to read carefully his answer and the material he posted as reference. More specifically, be sure to check his Desktop Patterns and Data Binding presentation. Surprisingly, I prefer the old version to the new one.
Let me quote his slide about MVC vs MVP:
And then from the Summary:
That is Separated Presentation.
But I can't do a better job than Karsten at explaining this, I can at best paraphrase him. So just read him!
Also maybe have a look at Desktop Java demos for learning (more precisely Scott Violet's answer).
Here is an article which compares three GUI patterns in Java used to implement the same screen three times:
Implementing event-driven GUI patterns using the ZK Java AJAX framework, Simon Massey, Sachin K Mahajan
Since different frameworks and languages have slight variations on what people feel is MVP, MVC, MVVM and MVVMP etc etc the article is careful to refer to the patterns by the long names given by Martin Fowler not the short hand M__ monikers which are easy to argue about.
Clearly ZK is a web or mobile desktop-like programming environment but the patterns are equally applicable to Swing or another fat client framework. However without a good databinding framework for a certain desktop environment it is not very feasible to attempt MVVM. Hence in this early presentation the "Presentation Model" pattern is given the moniker "MVB" for Model-View-Binder as an alternative to calling it "MVVM":
Design Patterns in ZK: Java MVVM as Model-View-Binder, Simon Massey
You could take a look at this article: Hello ZK MVVM. ZK supports both MVP and MVVM, and this article might provide some insights for your choice -- the programming model is similar to Swing, thought it is a Web framework.