MVC Pattern

Hello community,

as my title states I have question about MVC pattern and the jME that came to my mind when browsing the forum.

I have read something about the MVC pattern in a post, as far as i understood the jME uses a MVC pattern out of the box.
Here is a link to the post: Patterns used in jmonkeyengine - #5 by Ali_RS
I just wanted to ask if that is true or not and maybe a slighlty longer explanation on how the jME uses this pattern.

Thank you guys

I personally consider jME’s core model to not really be MVC, though I can see the argument for why it is - but it’s definitely not preferable as an “MVC framework” for engine users. While it’s true that setting user data on spatials can be used as a model of sorts, in practice this is usually an anti-pattern for managing your game data (the “model” in MVC). Similarly, the jME Controls that get added to spatials are usually not great for managing your game logic. I view and use jME as the “view” in MVC, and use spatial user data and controls to manage certain aspects of the view, but the data (model) and control (simulation) are entirely separate systems. I find this to be a clean and practical way to manage things within jME - code that handles everything in the scene graph (using jME for all of the MVC pattern) typically gets quite messy and bug-prone quite quickly. Cleanly separating out your model & simulation and using jME as the view layer tends to be both powerful and clean, and it gives you many opportunities for testing, persistence (save games), running advanced/expensive computations in your simulation, etc.

In general, your model (game data) is best managed in an entity system (usually an ECS, of which Zay-ES is the current community standard), and most entity systems have a concept of simulations that control the entities built into them.

TL;DR - by a technical definition, yes, jME could be considered to have a MVC implementation present in the scene graph. However, for engine users it’s almost always better to treat jME as the “V” in MVC and handle the M & C layers separately.


Me, too. You put it very well.

Similar to the way Swing is the V in MVC, JME is the V in MVC. Your game objects would be the M and the any of the glue to bind them together are the C.

You need not use an ECS for your game objects but it is common and especially has a lot of advantages the more game objects you will have.