Compound Patterns
Defined
A compound pattern combines two or more patterns into a solution that solves a recurring or general problem.Model View Controller is an example of a compound pattern (MVC is just a few patterns put together)
MVC is a paradigm for factoring your code into functional segments, so you brain does not explode.
The Model View Controller Pattern (MVC) is a compound pattern consisting of the Observer, Strategy and Composite Patterns.
Diagrams
Diagrams for MVCPatterns in MVC
Lets start with the model. As you might have guessed the model uses the Observer pattern to keep the views and controllers updated on the latest state changes.
The view and the controller, on the other hand, implement the Strategy Pattern. The controller is the behavior of the view, and it can be easily exchanged with another controller if you want different behavior. The view itself also uses a pattern internally to manage the windows, buttons and other components of the display: the composite pattern.
Bullet Points
- The Model View Controller Pattern (MVC) is a compound pattern consisting of the Observer, Strategy and Composite Patterns.
- The model makes use of the Observer Pattern so that it can keep observers update yet stay decoupled from them.
- The controller is the strategy for the view. The view can use different implementations of the controller to get different behavior.
- The view uses the Composite Pattern to implement the user interface, which usually consists of nested components like panels, frames and buttons.
- These patterns work together to decouple the three players in the MVC model, which keeps designs clear and flexible
- The Adapter Pattern can be used to adapt a new model to an existing view and controller.
No comments:
Post a Comment