Saturday, January 9, 2010

MVC - Beginner

To Confuse more... It is separation of UI with business logic and underlying object. The View captures user events and passes it on to Controller. The controller accepts events from view and passes it on to Model. The model exposes behaviour and activities to Controller, and returns appropriate result to controller. Controller takes result from Model and signals (updates) view accordingly.

To my best of understanding (so far). Each of these entities interact with each other on contract (interface) bases. View has the handle of desired controller, and on each user event that view exposes it knows the corresponding method/event to invoke of the controller.

Controller has handle of View and Model. On each event/method being exposed it signals the model about user activity. Controller knows nothing about the state of Model, it just passes the user event and input (got from view) to Model. Model maintains its internal state, and as per event and user event may choose to update its state. The state that Model choose to expose to user is exposed through some contract (or may be directly to controller). On invoking some method of model, controller sends the state back to View, which is then shown to the user.

Phew... i hope my understanding is correct. Will write more about it.

No comments:

Post a Comment