Question

If you had to fix and stabilize a MVC application, where would you start: the Model, Controller or View? The problems are spread equally throughout the application, with bad programming practices that make it hard to add functionality. The application is written in PHP if it makes a difference.

Was it helpful?

Solution

Start with the model because it is the foundation of your application. It is also easier to write tests for. It is tricky to write unit tests for controllers, though it can be done, and even harder for views. However, once you have a really solid and encapsulated API for your model, it is relatively easy to layer a new controller and view framework over top of it. If you want real separation from the view, build your model as a REST API, and implement your controller entirely in AJAX. That would be moving toward a more service oriented architecture with completely client-side based views. That's how much of Google's stuff works.

OTHER TIPS

Fix the model, because it changes more slowly than the view, and because the controller depends on the view. You get better return on investing in good stable model code.

Id' say model, controller, view, in that order. Because the most fundamental logic in in the model, followed by the controller (at quite a distance, usually)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top