CSC/ECE 517 Fall 2010/ch7 7d ID: Difference between revisions
No edit summary |
No edit summary |
||
Line 15: | Line 15: | ||
Indirection pattern describes how the data resources can be exchanged in communication without disrupting the existing application. | Indirection pattern describes how the data resources can be exchanged in communication without disrupting the existing application. | ||
One of the best applications of Indirection pattern is to embed multilingual texts in language-independent data or into software applications. An high level example would be to support multi-languages like English, Spanish, French for user manual for a software system. | One of the best applications of Indirection pattern is to embed multilingual texts in language-independent data or into software applications. An high level example would be to support multi-languages like English, Spanish, French for user manual for a software system. | ||
==Example: MVC Framework== | |||
[http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller Model-View-Controller] is an example for the indirection pattern often used by applications that need the ability to maintain multiple views of the same data. By indirection pattern, responsibilities like handling event call backs can be taken care by controller and the view can operate its interface logic without any changes. A controller is an intermediary class whose job is to coordinate the events. It sees to it the messages are sent to the correct expert in the model. | |||
===Advantages=== | |||
# Because of this separation, multiple views and controllers can interface with the same model. Even new types of views and controllers that never existed before can interface with a model without forcing a change in the model design. | |||
# Events typically cause a controller to change a model, or view, or both. Whenever a controller changes a model’s data or properties, all dependent views are automatically updated. Similarly, whenever a controller changes a view, for example, by revealing areas that were previously hidden, the view gets data from the underlying model to refresh itself. |
Revision as of 04:38, 2 December 2010
Introduction
GRASP(General Responsibility Assignment Software Patterns) in object oriented design gives guidelines for assigning responsibility to classes and objects. Some of the guidelines include the following:
- To assign a responsibility to a class
- To avoid or minimize additional dependencies
- To maximise cohesion and minimise coupling
- To increase reuse and decrease maintenance
- To maximise understandability
There are nine GRASP patterns: Creator, Controller, Pure Fabrication, Information Expert, High Cohesion, Indirection, Low Coupling, Polymorphism and Protected Variations. In this chapter we will look at the Indirection design pattern with some examples.
What is Indirection Pattern?
Indirection pattern reduces the coupling between the data objects by setting up an intermediary object which performs the mediation between the objects. The intermediary creates an indirection between the other components. Indirection is utilized by GoF proxy, Bridge, and Mediator patterns. Architectural concepts developed currently for software design and development demand the decomposition of a system into independent modules with well-defined interfaces. This leads to decoupling of data from the rest of the system by hiding the data access details in an abstract interface. To achieve this, it is good to use an intermediate object to mediate between other objects. Indirection pattern describes how the data resources can be exchanged in communication without disrupting the existing application. One of the best applications of Indirection pattern is to embed multilingual texts in language-independent data or into software applications. An high level example would be to support multi-languages like English, Spanish, French for user manual for a software system.
Example: MVC Framework
Model-View-Controller is an example for the indirection pattern often used by applications that need the ability to maintain multiple views of the same data. By indirection pattern, responsibilities like handling event call backs can be taken care by controller and the view can operate its interface logic without any changes. A controller is an intermediary class whose job is to coordinate the events. It sees to it the messages are sent to the correct expert in the model.
Advantages
- Because of this separation, multiple views and controllers can interface with the same model. Even new types of views and controllers that never existed before can interface with a model without forcing a change in the model design.
- Events typically cause a controller to change a model, or view, or both. Whenever a controller changes a model’s data or properties, all dependent views are automatically updated. Similarly, whenever a controller changes a view, for example, by revealing areas that were previously hidden, the view gets data from the underlying model to refresh itself.