Rev316 Rev316 - 1 year ago 117
Java Question

MVC and Java in comparison with more strict MVC languages

I've been told Java is not the greatest pick to follow an MVC architecture. I believe I've seen some Java framework solutions to ease this roadbump. However, I a bit confused on why this is. More specifically, why Java's attempt at MVC is often mocked as a "wannabe" approach. I come from a ObjC background (w/ Cocoa of course) and would love to hear from the seasoned programmers about why MVC with Java is said to fall short.

Appreciate it!

Answer Source

You say you come from a Cocoa background so I'm assuming you're not talking about web-framework MVC. Most webframeworks that say they do MVC are actually using a different pattern called Front Controller, it's a bit of a different story from normal MVC because you need quite a lot of plumbing to make that work. Hence all the MVC frameworks in the web-world, originally MVC was a pattern for window-based applications. For these applications you can make MVC work without needing a framework.

MVC is a pattern that can be implemented in any object oriented language. There's no reason why you can't do it in Java. The only reason I can think of why people would call MVC on Java a "wannabe" approach is that the UI libraries on Java like Swing do not actually require you to do MVC. They just give you the tools to implement a View. You'll have to create controller and model classes yourself.

Discussions about what 'real MVC' is are usually not really constructive anyway. MVC is a pattern developed for smaltalk about 30 years ago. None of the implementations that are used now are exactly the same anymore, many implementations are improvements. You've got different flavours called MVP, MVVM, Document-View etc. And they are all usefull in some cases. The important thing to take away from this is that its a good idea to separate your UI logic from your application logic. Java can do this and so can most other languages. People claiming otherwise are probably just afraid to look outside the language they're comfortable with.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download