Content deleted Content added
Quuxplusone (talk | contribs) if it's not related to SOLID, then don't mention SOLID in the intro paragraph |
Quuxplusone (talk | contribs) clean up (except for the middle section which is still a mess) |
||
Line 3:
{{primary|date=May 2015}}
'''General Responsibility Assignment Software Patterns''' (or '''Principles'''), abbreviated '''GRASP''',
The different patterns and principles used in GRASP are controller, creator, indirection, information expert, low [[coupling (computer science)|coupling]], high [[cohesion (computer science)|cohesion]], [[Polymorphism (object-oriented programming)|polymorphism]], protected variations, and pure fabrication.<ref name="Umair2018"/> All these patterns
==
In
===Information expert===
Line 22:
Using the principle of information expert, a general approach to assigning responsibilities is to look at a given responsibility, determine the information needed to fulfill it, and then determine where that information is stored.
This will lead to placing the responsibility on the class with the most information required to fulfill it.<ref name="Larman2004"/>{{
'''Related Pattern or Principle''': Low Coupling, High Cohesion
Line 35:
* Instances of <code>B</code> record instances of <code>A</code>
* Instances of <code>B</code> closely use instances of <code>A</code>
* Instances of <code>B</code> have the initializing information for instances of <code>A</code> and pass it on creation.<ref name="Larman2004"/>{{
'''Related Pattern or Principle''': Low Coupling, [[Factory pattern]]
Line 46:
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. 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.
The controller is defined as the first object beyond the UI layer that receives and coordinates ("controls") a system operation. The controller should delegate the work that needs to be done to other objects; 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<ref
'''Related Pattern or Principle''': [[Command_pattern|Command]], [[Facade_pattern|Facade]], [[Layer_(object-oriented_design)|Layers]], Pure Fabrication
Line 56:
Solution: Assign the responsibility to an intermediate object to mediate between other components or services so that they are not directly coupled. <br>
===Low coupling===
Line 66:
===High cohesion===
{{main|Cohesion (computer science)}}
'''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, reuse, maintain and change.<ref name="
===Polymorphism===
Line 93:
* [[Anemic ___domain model]]
* [[Design pattern (computer science)]]
* [[Design Patterns (book)|''Design Patterns'' (book)]]
* [[SOLID (object-oriented design)]]
==References==
<references>
<ref name="Larman2001">{{cite book |author=[[Craig Larman]] |title=Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified Process |edition=2nd |publisher=Prentice Hall |year=2001 |isbn=0-13-092569-1 |url=https://personal.utdallas.edu/~chung/SP/applying-uml-and-patterns.pdf}}</ref>
<ref name="Larman2004">{{cite book |author=[[Craig Larman]] |title=Applying UML and Patterns
<ref name="Umair2018">{{cite web |author=Muhammad Umair |title=SOLID, GRASP, and Other Basic Principles of Object-Oriented Design |website=DZone |date=2018-02-26 |url=https://dzone.com/articles/solid-grasp-and-other-basic-principles-of-object-o}}</ref>
<ref name="Yahoo">{{cite web |url=https://groups.yahoo.com/neo/groups/domaindrivendesign/conversations/messages/7582 |url-status=dead |title=Application Layer like business facade? |work=Yahoo! Groups (domaindrivendesign) |access-date=2010-07-15}}</ref>
</references>
[[Category:Software design]]
[[Category:Programming principles]]
|