

#Indirection pattern how to
Problem: Where to assign responsibility, to avoid direct coupling between two (or more) things? How to de-couple objects so that low coupling is supported and reuse potential remains higher? This ensures that coupling between them remains low. An example of this is the introduction of a controller component for mediation between data (model) and its representation (view) in the model-view-controller pattern. The indirection pattern supports low coupling and reuses potential between two elements by assigning the responsibility of mediation between them to an intermediate object. Related Pattern or Principle: Command, Facade, Layers, Pure Fabrication The GRASP Controller can be thought of as being a part of the application/service layer (assuming that the application has made an explicit distinction between the application/service layer and the domain layer) in an object-oriented system with common layers in an information system logical architecture. The controller should delegate the work that needs to be done to other objects it coordinates or controls the activity. The controller is defined as the first object beyond the UI layer that receives and coordinates ("controls") a system operation. Alternatively a facade controller would be used this applies when the object with responsibility for handling the event represents the overall system or a root object. For instance, for the use cases Create User and Delete User, one can have a single class called UserController, instead of two separate use case controllers. Solution: A use case controller should be used to deal with all system events of a use case, and may be used for more than one use case.

Problem: Who should be responsible for handling an input system event? A controller object is a non-user interface object responsible for receiving or handling a system event. The controller pattern assigns the responsibility of dealing with system events to a non- UI class that represents the overall system or a use case scenario. Related Pattern or Principle: Low Coupling, Factory pattern Controller Instances of B have the initializing information for instances of A and pass it on creation.Instances of B closely use instances of A.Instances of B contain or compositely aggregate instances of A.Solution: In general, Assign class B the responsibility to create object A if one, or preferably more, of the following apply: Which class is responsible for creating objects is a fundamental property of the relationship between objects of particular classes. The creation of objects is one of the most common activities in an object-oriented system. Many patterns, given a specific category of problem, guide the assignment of responsibilities to objects. In object-oriented design, a pattern is a named description of a problem and solution that can be applied in new contexts ideally, a pattern advises us on how to apply its solution in varying circumstances and considers the forces and trade-offs. It is not UML or any other technology." : 272 Thus, the GRASP principles are really a mental toolset, a learning aid to help in the design of object-oriented software.
#Indirection pattern software
Larman states that "the critical design tool for software development is a mind well educated in design principles. These techniques have not been invented to create new ways of working, but to better document and standardize old, tried-and-tested programming principles in object-oriented design.

All these patterns solve some software problems common to many software development projects. The different patterns and principles used in GRASP are controller, creator, indirection, information expert, low coupling, high cohesion, polymorphism, protected variations, and pure fabrication. General Responsibility Assignment Software Patterns (or Principles), abbreviated GRASP, is a set of "eight fundamental principles in object design and responsibility assignment" : 6 first published by Craig Larman in his 1997 book Applying UML and Patterns. JSTOR ( May 2015) ( Learn how and when to remove this template message).Please improve this article by adding secondary or tertiary sources.įind sources: "GRASP" object-oriented design – news This article relies excessively on references to primary sources.
