Fat model, thin controller, sensible view

Just thought I’d push out a quick thought. This is one of my guiding philosophies for software development, HT to the brilliant Arlen Cuss for introducing me to the idea. It applies any time your code follows even a loose MVC structure:

  • Put lots of code in the model
  • Put very, very little code in the controller – just enough to connect the model and view
  • Put as much code in the view as is needed

The idea is that business logic should be centralised into the model as much as possible. Controllers should have essentially no knowledge of the business logic. Views obviously need to know some business logic – they can’t be totally generic.

Most programmers instead try thin model, fat controller, thin view. But it doesn’t really work: the view can’t stay thin if the user interface is genuinely complex, and you end up with duplicated code in many controllers.

Anyway, I’ll probably expand on this later – it ties in deeply to mgnb software’s development philosophy – so stay tuned for more!