Model-view-controller

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,835
4,815
75
The "model-view-controller" pattern. I've seen that pop up frequently over the past few months; but I don't really understand it. Nothing I've read has really helped.

I understand "view". Databases have views. And I can see how a JSP page on a J2EE app, for instance, could be a view.

What I don't get is model and controller. Wikipedia says something about the model being related to a database backend; but that the database backend itself is outside the model-view-controller pattern.

So, what are "model" and "controller"? Or maybe, considering the amount of stuff I would put in or call from a JSP page, what are they that a view is not?
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
The term has become waaay overused, imo. Model-view-controller is a classic architectural pattern for an application with data (state), rules (transformations of state), and an interface. Basically the application data is the model, the controller is the engine that takes input and applies state transformations to the model, and the view is some view of the model, i.e. the user interface showing field values, or a visualization like a graph.

It's a decoupling/modularity pattern that separates the application architecture into these large-grained subsystems with distinct responsibilities.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Originally posted by: Ken g6
Oh, so it's just a finite state machine with a view? :Q

That makes much more sense! Thanks! :)

I'd say a finite state machine is one representation of the controller part of a MVC architecture. FSMs operate on models (to the extent that the states are part of the model, they don't have to be).