GRASP (Object Oriented Design)

GRASP (Object Oriented Design)

GRASP stands for General Responsibility Assignment Software Patterns (or sometimes Principles). It is used in object oriented design, and gives guidelines for assigning responsibility to classes and objects.

Examples of different patterns/principles used in GRASP are: Information Expert, Creator, Controller, Low Coupling, High Cohesion, Polymorphism, Pure Fabrication, Indirection, Protected Variations. All these patterns answer some software problem, and in almost every case these problems are common to almost every software development project, thus they don't exist to facilitate new information but to better document and standardize old, tried-and-true programming principles in object oriented design.

"The critical design tool for software development is a mind well educated in design principles. It is not the UML or any other technology" (Larman, Craig. "Applying UML and Patterns - Third Edition". [http://authors.phptr.com/larman/uml_ooad/index.html] ). Thus, GRASP is really a mental toolset, a learning aid to help in the design of object oriented software.

Patterns

Information Expert

The Information Expert pattern provides the general principles associated with the assignment of responsibilities to objects. The information expert pattern states that responsibility should be assigned to the information expert—the class that has all the essential information. Systems which appropriately utilize the information expert pattern are easier to understand, maintain and expand as well as increase the possibility that an element can be reused in future development.(Larman 294)]

Creator

The Creator pattern solves the problem of who should be responsible for the creation of a new instance of a class. The creator pattern is important because creation of objects is one of the most ubiquitous activities in an object-oriented system. A system that effectively utilizes the creator pattern can also support low coupling, increased understandability, encapsulation and the likelihood that the object in question will be capable of sustaining reuse. Given two classes, class B and Class A, class B should be responsible for the creation of A if class B contains or compositely aggregates, records, closely uses or contains the initializing information for class A. It could then be stated that B is natural object to be a creator of A objects.

The Factory pattern is a common alternative to Creator when there are special considerations, such as complex creation logic. This is achieved by creating a Pure Fabrication object (see below), called Factory that handles the creation.

[(Larman 292)]

Controller

The Controller pattern assigns the responsibility of dealing with system events to a non-UI class that represent the overall system or a use case scenario. 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 (for instance, for use cases "Create User" and "Delete User", one can have one "UserController", instead of two separate use case controllers).It is defined as the first object beyond the UI layer that receives and coordinates ("controls") a system operation. The controller should delegate to other objects the work that needs to be done; it coordinates or controls the activity. It should not do much work itself.The GRASP Controller can be thought of as being a part of the Application/Service layer [ [http://tech.groups.yahoo.com/group/domaindrivendesign/message/7582 Comparison/discussion of the GRASP Controller Layer vs. Application/Service Layer] ] (assuming that the application has made an explicit distinction between the App/Service layer and the Domain layer) in an object-oriented system with common layers.

Low Coupling

Low Coupling is an evaluative pattern, which dictates how to assign responsibilities to support:
* low dependency between classes;
* low impact in a class of changes in other classes;
* high reuse potential;

High Cohesion

High Cohesion is an evaluative pattern that attempts to keep objects appropriately focused, manageable and understandable. High cohesion is generally used in support of Low Coupling. High cohesion means that the responsibilities of a given element are strongly related and highly focused. Breaking programs into classes and subsystems is an example of activities that increase the cohesive properties of a system. Alternatively, low cohesion is a situation in which a given element has too many unrelated responsibilities. Elements with low cohesion often suffer from being hard to comprehend, hard to reuse, hard to maintain and adverse to change.(Larman 314-315)]

Polymorphism

According to the Polymorphism pattern, responsibility of defining the variation of behaviors based on type is assigned to the types for which this variation happens. This is achieved using polymorphic operations.

Pure Fabrication

A pure fabrication is a class that does not represent a concept in the problem domain, specially made up to achieve low coupling, high cohesion, and the reuse potential thereof derived (when a solution presented by the "Information Expert" pattern does not).This kind of class is called "Service" in Domain-driven design.

Indirection

The Indirection pattern supports low coupling (and reuse potential) between two elements by assigning the responsibility of mediation between them to an intermediate object. 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.

Protected Variations

The Protected Variations pattern protects elements from the variations on other elements (objects, systems, subsystems) by wrapping the focus of instability with an interface and using polymorphism to create various implementations of this interface.

ee also

*Design pattern (computer science)
*Design Patterns

Works Cited


*citebook|last=Larman|first=Craig|authorlink=Craig Larman|title=Applying UML and Patterns - An Introduction to Object-Oriented Analysis and Design and Iterative Development|origdate=2004|edition=3rd|publisher=Prentice Hall PTR|location Upper Saddle River, New Jersey|year=2005|isbn=0-13-148906-2

References


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Object-oriented design — OOD redirects here. OOD may also refer to Officer of the Deck, Officer of the day, or the Ood. Object oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to… …   Wikipedia

  • Object-oriented programming — Programming paradigms Agent oriented Automata based Component based Flow based Pipelined Concatenative Concurrent computing …   Wikipedia

  • GRASP — may refer to:* GRASP (multimedia authoring software), a multimedia authoring software * GRASP (SAT solver), a SAT instance solver * GRASP (Object Oriented Design) * Greedy randomized adaptive search procedure * Given, Required, Analysis, Solution …   Wikipedia

  • Design Patterns — Not to be confused with the concept of a Design pattern. Design Patterns: Elements of Reusable Object Oriented Software …   Wikipedia

  • Design pattern (computer science) — In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for …   Wikipedia

  • GRASP — En diseño orientado a objetos, GRASP son patrones generales de software para asignación de responsabilidades, es el acrónimo de General Responsibility Assignment Software Patterns . Aunque se considera que más que patrones propiamente dichos, son …   Wikipedia Español

  • Software design pattern — In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly into code. It is a… …   Wikipedia

  • GRASP — (General Responsibility Assignment Software Patterns) bezeichnet eine Menge von Entwurfsmustern, mit denen die Zuständigkeit bestimmter Klassen objektorientierter Systeme festgelegt wird. Sie beschreiben also allgemein welche Klassen und Objekte… …   Deutsch Wikipedia

  • Design Pattern — Patron de conception Pour les articles homonymes, voir Patron. Un patron de conception (design pattern en anglais) est un concept de génie logiciel destiné à résoudre les problèmes récurrents suivant le paradigme objet. En français on utilise… …   Wikipédia en Français

  • Design Patterns — Patron de conception Pour les articles homonymes, voir Patron. Un patron de conception (design pattern en anglais) est un concept de génie logiciel destiné à résoudre les problèmes récurrents suivant le paradigme objet. En français on utilise… …   Wikipédia en Français

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”