SlideShare a Scribd company logo
GRASP
General Responsibility Assignment Software Patterns

author: Yuriy Shapovalov (Yurii_Shapovalov@epam.com)
Where it came from?
• GRASP like a term and principles firstly was described at Craig
Larman’s book “Applying UML and Patterns”

GRASP stands for:
• General
• Responsibility

• Assignment
• Software
• Patterns (Principles)
Nine Patterns
• Creator
• Informational Expert
• Controller
• Low Coupling
• High Cohesion
• Polymorphism
• Pure Fabrication
• Indirection
• Protected Variation
Differences from GoF and SOLID
• Patterns of assigning responsibilities (RDD)
• GRASP declares more common principles responsibility
separation, when GoF describe more specific and complex
design patterns.

• SOLID – more common OOP principles less oriented on
responsibility segregation
• GRASP somewhere between GoF patterns and SOLID principles.
Representation in Sequence Diagram (UML)
• Relationship between methods and responsibilities.
• Assuming that Sale objects are responsible to create Payment
objects
:Sale

makePayment(cashTendered)
create(cashTendered)

Confidential

:Payment

5
Responsibility-Driven Design
• “doing” responsibilities
– Doing something itself, such as creation an object or doing a
calculation.

– Initiating action in other objects
– Controlling and coordinating activities in other objects.

• “knowing” responsibilities
– Knowing about encapsulated data.
– Knowing about related objects.

– Knowing about things it can derive or calculate.
Informational Expert
Problem: Which class possesses information about object A?
More common question: What is a general principle of assigning
responsibilities to objects?
Assign the responsibility to the class that knows the necessary
information for performing required action and fulfill the
responsibility.
Informational Expert
Tell, Don’t Ask.
“Procedural code gets information then, makes decisions. Objectoriented code tells object to do things” © Alec Sharp
Informational Expert

A

B

C

D

GetDataX()
GetDataY()
GetDataZ()

return Z
return Y
return X
DO
Informational Expert

A

B

C

D

DoAction()
DoAction(X)
DoAction(Y)

DO
Creator
Problem: Who should be responsible for creating object A?
In general, a class B should be responsible for creating instances of
class A if one, or preferably more, of the following apply:
• Instances of B contain or compositely aggregate instances of A
• Instances of B record instances of A

• Instances of B closely use instances of A
• Instances of B have the initializing information for instances of A
and pass it on creation.
Creator
• The goal is to define creator-object, which will be related to all
created objects.
64
Board

create

Square

Board

create

Square
Creator
In case of complex creation login, based on some external
cases, make sense to use Factory pattern, and delegate creation
responsibility to auxiliary class.
• Related patterns: Concrete Factory and Abstract Factory
Low Coupling
• Problem: How to reduce design change impact, support low
dependency and increase reuse?

Coupling is the degree, defines how tightly one component linked
to other components, or how much information it knows about
other components.
• A change in one module usually forces a ripple effect of changes in other
modules.
• Assembly of modules might require more effort and/or time due to the
increased inter-module dependency.

• A particular module might be harder to reuse and/or test because
dependent modules must be included.
Tightly Coupled Application

Confidential

15
Low Coupling
• Assign a responsibility so that coupling remains low.
Low Coupling is an evaluative pattern, which 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.

http://en.wikipedia.org/wiki/Coupling_(computer_science)#Module_coupling
High Cohesion
• Problem: How to keep objects
focused, understandable, manageable, and support low
coupling?
Cohesion is a measure of how strongly related or focused the
responsibilities of a single module are.
High Cohesion is an evaluative pattern that attempts to keep
objects appropriately focused, manageable and understandable.

Alternatively, low cohesion is a situation in which a given element
has too many unrelated responsibilities (“God Object”)
High Cohesion
Cohesion is decreased if:
• The functionalities embedded in a class, accessed through its methods, have
little in common.

• Methods carry out many varied activities, often using coarsely grained or
unrelated sets of data.

Disadvantages of low cohesion (or “weak cohesion”) are:
• Increased difficulty in understanding modules.

• Increased difficulty in maintaining a system, because logical changes in the
domain affect multiple modules, and because changes in one module require
changes in related modules.
• Increased difficulty in reusing a module because most applications won’t
need the random set of operations provided by a module.
High Cohesion

A

A

??
DoA()

DoA()

DoB()

DoC()

DoB()

DoC()

??
Controller
• Problem: Who should be responsible for handling events and
messages from external actors (UI, …)?

• Assign the responsibility to a class, such as:
– A class that represents the overall system, device, or subsystem.
• Façade Controller Pattern

– A class that represent a use case, whereby performs handling
particular system operation.
• Use Case Controller Pattern

• Generally does not perform operation by itself, but delegate
responsibility to component objects.
Polymorphism
• Problem: How to act different depending in object’s class, or
how to design pluggable components?

• In case of class behavior might changes, responsibilities
segregates to different behavior specific classes, using
polymorphic operations for this class.
• Advise: Do not use type checking, but conditional logic for
implementation different variations based on object type.
Polymorphism
Square

Player

landedOn

RegularSquare

landedOn

GoSquare

landedOn

OtherSquare

landedOn

• There are (roughly) 3 types a polymorphism:
– Ad hoc Polymorphism
– Parametric Polymorphism

– Subtype Polymorphism
Pure Fabrication
• Problem: How to assign responsibilities if applying the
Informational Expert principle decreases cohesion and increases
coupling?
• Assign the responsibility to an artificial class that does not
belongs to the domain model.
• Pure Fabrication is a class that does not reflect any business
domain object, but required only for increase cohesion and
decrease coupling.
Indirection
• Problem: How to assign responsibilities in order to avoid direct
coupling between two components, and keep ability for reuse.

• Assign responsibility to intermediate class for providing linking
between objects not linking directly.
• Related design patterns: Adapter, Bridge, Mediator.
Protected Variations
• Problem: How to design system and subsystems, that changes in
these components does not affects on other components.

• Identify points of possible variations and instability; create
stable interfaces upon instable components.
• Open-Closed Principle almost equivalent to PV pattern.
Protected Variations
• There are 2 types of points:
– Variation point – branching point on existing system or in
requirements. For example we need to support several types of
interfaces for tax payment system
– Evolution point – supposed branching point, which might occur in
future, but does not declared by existing requirements.

• Protected variation pattern applying for both variation and
evolution points.
Law of Demeter (not part of GRASP)
Specific case of loose coupling.
• Each unit should have only limited knowledge about other units
• Each unit should only talk to its friend (“don’t talk to strangers”)

A

B

C
Law of Demeter (not part of GRASP)
More formally, the Law of Demeter for functions requires that a
method m of an object O may only invoke the methods of the
following kinds of objects:

• O itself
• m's parameters
• Any objects created/instantiated within m

• O's direct component objects
• A global variable, accessible by O, in the scope of m
“Don’t talk to strangers”
RDD conflicts with Law of Demeter
• Therefore, sending a message to the result of a previous
message send isn't allowed.

However, "returned values are part of the
client/server contract. There need be no
correlation between the structure of an object
and the object returned by the message.“

Wirfs-Brock, Rebecca; McKean, Alan
(November 2002). Object Design:
Roles, Responsibilities, and Collaborations.
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 of
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 to A
when it is crated. Thus B is an Expert with respect 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 an
unstable or predictably variable subsystem or component.
Questions?

Contacts:
Yuriy Shapovalov ( Yurii_Shapovalov@epam.com )
email:
skype:
twitter:

shapovalov.yuri@gmail.com
shapovalov.yuriy
@YuriyShapovalov

More Related Content

What's hot

Publish Subscribe pattern - Design Patterns
Publish Subscribe pattern - Design PatternsPublish Subscribe pattern - Design Patterns
Publish Subscribe pattern - Design Patterns
Rutvik Bapat
 
Object Oriented Design Concept
Object Oriented Design ConceptObject Oriented Design Concept
Object Oriented Design Concept
Sharath g
 
GRASP Principles
GRASP PrinciplesGRASP Principles
GRASP Principles
Raheel Arif
 
Builder pattern
Builder patternBuilder pattern
Builder pattern
Shakil Ahmed
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
Haitham El-Ghareeb
 
Structure chart
Structure chartStructure chart
Structure chart
Roy Antony Arnold G
 
3. ch 2-process model
3. ch 2-process model3. ch 2-process model
3. ch 2-process model
Delowar hossain
 
CS8592-OOAD Lecture Notes Unit-4
CS8592-OOAD Lecture Notes Unit-4CS8592-OOAD Lecture Notes Unit-4
CS8592-OOAD Lecture Notes Unit-4
Gobinath Subramaniam
 
CS8592-OOAD Lecture Notes Unit-2
CS8592-OOAD Lecture Notes Unit-2CS8592-OOAD Lecture Notes Unit-2
CS8592-OOAD Lecture Notes Unit-2
Gobinath Subramaniam
 
UML diagrams and symbols
UML diagrams and symbolsUML diagrams and symbols
UML diagrams and symbols
Kumar
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
Sudarsun Santhiappan
 
Line of Code (LOC) Matric and Function Point Matric
Line of Code (LOC) Matric and Function Point MatricLine of Code (LOC) Matric and Function Point Matric
Line of Code (LOC) Matric and Function Point Matric
Ankush Singh
 
Solid principles
Solid principlesSolid principles
Solid principles
Monica Rodrigues
 
Learning solid principles using c#
Learning solid principles using c#Learning solid principles using c#
Learning solid principles using c#
Aditya Kumar Rajan
 
Cohesion and coupling
Cohesion and couplingCohesion and coupling
Cohesion and coupling
Aprajita (Abbey) Singh
 
Software Development Life Cycle (SDLC)
Software Development Life Cycle (SDLC)Software Development Life Cycle (SDLC)
Software Development Life Cycle (SDLC)
Al-Mamun Sarkar
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principles
rainynovember12
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
University of Technology
 
Software Development Life Cycle (SDLC)
Software Development Life Cycle (SDLC)Software Development Life Cycle (SDLC)
Software Development Life Cycle (SDLC)
Angelin R
 
CS8592 Object Oriented Analysis & Design - UNIT IV
CS8592 Object Oriented Analysis & Design - UNIT IV CS8592 Object Oriented Analysis & Design - UNIT IV
CS8592 Object Oriented Analysis & Design - UNIT IV
pkaviya
 

What's hot (20)

Publish Subscribe pattern - Design Patterns
Publish Subscribe pattern - Design PatternsPublish Subscribe pattern - Design Patterns
Publish Subscribe pattern - Design Patterns
 
Object Oriented Design Concept
Object Oriented Design ConceptObject Oriented Design Concept
Object Oriented Design Concept
 
GRASP Principles
GRASP PrinciplesGRASP Principles
GRASP Principles
 
Builder pattern
Builder patternBuilder pattern
Builder pattern
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
 
Structure chart
Structure chartStructure chart
Structure chart
 
3. ch 2-process model
3. ch 2-process model3. ch 2-process model
3. ch 2-process model
 
CS8592-OOAD Lecture Notes Unit-4
CS8592-OOAD Lecture Notes Unit-4CS8592-OOAD Lecture Notes Unit-4
CS8592-OOAD Lecture Notes Unit-4
 
CS8592-OOAD Lecture Notes Unit-2
CS8592-OOAD Lecture Notes Unit-2CS8592-OOAD Lecture Notes Unit-2
CS8592-OOAD Lecture Notes Unit-2
 
UML diagrams and symbols
UML diagrams and symbolsUML diagrams and symbols
UML diagrams and symbols
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
 
Line of Code (LOC) Matric and Function Point Matric
Line of Code (LOC) Matric and Function Point MatricLine of Code (LOC) Matric and Function Point Matric
Line of Code (LOC) Matric and Function Point Matric
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Learning solid principles using c#
Learning solid principles using c#Learning solid principles using c#
Learning solid principles using c#
 
Cohesion and coupling
Cohesion and couplingCohesion and coupling
Cohesion and coupling
 
Software Development Life Cycle (SDLC)
Software Development Life Cycle (SDLC)Software Development Life Cycle (SDLC)
Software Development Life Cycle (SDLC)
 
Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principles
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
 
Software Development Life Cycle (SDLC)
Software Development Life Cycle (SDLC)Software Development Life Cycle (SDLC)
Software Development Life Cycle (SDLC)
 
CS8592 Object Oriented Analysis & Design - UNIT IV
CS8592 Object Oriented Analysis & Design - UNIT IV CS8592 Object Oriented Analysis & Design - UNIT IV
CS8592 Object Oriented Analysis & Design - UNIT IV
 

Viewers also liked

GRASP Staff Final Presentation
GRASP Staff Final PresentationGRASP Staff Final Presentation
GRASP Staff Final Presentation
Radu Florea
 
Week4 grasp-into
Week4 grasp-intoWeek4 grasp-into
Week4 grasp-into
Alexandru-Gala Popescu
 
L12 GRASP
L12 GRASPL12 GRASP
Assessment in the K12 Classroom
Assessment in the K12 ClassroomAssessment in the K12 Classroom
Assessment in the K12 Classroom
Patricia Dickenson
 
14 grasp-1
14 grasp-114 grasp-1
14 grasp-1
Rahul Jain
 
GRASP PERFORMANCE ASSESSMENT
GRASP PERFORMANCE ASSESSMENTGRASP PERFORMANCE ASSESSMENT
GRASP PERFORMANCE ASSESSMENT
Marvin Broñoso
 
OOA&D Lecture1
OOA&D Lecture1OOA&D Lecture1
OOA&D Lecture1
Muhammad Tahir Mehmood
 
OOA&D Lecture 2 uml notations
OOA&D Lecture 2 uml notations OOA&D Lecture 2 uml notations
OOA&D Lecture 2 uml notations
Muhammad Tahir Mehmood
 
Lecture 4
Lecture 4Lecture 4
Simple k12 performance task assessment
Simple k12 performance task assessmentSimple k12 performance task assessment
Simple k12 performance task assessment
Jonathan Martin
 
Craig Larman - Scaling Lean & Agile Development
Craig Larman - Scaling Lean & Agile Development Craig Larman - Scaling Lean & Agile Development
Craig Larman - Scaling Lean & Agile Development
Valtech
 
SOLID & GRASP
SOLID & GRASPSOLID & GRASP
SOLID & GRASPdevel123
 
Standards based assessment and grading in the k-12 system
Standards based assessment and grading in the k-12 systemStandards based assessment and grading in the k-12 system
Standards based assessment and grading in the k-12 system
Feljone Ragma
 
Domain object model
Domain object modelDomain object model
Domain object model
university of education,Lahore
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
bmcfad01
 
Chapter 07
Chapter 07Chapter 07
Chapter 07
bmcfad01
 
probability and statistics Chapter 1 (1)
probability and statistics Chapter 1 (1)probability and statistics Chapter 1 (1)
probability and statistics Chapter 1 (1)
abfisho
 
Real World & Performance Assessment
Real World & Performance AssessmentReal World & Performance Assessment
Real World & Performance Assessment
guestd0c8f7
 
Performance assessment using grasps
Performance assessment  using graspsPerformance assessment  using grasps
Performance assessment using grasps
Shyne De Vera
 
Grasp task - 3
Grasp task - 3Grasp task - 3
Grasp task - 3
Jerry Lomigo-Almilla
 

Viewers also liked (20)

GRASP Staff Final Presentation
GRASP Staff Final PresentationGRASP Staff Final Presentation
GRASP Staff Final Presentation
 
Week4 grasp-into
Week4 grasp-intoWeek4 grasp-into
Week4 grasp-into
 
L12 GRASP
L12 GRASPL12 GRASP
L12 GRASP
 
Assessment in the K12 Classroom
Assessment in the K12 ClassroomAssessment in the K12 Classroom
Assessment in the K12 Classroom
 
14 grasp-1
14 grasp-114 grasp-1
14 grasp-1
 
GRASP PERFORMANCE ASSESSMENT
GRASP PERFORMANCE ASSESSMENTGRASP PERFORMANCE ASSESSMENT
GRASP PERFORMANCE ASSESSMENT
 
OOA&D Lecture1
OOA&D Lecture1OOA&D Lecture1
OOA&D Lecture1
 
OOA&D Lecture 2 uml notations
OOA&D Lecture 2 uml notations OOA&D Lecture 2 uml notations
OOA&D Lecture 2 uml notations
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Simple k12 performance task assessment
Simple k12 performance task assessmentSimple k12 performance task assessment
Simple k12 performance task assessment
 
Craig Larman - Scaling Lean & Agile Development
Craig Larman - Scaling Lean & Agile Development Craig Larman - Scaling Lean & Agile Development
Craig Larman - Scaling Lean & Agile Development
 
SOLID & GRASP
SOLID & GRASPSOLID & GRASP
SOLID & GRASP
 
Standards based assessment and grading in the k-12 system
Standards based assessment and grading in the k-12 systemStandards based assessment and grading in the k-12 system
Standards based assessment and grading in the k-12 system
 
Domain object model
Domain object modelDomain object model
Domain object model
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
 
Chapter 07
Chapter 07Chapter 07
Chapter 07
 
probability and statistics Chapter 1 (1)
probability and statistics Chapter 1 (1)probability and statistics Chapter 1 (1)
probability and statistics Chapter 1 (1)
 
Real World & Performance Assessment
Real World & Performance AssessmentReal World & Performance Assessment
Real World & Performance Assessment
 
Performance assessment using grasps
Performance assessment  using graspsPerformance assessment  using grasps
Performance assessment using grasps
 
Grasp task - 3
Grasp task - 3Grasp task - 3
Grasp task - 3
 

Similar to Grasp principles

UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
anguraju1
 
Effective Software Design
Effective Software Design Effective Software Design
Effective Software Design
Darshan Ashpal
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
stanbridge
 
Design pattern and their application
Design pattern and their applicationDesign pattern and their application
Design pattern and their application
Hiệp Tiến
 
Software Design principales
Software Design principalesSoftware Design principales
Software Design principales
ABDEL RAHMAN KARIM
 
Design engineering cohesion by dinesh
Design engineering cohesion by dineshDesign engineering cohesion by dinesh
Design engineering cohesion by dinesh
Dinesh Kumar
 
12266422.ppt
12266422.ppt12266422.ppt
12266422.ppt
CSEC5
 
Nina Grantcharova - Approach to Separation of Concerns via Design Patterns
Nina Grantcharova - Approach to Separation of Concerns via Design PatternsNina Grantcharova - Approach to Separation of Concerns via Design Patterns
Nina Grantcharova - Approach to Separation of Concerns via Design Patterns
iasaglobal
 
TEST PPT
TEST PPTTEST PPT
TEST PPT
berryzed
 
Patterns
PatternsPatterns
Patterns
Amith Tiwari
 
session on pattern oriented software architecture
session on pattern oriented software architecturesession on pattern oriented software architecture
session on pattern oriented software architecture
SUJOY SETT
 
Entity Framework: To the Unit of Work Design Pattern and Beyond
Entity Framework: To the Unit of Work Design Pattern and BeyondEntity Framework: To the Unit of Work Design Pattern and Beyond
Entity Framework: To the Unit of Work Design Pattern and Beyond
Steve Westgarth
 
Microservice architecture design principles
Microservice architecture design principlesMicroservice architecture design principles
Microservice architecture design principles
Sanjoy Kumar Roy
 
OOM Unit I - III.pdf
OOM Unit I - III.pdfOOM Unit I - III.pdf
OOM Unit I - III.pdf
ShaikRafikhan1
 
effective modular design.pptx
effective modular design.pptxeffective modular design.pptx
effective modular design.pptx
Dr.Shweta
 
Unit3 Software engineering UPTU
Unit3 Software engineering UPTUUnit3 Software engineering UPTU
Unit3 Software engineering UPTU
Mohammad Faizan
 
EFFECTIVE MODULAR DESIGN.pptx
EFFECTIVE MODULAR DESIGN.pptxEFFECTIVE MODULAR DESIGN.pptx
EFFECTIVE MODULAR DESIGN.pptx
DrTThendralCompSci
 
Tech challenges in a large scale agile project
Tech challenges in a large scale agile projectTech challenges in a large scale agile project
Tech challenges in a large scale agile project
Harald Soevik
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_ppt
agnes_crepet
 
Clean Code .Net Cheetsheets
Clean Code .Net CheetsheetsClean Code .Net Cheetsheets
Clean Code .Net Cheetsheets
NikitaGoncharuk1
 

Similar to Grasp principles (20)

UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
 
Effective Software Design
Effective Software Design Effective Software Design
Effective Software Design
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
 
Design pattern and their application
Design pattern and their applicationDesign pattern and their application
Design pattern and their application
 
Software Design principales
Software Design principalesSoftware Design principales
Software Design principales
 
Design engineering cohesion by dinesh
Design engineering cohesion by dineshDesign engineering cohesion by dinesh
Design engineering cohesion by dinesh
 
12266422.ppt
12266422.ppt12266422.ppt
12266422.ppt
 
Nina Grantcharova - Approach to Separation of Concerns via Design Patterns
Nina Grantcharova - Approach to Separation of Concerns via Design PatternsNina Grantcharova - Approach to Separation of Concerns via Design Patterns
Nina Grantcharova - Approach to Separation of Concerns via Design Patterns
 
TEST PPT
TEST PPTTEST PPT
TEST PPT
 
Patterns
PatternsPatterns
Patterns
 
session on pattern oriented software architecture
session on pattern oriented software architecturesession on pattern oriented software architecture
session on pattern oriented software architecture
 
Entity Framework: To the Unit of Work Design Pattern and Beyond
Entity Framework: To the Unit of Work Design Pattern and BeyondEntity Framework: To the Unit of Work Design Pattern and Beyond
Entity Framework: To the Unit of Work Design Pattern and Beyond
 
Microservice architecture design principles
Microservice architecture design principlesMicroservice architecture design principles
Microservice architecture design principles
 
OOM Unit I - III.pdf
OOM Unit I - III.pdfOOM Unit I - III.pdf
OOM Unit I - III.pdf
 
effective modular design.pptx
effective modular design.pptxeffective modular design.pptx
effective modular design.pptx
 
Unit3 Software engineering UPTU
Unit3 Software engineering UPTUUnit3 Software engineering UPTU
Unit3 Software engineering UPTU
 
EFFECTIVE MODULAR DESIGN.pptx
EFFECTIVE MODULAR DESIGN.pptxEFFECTIVE MODULAR DESIGN.pptx
EFFECTIVE MODULAR DESIGN.pptx
 
Tech challenges in a large scale agile project
Tech challenges in a large scale agile projectTech challenges in a large scale agile project
Tech challenges in a large scale agile project
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_ppt
 
Clean Code .Net Cheetsheets
Clean Code .Net CheetsheetsClean Code .Net Cheetsheets
Clean Code .Net Cheetsheets
 

Recently uploaded

Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
christinelarrosa
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
ScyllaDB
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
LizaNolte
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
Mydbops
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 

Recently uploaded (20)

Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 

Grasp principles

  • 1. GRASP General Responsibility Assignment Software Patterns author: Yuriy Shapovalov (Yurii_Shapovalov@epam.com)
  • 2. Where it came from? • GRASP like a term and principles firstly was described at Craig Larman’s book “Applying UML and Patterns” GRASP stands for: • General • Responsibility • Assignment • Software • Patterns (Principles)
  • 3. Nine Patterns • Creator • Informational Expert • Controller • Low Coupling • High Cohesion • Polymorphism • Pure Fabrication • Indirection • Protected Variation
  • 4. Differences from GoF and SOLID • Patterns of assigning responsibilities (RDD) • GRASP declares more common principles responsibility separation, when GoF describe more specific and complex design patterns. • SOLID – more common OOP principles less oriented on responsibility segregation • GRASP somewhere between GoF patterns and SOLID principles.
  • 5. Representation in Sequence Diagram (UML) • Relationship between methods and responsibilities. • Assuming that Sale objects are responsible to create Payment objects :Sale makePayment(cashTendered) create(cashTendered) Confidential :Payment 5
  • 6. Responsibility-Driven Design • “doing” responsibilities – Doing something itself, such as creation an object or doing a calculation. – Initiating action in other objects – Controlling and coordinating activities in other objects. • “knowing” responsibilities – Knowing about encapsulated data. – Knowing about related objects. – Knowing about things it can derive or calculate.
  • 7. Informational Expert Problem: Which class possesses information about object A? More common question: What is a general principle of assigning responsibilities to objects? Assign the responsibility to the class that knows the necessary information for performing required action and fulfill the responsibility.
  • 8. Informational Expert Tell, Don’t Ask. “Procedural code gets information then, makes decisions. Objectoriented code tells object to do things” © Alec Sharp
  • 11. Creator Problem: Who should be responsible for creating object A? In general, a class B should be responsible for creating instances of class A if one, or preferably more, of the following apply: • Instances of B contain or compositely aggregate instances of A • Instances of B record instances of A • Instances of B closely use instances of A • Instances of B have the initializing information for instances of A and pass it on creation.
  • 12. Creator • The goal is to define creator-object, which will be related to all created objects. 64 Board create Square Board create Square
  • 13. Creator In case of complex creation login, based on some external cases, make sense to use Factory pattern, and delegate creation responsibility to auxiliary class. • Related patterns: Concrete Factory and Abstract Factory
  • 14. Low Coupling • Problem: How to reduce design change impact, support low dependency and increase reuse? Coupling is the degree, defines how tightly one component linked to other components, or how much information it knows about other components. • A change in one module usually forces a ripple effect of changes in other modules. • Assembly of modules might require more effort and/or time due to the increased inter-module dependency. • A particular module might be harder to reuse and/or test because dependent modules must be included.
  • 16. Low Coupling • Assign a responsibility so that coupling remains low. Low Coupling is an evaluative pattern, which 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. http://en.wikipedia.org/wiki/Coupling_(computer_science)#Module_coupling
  • 17. High Cohesion • Problem: How to keep objects focused, understandable, manageable, and support low coupling? Cohesion is a measure of how strongly related or focused the responsibilities of a single module are. High Cohesion is an evaluative pattern that attempts to keep objects appropriately focused, manageable and understandable. Alternatively, low cohesion is a situation in which a given element has too many unrelated responsibilities (“God Object”)
  • 18. High Cohesion Cohesion is decreased if: • The functionalities embedded in a class, accessed through its methods, have little in common. • Methods carry out many varied activities, often using coarsely grained or unrelated sets of data. Disadvantages of low cohesion (or “weak cohesion”) are: • Increased difficulty in understanding modules. • Increased difficulty in maintaining a system, because logical changes in the domain affect multiple modules, and because changes in one module require changes in related modules. • Increased difficulty in reusing a module because most applications won’t need the random set of operations provided by a module.
  • 20. Controller • Problem: Who should be responsible for handling events and messages from external actors (UI, …)? • Assign the responsibility to a class, such as: – A class that represents the overall system, device, or subsystem. • Façade Controller Pattern – A class that represent a use case, whereby performs handling particular system operation. • Use Case Controller Pattern • Generally does not perform operation by itself, but delegate responsibility to component objects.
  • 21. Polymorphism • Problem: How to act different depending in object’s class, or how to design pluggable components? • In case of class behavior might changes, responsibilities segregates to different behavior specific classes, using polymorphic operations for this class. • Advise: Do not use type checking, but conditional logic for implementation different variations based on object type.
  • 22. Polymorphism Square Player landedOn RegularSquare landedOn GoSquare landedOn OtherSquare landedOn • There are (roughly) 3 types a polymorphism: – Ad hoc Polymorphism – Parametric Polymorphism – Subtype Polymorphism
  • 23. Pure Fabrication • Problem: How to assign responsibilities if applying the Informational Expert principle decreases cohesion and increases coupling? • Assign the responsibility to an artificial class that does not belongs to the domain model. • Pure Fabrication is a class that does not reflect any business domain object, but required only for increase cohesion and decrease coupling.
  • 24. Indirection • Problem: How to assign responsibilities in order to avoid direct coupling between two components, and keep ability for reuse. • Assign responsibility to intermediate class for providing linking between objects not linking directly. • Related design patterns: Adapter, Bridge, Mediator.
  • 25. Protected Variations • Problem: How to design system and subsystems, that changes in these components does not affects on other components. • Identify points of possible variations and instability; create stable interfaces upon instable components. • Open-Closed Principle almost equivalent to PV pattern.
  • 26. Protected Variations • There are 2 types of points: – Variation point – branching point on existing system or in requirements. For example we need to support several types of interfaces for tax payment system – Evolution point – supposed branching point, which might occur in future, but does not declared by existing requirements. • Protected variation pattern applying for both variation and evolution points.
  • 27. Law of Demeter (not part of GRASP) Specific case of loose coupling. • Each unit should have only limited knowledge about other units • Each unit should only talk to its friend (“don’t talk to strangers”) A B C
  • 28. Law of Demeter (not part of GRASP) More formally, the Law of Demeter for functions requires that a method m of an object O may only invoke the methods of the following kinds of objects: • O itself • m's parameters • Any objects created/instantiated within m • O's direct component objects • A global variable, accessible by O, in the scope of m “Don’t talk to strangers”
  • 29. RDD conflicts with Law of Demeter • Therefore, sending a message to the result of a previous message send isn't allowed. However, "returned values are part of the client/server contract. There need be no correlation between the structure of an object and the object returned by the message.“ Wirfs-Brock, Rebecca; McKean, Alan (November 2002). Object Design: Roles, Responsibilities, and Collaborations.
  • 30. 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 of 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 to A when it is crated. Thus B is an Expert with respect 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.
  • 31. 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 an unstable or predictably variable subsystem or component.
  • 32. Questions? Contacts: Yuriy Shapovalov ( Yurii_Shapovalov@epam.com ) email: skype: twitter: shapovalov.yuri@gmail.com shapovalov.yuriy @YuriyShapovalov