SlideShare a Scribd company logo
8
Most read
9
Most read
16
Most read
GRASP PATTERNS
AND ITS TYPES
PRESENTED BY:
SAIRA BANO
RAMSHA GHAFFAR
SYED HASSAN ALI HASHMI
DEFINITION
 GRASP or General Responsibility Assignment Software Principles help
guide object-oriented design by clearly outlining WHO does WHAT.
object or class is responsible for what action or role? GRASP also helps us
define how classes work with one another. The key point of GRASP is to
have efficient, clean, understandable code
PATTERNS
 In OO design, a pattern is a named description of a problem and solution
that can be applied to new contexts; ideally, a pattern advises us on how to
apply its solution in varying circumstances and considers the forces and
trade-offs. Many patterns, given a specific category of problem, guide the
assignment of responsibilities to objects.
PRINCIPLES
Within GRASP there are nine principles that we want to cover. They are:
 Creator
 Controller
 Information Expert
 Low Coupling
 High Cohesion
 Indirection
 Polymorphism
 Protected Variations
 Pure Fabrication.
We'll be talking about a chess game and the various responsibilities and
relationships between the objects and classes within the game.
CREATOR
 The Creator defines WHO instantiates WHAT object. In object-oriented
design lingo, we need to ask the question of who creates an object A. The
solution is that we give class B the role of instantiating (creating an
instance of) a class A if:
 B contains A
 B uses most of A's features
 B can initialize A
So far this doesn't really help us understand how this works. Let's use a real-world
example of a chess game. A chess game includes 2 players, 32 pieces (16 per player)
and a game board with 64 squares.
CONTROLLER
 In our chess example, the end user is going to interact with our program through a user
interface (UI). The Controller is the FIRST object to receive a command from the UI. In
our case, when the user presses Play, the first object that should be triggered is the Chess
Game.
INFORMATION EXPERT
 Information expert is a principle used to determine where to delegate
responsibilities. These responsibilities include methods, computed fields,
and so on.
 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.
 Information expert will lead to placing the responsibility on the class with
the most information required to fulfill it
 The Information Expert pattern states that we need to assign responsibilities to the right
expert. Is the game board itself the expert on how pieces can move or are the pieces
themselves the experts at their moves? In the case of the chess board, the piece is the
expert on the possible move options for that piece.
INFORMATION EXPERT
LOW COUPLING
 Coupling is a measure of how strongly one element is connected to, has
knowledge of, or relies on other elements. Low coupling is an evaluative
pattern that dictates how to assign responsibilities to support
 lower dependency between the classes,
 change in one class having lower impact on other classes,
 higher reuse potential.
Grasp patterns and its types
 Low Coupling can be described as following the path of least resistance.
Coupling is a measure of how much objects are tied to one another. We
can follow the information expert for the lowest level of coupling. So, to
get the moves available to a piece, we start with the information expert,
and not some other class. In the chess game, the MovePiece class
needs to get information from the board and the place it intends to move
to. We can couple all of this together in one flow:
LOW COUPLING
HIGH COHESION
 It is important to have code that is clean. Objects need to be manageable,
easy to maintain and have clearly-stated properties and objectives. This
is High Cohesion which includes defined purposes of classes, ability to
reuse code, and keeping responsibility to one unit. High Cohesion, Low
Coupling, and clearly defined responsibilities go together. To achieve High
Cohesion, a class should have ONE job. A game piece should move across
the board. It should not need to setup the board or define moves for other
players.
INDIRECTION
 In order to support lower coupling between objects, we look
for Indirection, that is creating an intersection object between two or more
objects so they aren't connected to each other. Indirection and
Polymorphism go hand in hand.
POLYMORPHISM
 This sounds like a science fiction term, but Polymorphism really means
that one thing can be performed in different ways. All chess pieces can
move, but each has a special way of moving.
PROTECTED VARIATION
 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.
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 a "service" in domain-driven design.
OVERVIEW
Informational Expert Assign a responsibility to the class that has the information
needed to fulfill it..
Creator Assign class B the responsibility to create an instance
class A if one of these is true (the more the better):
• B ”contains” or compositely aggregates A.
• B records A.
• B closely uses A.
• B has the initializing data for A that will be passed
A when it is created. Thus B is an Expert with
to creating A.
Controller Assign the responsibility to a class representing one of
the following choices:
• Major subsystem classes
• A use case scenario classes within which the system
event occurs.
Low Coupling Assign a responsibility so that coupling remains low.
High Cohesion Assign a responsibility so that cohesion remains high.
OVERVIEW
Polymorphism The same name operations (methods) in the difference
classes is defined. And assign a responsibility to the class
the class that the behavior is changed.
Pure Fabrication Define a class for convenience sake that doesn’t express
the concept of the problem area at all.
Indirection Assign the responsibility to an intermediate object to
mediate between other components or services, so that
they are not directly coupled.
Protected Variations Assign responsibility to create a stable interface around
unstable or predictably variable subsystem or
Grasp patterns and its types

More Related Content

PPTX
ORO551 RES - Unit 1 - Role and potential of new and renewable source
PPT
Use case Diagram and Sequence Diagram
PPTX
CMSC 56 | Lecture 3: Predicates & Quantifiers
PPT
Problem solving method
PPTX
Secure Hash Algorithm
PDF
Sequence diagram- UML diagram
PDF
Solution manual-of-probability-statistics-for-engineers-scientists-9th-editio...
PPTX
ORO551 RES - Unit 1 - Role and potential of new and renewable source
Use case Diagram and Sequence Diagram
CMSC 56 | Lecture 3: Predicates & Quantifiers
Problem solving method
Secure Hash Algorithm
Sequence diagram- UML diagram
Solution manual-of-probability-statistics-for-engineers-scientists-9th-editio...

What's hot (20)

PPT
Class diagrams
PPT
Unit 5 testing -software quality assurance
PPT
Requirement specification (SRS)
PDF
I. AO* SEARCH ALGORITHM
PPT
Object Oriented Analysis and Design
PPTX
Design Concept software engineering
PPTX
Context model
PPTX
Concurrency Control in Database Management System
PPTX
Issues in knowledge representation
PPT
Flow oriented modeling
PDF
Dbms 14: Relational Calculus
PPTX
Case Study - SUN NFS
PPTX
Interaction Modeling
PPT
Communication primitives
PPT
System Models in Software Engineering SE7
PPTX
Database System Architectures
PPTX
Component and Deployment Diagram - Brief Overview
PDF
1. GRID COMPUTING
PPTX
Semantic net in AI
PDF
Ch 7 Knowledge Representation.pdf
Class diagrams
Unit 5 testing -software quality assurance
Requirement specification (SRS)
I. AO* SEARCH ALGORITHM
Object Oriented Analysis and Design
Design Concept software engineering
Context model
Concurrency Control in Database Management System
Issues in knowledge representation
Flow oriented modeling
Dbms 14: Relational Calculus
Case Study - SUN NFS
Interaction Modeling
Communication primitives
System Models in Software Engineering SE7
Database System Architectures
Component and Deployment Diagram - Brief Overview
1. GRID COMPUTING
Semantic net in AI
Ch 7 Knowledge Representation.pdf
Ad

Similar to Grasp patterns and its types (20)

PPTX
Advance oops concepts
PPTX
Knowledge-Based Agent in Artificial intelligence.pptx
PPTX
SAD02 - Object Orientation
PDF
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVER
PDF
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVER
DOCX
PDF
Oops concepts
PPT
Jedi slides 2.1 object-oriented concepts
PDF
EEE oops Vth semester viva questions with answer
PPTX
OBJECT ORIENTED PROGRAMMING CONCEPTS IN C++.pptx
PDF
Java chapter 3
PPTX
SAD05 - Encapsulation
PDF
Object oriented software engineering concepts
PPT
General OOP concept [by-Digvijay]
DOCX
Ece478 12es_final_report
PPT
The Role Of Ontology In Modern Expert Systems Dallas 2008
PPT
PPT
PPTX
Patterns of Assigning Responsibilities
Advance oops concepts
Knowledge-Based Agent in Artificial intelligence.pptx
SAD02 - Object Orientation
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVER
ANSWER SET PROGRAMMING (DLV – CLINGO):CONNECT 4 SOLVER
Oops concepts
Jedi slides 2.1 object-oriented concepts
EEE oops Vth semester viva questions with answer
OBJECT ORIENTED PROGRAMMING CONCEPTS IN C++.pptx
Java chapter 3
SAD05 - Encapsulation
Object oriented software engineering concepts
General OOP concept [by-Digvijay]
Ece478 12es_final_report
The Role Of Ontology In Modern Expert Systems Dallas 2008
Patterns of Assigning Responsibilities
Ad

More from Syed Hassan Ali (7)

PPTX
COCOMO Model in software project management
PPTX
Resource Allocation In Software Project Management
PPTX
Accountability And Auditing In Professional Practice
PPTX
Use Case Modeling In UML
PPTX
Software Generic Design Process.
PPTX
Process synchronization
PPTX
Structured Query Language (SQL)
COCOMO Model in software project management
Resource Allocation In Software Project Management
Accountability And Auditing In Professional Practice
Use Case Modeling In UML
Software Generic Design Process.
Process synchronization
Structured Query Language (SQL)

Recently uploaded (20)

PDF
Pre independence Education in Inndia.pdf
PPTX
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
PDF
Insiders guide to clinical Medicine.pdf
PDF
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
PPTX
How to Manage Starshipit in Odoo 18 - Odoo Slides
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Cell Structure & Organelles in detailed.
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Business Ethics Teaching Materials for college
PDF
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
Pre independence Education in Inndia.pdf
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
Insiders guide to clinical Medicine.pdf
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
How to Manage Starshipit in Odoo 18 - Odoo Slides
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
Renaissance Architecture: A Journey from Faith to Humanism
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Cell Structure & Organelles in detailed.
Open Quiz Monsoon Mind Game Final Set.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Business Ethics Teaching Materials for college
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
O7-L3 Supply Chain Operations - ICLT Program
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf

Grasp patterns and its types

  • 1. GRASP PATTERNS AND ITS TYPES PRESENTED BY: SAIRA BANO RAMSHA GHAFFAR SYED HASSAN ALI HASHMI
  • 2. DEFINITION  GRASP or General Responsibility Assignment Software Principles help guide object-oriented design by clearly outlining WHO does WHAT. object or class is responsible for what action or role? GRASP also helps us define how classes work with one another. The key point of GRASP is to have efficient, clean, understandable code
  • 3. PATTERNS  In OO design, a pattern is a named description of a problem and solution that can be applied to new contexts; ideally, a pattern advises us on how to apply its solution in varying circumstances and considers the forces and trade-offs. Many patterns, given a specific category of problem, guide the assignment of responsibilities to objects.
  • 4. PRINCIPLES Within GRASP there are nine principles that we want to cover. They are:  Creator  Controller  Information Expert  Low Coupling  High Cohesion  Indirection  Polymorphism  Protected Variations  Pure Fabrication.
  • 5. We'll be talking about a chess game and the various responsibilities and relationships between the objects and classes within the game.
  • 6. CREATOR  The Creator defines WHO instantiates WHAT object. In object-oriented design lingo, we need to ask the question of who creates an object A. The solution is that we give class B the role of instantiating (creating an instance of) a class A if:  B contains A  B uses most of A's features  B can initialize A
  • 7. So far this doesn't really help us understand how this works. Let's use a real-world example of a chess game. A chess game includes 2 players, 32 pieces (16 per player) and a game board with 64 squares.
  • 8. CONTROLLER  In our chess example, the end user is going to interact with our program through a user interface (UI). The Controller is the FIRST object to receive a command from the UI. In our case, when the user presses Play, the first object that should be triggered is the Chess Game.
  • 9. INFORMATION EXPERT  Information expert is a principle used to determine where to delegate responsibilities. These responsibilities include methods, computed fields, and so on.  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.  Information expert will lead to placing the responsibility on the class with the most information required to fulfill it
  • 10.  The Information Expert pattern states that we need to assign responsibilities to the right expert. Is the game board itself the expert on how pieces can move or are the pieces themselves the experts at their moves? In the case of the chess board, the piece is the expert on the possible move options for that piece. INFORMATION EXPERT
  • 11. LOW COUPLING  Coupling is a measure of how strongly one element is connected to, has knowledge of, or relies on other elements. Low coupling is an evaluative pattern that dictates how to assign responsibilities to support  lower dependency between the classes,  change in one class having lower impact on other classes,  higher reuse potential.
  • 13.  Low Coupling can be described as following the path of least resistance. Coupling is a measure of how much objects are tied to one another. We can follow the information expert for the lowest level of coupling. So, to get the moves available to a piece, we start with the information expert, and not some other class. In the chess game, the MovePiece class needs to get information from the board and the place it intends to move to. We can couple all of this together in one flow: LOW COUPLING
  • 14. HIGH COHESION  It is important to have code that is clean. Objects need to be manageable, easy to maintain and have clearly-stated properties and objectives. This is High Cohesion which includes defined purposes of classes, ability to reuse code, and keeping responsibility to one unit. High Cohesion, Low Coupling, and clearly defined responsibilities go together. To achieve High Cohesion, a class should have ONE job. A game piece should move across the board. It should not need to setup the board or define moves for other players.
  • 15. INDIRECTION  In order to support lower coupling between objects, we look for Indirection, that is creating an intersection object between two or more objects so they aren't connected to each other. Indirection and Polymorphism go hand in hand.
  • 16. POLYMORPHISM  This sounds like a science fiction term, but Polymorphism really means that one thing can be performed in different ways. All chess pieces can move, but each has a special way of moving.
  • 17. PROTECTED VARIATION  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.
  • 18. 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 a "service" in domain-driven design.
  • 19. OVERVIEW Informational Expert Assign a responsibility to the class that has the information needed to fulfill it.. Creator Assign class B the responsibility to create an instance class A if one of these is true (the more the better): • B ”contains” or compositely aggregates A. • B records A. • B closely uses A. • B has the initializing data for A that will be passed A when it is created. Thus B is an Expert with to creating A. Controller Assign the responsibility to a class representing one of the following choices: • Major subsystem classes • A use case scenario classes within which the system event occurs. Low Coupling Assign a responsibility so that coupling remains low. High Cohesion Assign a responsibility so that cohesion remains high.
  • 20. OVERVIEW Polymorphism The same name operations (methods) in the difference classes is defined. And assign a responsibility to the class the class that the behavior is changed. Pure Fabrication Define a class for convenience sake that doesn’t express the concept of the problem area at all. Indirection Assign the responsibility to an intermediate object to mediate between other components or services, so that they are not directly coupled. Protected Variations Assign responsibility to create a stable interface around unstable or predictably variable subsystem or