I'm trying to design my new open source project I want to launch.
I want to be very careful with design/projecting because I had trouble maintaining software in the past.
I have code that works and now I want to rebuild it from scratch in a more organised way.
The project it self is based around a physics simulation environment.
I'm using Java and I've been looking at the MVC architecture.
My question is :
Right now I have the "View" and the "Model" part mixed together .
for example in the Class that represents a body to be simulated,PObject
I store all the data about position, velocity etc, but I also have a function to render it to the screen. From what I understand from the MVC, I should split this in two classes (PObjectView
and PObjectController
perhaps ? )
But its hard to see with my little experience why, So I'm asking what are the benefits of MVC or am I just completely missing the point here ?

- 11
- 1
1 Answers
The benefit of MVC is that it can allow you to separate concerns (3 of them anyway) and achieve the goal to isolate changes. Wouldn't it be nice if changing your mind about, lets say, how to display this didn't force you to update code in multiple places?
MVC is our oldest pattern. It doesn't have much to say about how to communicate between it's three modules. But when done right you should be able to replace any one of them with minimal impact to the others.
One way to ensure that is to follow the Dependency Inversion Principle. This allows you to control which direction static dependencies will point regardless of the direction the flow of control must flow. Maintain this and the module that has no static dependencies pointing at it can be completely replaced with zero impact on the one it points to.
If you're curious I explored this idea here.

- 102,279
- 24
- 197
- 315