Wednesday, December 16, 2015

HeadFirst Design Pattern CH12: MVC Pattern

We know the MVC Pattern

The Controller will receive the request, call the appropriate Model, then pass the control to the view.

an example could be

Here we have the Student Class as the Model

The view is defined like this

The Controller is defined like this

NOTE: in the previous example, the controller calls the Model, sometimes the Model might update the controller about its state.

NOTE: int the MVC, we can consider the Model as Observer Pattern, the Controller as Strategy Pattern (You can change the controller whenever you want) and the View as a Composite pattern (consider the view as a page with multiple elements inside)

No comments:

Post a Comment