SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Submitted To: 
Submitted by: 
Fizza Durrani 
11073 
7th Semester UET(A) 
October 15, 2014 
Lahore Garrison University 1
“The critical design tool for software 
development is a mind well educated in 
design principles. It is not the UML or any 
other technology.“ 
Craig Larman 
Thus, GRASP is really a mental toolset, a learning 
aid to help in the design of object-oriented 
software. 
Lahore Garrison University 2
It stands for: 
ď‚ž General 
ď‚ž Responsibilities 
ď‚ž Assignment 
ď‚ž Software 
ď‚ž Patterns (Principles) 
Lahore Garrison University 3
Responsibility 
ď‚žA contract / obligation that a class / module / 
component must accomplish 
 Knowledge 
 Private state 
 Computed state 
ď‚ž 
ď‚ž 
 Behavior 
 Send messages itself and modify its private 
state 
 Instantiate another objects 
 Send messages to another objects 
Lahore Garrison University 4
 “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. 
Lahore Garrison University 5
Lahore Garrison University 6
 Informational Expert 
 Creator 
 Low Coupling 
 High Cohesion 
 Controller 
 Polymorphism 
 Pure Fabrication 
 Indirection 
 Controlled Variation 
Lahore Garrison University 7
Lahore Garrison University 8
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. 
Lahore Garrison University 9
A B C D 
DO 
GetDataX() 
GetDataY() 
GetDataZ() 
return Z 
return Y 
return X 
Lahore Garrison University 10
A B C D 
DO 
DoAction() 
DoAction(X) 
DoAction(Y) 
Lahore Garrison University 11
Lahore Garrison University 12
Problem: Who should be responsible for creating 
object 
A? 
ď‚ž Class B must have that responsibility if: 
 B is composed by A (composition) 
 B knows the necessary information in order to 
instantiate A objects 
 B depends heavily on A 
Lahore Garrison University 13
• The goal is to define creator-object, which will be 
related to all created objects. 
64 
Board Square 
Square 
Board 
create 
create 
Lahore Garrison University 14
Lahore Garrison University 15
Problem: How to minimize dependencies between 
classes ? 
Coupling is the degree, defines how tightly one 
component linked to other components, or how 
much 
information it knows about other components. 
Examples 
 Inheritance 
 Composition / aggregation / association 
 A send messages to B 
Lahore Garrison University 16
ď‚ž 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. 
Lahore Garrison University 17
Lahore Garrison University 18
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. 
Lahore Garrison University 19
ď‚ž Alternatively, low cohesion is a situation in 
which a given element has too many unrelated 
responsibilities (“God Object”) 
ď‚žLow Cohesion implies: 
 Hard to reuse 
 Hard to maintain 
 Constantly changing 
Lahore Garrison University 20
A A ?? ?? 
DoA() 
DoB() 
DoC() 
DoA() 
DoB() 
DoC() 
Lahore Garrison University 21
Lahore Garrison University 22
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. 
Lahore Garrison University 23
Lahore Garrison University 24
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. 
Lahore Garrison University 25
Player 
ď‚ž There are (roughly) 3 types a polymorphism: 
 Ad hoc Polymorphism 
 Parametric Polymorphism 
 Subtype Polymorphism 
Square 
landedOn 
RegularSquare 
landedOn 
GoSquare 
landedOn 
OtherSquare 
landedOn 
Lahore Garrison University 26
Lahore Garrison University 27
ď‚ž 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. 
Lahore Garrison University 28
Lahore Garrison University 29
ď‚ž 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. 
Lahore Garrison University 30
Lahore Garrison University 31
ď‚ž 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 CV 
pattern. 
Lahore Garrison University 32
ď‚ž 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. 
Lahore Garrison University 33
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 Lahore GarArissons Uingivners iaty responsibility so that coh3e4 sion remains high.
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. 
Lahore Garrison University 35
ď‚ž http://en.wikipedia.org/wiki/GRASP_%28object-oriented_ 
design%29 
ď‚ž http://www.slideshare.net/snmgian/grasp-principles 
ď‚ž http://www.slideshare.net/eduardo_diederichsen/d 
esign-talk-grasp-patterns?related=1 
ď‚ž http://www.slideshare.net/eduardo_diederichsen/d 
esign-talk-grasp-patterns?related=1 
Lahore Garrison University 36
Any Question 
Lahore Garrison University 37
Lahore Garrison University 38

Weitere ähnliche Inhalte

Was ist angesagt?

Object and class relationships
Object and class relationshipsObject and class relationships
Object and class relationships
Pooja mittal
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
Aman Jain
 
Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
Srikanth R Vaka
 

Was ist angesagt? (20)

Uml
UmlUml
Uml
 
Grasp patterns and its types
Grasp patterns and its typesGrasp patterns and its types
Grasp patterns and its types
 
Major and Minor Elements of Object Model
Major and Minor Elements of Object ModelMajor and Minor Elements of Object Model
Major and Minor Elements of Object Model
 
CS8592-OOAD Lecture Notes Unit-2
CS8592-OOAD Lecture Notes Unit-2CS8592-OOAD Lecture Notes Unit-2
CS8592-OOAD Lecture Notes Unit-2
 
Component Diagram
Component DiagramComponent Diagram
Component Diagram
 
Object and class relationships
Object and class relationshipsObject and class relationships
Object and class relationships
 
Introduction to UML
Introduction to UMLIntroduction to UML
Introduction to UML
 
Sequence diagram- UML diagram
Sequence diagram- UML diagramSequence diagram- UML diagram
Sequence diagram- UML diagram
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
 
Uml class Diagram
Uml class DiagramUml class Diagram
Uml class Diagram
 
UML
UMLUML
UML
 
UML Diagrams
UML DiagramsUML Diagrams
UML Diagrams
 
Software design
Software designSoftware design
Software design
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Ooad ppt
Ooad pptOoad ppt
Ooad ppt
 
Presentation on uml
Presentation on umlPresentation on uml
Presentation on uml
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design pattern
 
Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
 
Unit 1( modelling concepts & class modeling)
Unit  1( modelling concepts & class modeling)Unit  1( modelling concepts & class modeling)
Unit 1( modelling concepts & class modeling)
 
Class diagram
Class diagramClass diagram
Class diagram
 

Andere mochten auch

14 grasp-1
14 grasp-114 grasp-1
14 grasp-1
Rahul Jain
 
Whitney Backwards Assessment April 2008
Whitney Backwards Assessment April 2008Whitney Backwards Assessment April 2008
Whitney Backwards Assessment April 2008
Swadeo
 
The LEARN and Backwards Design Model
The LEARN and Backwards Design ModelThe LEARN and Backwards Design Model
The LEARN and Backwards Design Model
Angelica Guevara Bernal
 

Andere mochten auch (20)

GRASP Principles
GRASP PrinciplesGRASP Principles
GRASP Principles
 
GRASP Principles
GRASP PrinciplesGRASP Principles
GRASP Principles
 
Grasp principles
Grasp principlesGrasp principles
Grasp principles
 
09 grasp
09 grasp09 grasp
09 grasp
 
14 grasp-1
14 grasp-114 grasp-1
14 grasp-1
 
BIS 08a - Application Development - II Version 2
BIS 08a - Application Development - II Version 2BIS 08a - Application Development - II Version 2
BIS 08a - Application Development - II Version 2
 
Chapter03
Chapter03Chapter03
Chapter03
 
Chapter04
Chapter04Chapter04
Chapter04
 
8. operation contracts
8. operation contracts8. operation contracts
8. operation contracts
 
OOA&D Lecture1
OOA&D Lecture1OOA&D Lecture1
OOA&D Lecture1
 
Refactoring to SOLID Code
Refactoring to SOLID CodeRefactoring to SOLID Code
Refactoring to SOLID Code
 
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
 
Silva assessment
Silva assessmentSilva assessment
Silva assessment
 
Performance based project jessica allen 2
Performance based project jessica allen 2Performance based project jessica allen 2
Performance based project jessica allen 2
 
Whitney Backwards Assessment April 2008
Whitney Backwards Assessment April 2008Whitney Backwards Assessment April 2008
Whitney Backwards Assessment April 2008
 
Chapter02
Chapter02Chapter02
Chapter02
 
The six facets of understanding
The six facets of understandingThe six facets of understanding
The six facets of understanding
 
Craig Larman - Scaling Lean & Agile Development
Craig Larman - Scaling Lean & Agile Development Craig Larman - Scaling Lean & Agile Development
Craig Larman - Scaling Lean & Agile Development
 
The LEARN and Backwards Design Model
The LEARN and Backwards Design ModelThe LEARN and Backwards Design Model
The LEARN and Backwards Design Model
 

Ă„hnlich wie Grasp

Object oriented software engineering
Object oriented software engineeringObject oriented software engineering
Object oriented software engineering
Varsha Ajith
 
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
 
An Empirical Study on How Developers Reason about Module Cohesion
An Empirical Study on How Developers Reason about Module CohesionAn Empirical Study on How Developers Reason about Module Cohesion
An Empirical Study on How Developers Reason about Module Cohesion
Bruno C. da Silva
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
Aravinth NSP
 
CSE333 project initial spec: Learning agents
CSE333 project initial spec: Learning agentsCSE333 project initial spec: Learning agents
CSE333 project initial spec: Learning agents
butest
 
CSE333 project initial spec: Learning agents
CSE333 project initial spec: Learning agentsCSE333 project initial spec: Learning agents
CSE333 project initial spec: Learning agents
butest
 
Ooad 2marks
Ooad 2marksOoad 2marks
Ooad 2marks
Ash Wini
 
Patterns of Assigning Responsibilities
Patterns of Assigning ResponsibilitiesPatterns of Assigning Responsibilities
Patterns of Assigning Responsibilities
guest2a92cd9
 
M03 1 Structuraldiagrams
M03 1 StructuraldiagramsM03 1 Structuraldiagrams
M03 1 Structuraldiagrams
Dang Tuan
 

Ă„hnlich wie Grasp (20)

Introduction to UML
Introduction to UMLIntroduction to UML
Introduction to UML
 
Object oriented software engineering
Object oriented software engineeringObject oriented software engineering
Object oriented software engineering
 
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
 
SE18_Lec 06_Object Oriented Analysis and Design
SE18_Lec 06_Object Oriented Analysis and DesignSE18_Lec 06_Object Oriented Analysis and Design
SE18_Lec 06_Object Oriented Analysis and Design
 
Mvc grasp
Mvc graspMvc grasp
Mvc grasp
 
SE_Lec 06_Object Oriented Analysis and Design
SE_Lec 06_Object Oriented Analysis and DesignSE_Lec 06_Object Oriented Analysis and Design
SE_Lec 06_Object Oriented Analysis and Design
 
Object Interconnections
Object InterconnectionsObject Interconnections
Object Interconnections
 
An Empirical Study on How Developers Reason about Module Cohesion
An Empirical Study on How Developers Reason about Module CohesionAn Empirical Study on How Developers Reason about Module Cohesion
An Empirical Study on How Developers Reason about Module Cohesion
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
 
M03_1_Structur alDiagrams.ppt
M03_1_Structur                         alDiagrams.pptM03_1_Structur                         alDiagrams.ppt
M03_1_Structur alDiagrams.ppt
 
CSE333 project initial spec: Learning agents
CSE333 project initial spec: Learning agentsCSE333 project initial spec: Learning agents
CSE333 project initial spec: Learning agents
 
CSE333 project initial spec: Learning agents
CSE333 project initial spec: Learning agentsCSE333 project initial spec: Learning agents
CSE333 project initial spec: Learning agents
 
Framing the Problem
Framing the ProblemFraming the Problem
Framing the Problem
 
Ooad 2marks
Ooad 2marksOoad 2marks
Ooad 2marks
 
TEST PPT
TEST PPTTEST PPT
TEST PPT
 
CS8592-OOAD-UNIT II-STATIC UML DIAGRAMS PPT
CS8592-OOAD-UNIT II-STATIC UML DIAGRAMS PPTCS8592-OOAD-UNIT II-STATIC UML DIAGRAMS PPT
CS8592-OOAD-UNIT II-STATIC UML DIAGRAMS PPT
 
Patterns of Assigning Responsibilities
Patterns of Assigning ResponsibilitiesPatterns of Assigning Responsibilities
Patterns of Assigning Responsibilities
 
CS8592-OOAD Lecture Notes Unit-4
CS8592-OOAD Lecture Notes Unit-4CS8592-OOAD Lecture Notes Unit-4
CS8592-OOAD Lecture Notes Unit-4
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
 
M03 1 Structuraldiagrams
M03 1 StructuraldiagramsM03 1 Structuraldiagrams
M03 1 Structuraldiagrams
 

KĂĽrzlich hochgeladen

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

KĂĽrzlich hochgeladen (20)

%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 

Grasp

  • 1. Submitted To: Submitted by: Fizza Durrani 11073 7th Semester UET(A) October 15, 2014 Lahore Garrison University 1
  • 2. “The critical design tool for software development is a mind well educated in design principles. It is not the UML or any other technology.“ Craig Larman Thus, GRASP is really a mental toolset, a learning aid to help in the design of object-oriented software. Lahore Garrison University 2
  • 3. It stands for: ď‚ž General ď‚ž Responsibilities ď‚ž Assignment ď‚ž Software ď‚ž Patterns (Principles) Lahore Garrison University 3
  • 4. Responsibility ď‚žA contract / obligation that a class / module / component must accomplish  Knowledge  Private state  Computed state ď‚ž ď‚ž  Behavior  Send messages itself and modify its private state  Instantiate another objects  Send messages to another objects Lahore Garrison University 4
  • 5. ď‚ž “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. Lahore Garrison University 5
  • 7.  Informational Expert  Creator  Low Coupling  High Cohesion  Controller  Polymorphism  Pure Fabrication  Indirection  Controlled Variation Lahore Garrison University 7
  • 9. 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. Lahore Garrison University 9
  • 10. A B C D DO GetDataX() GetDataY() GetDataZ() return Z return Y return X Lahore Garrison University 10
  • 11. A B C D DO DoAction() DoAction(X) DoAction(Y) Lahore Garrison University 11
  • 13. Problem: Who should be responsible for creating object A? ď‚ž Class B must have that responsibility if:  B is composed by A (composition)  B knows the necessary information in order to instantiate A objects  B depends heavily on A Lahore Garrison University 13
  • 14. • The goal is to define creator-object, which will be related to all created objects. 64 Board Square Square Board create create Lahore Garrison University 14
  • 16. Problem: How to minimize dependencies between classes ? Coupling is the degree, defines how tightly one component linked to other components, or how much information it knows about other components. Examples  Inheritance  Composition / aggregation / association  A send messages to B Lahore Garrison University 16
  • 17. ď‚ž 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. Lahore Garrison University 17
  • 19. 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. Lahore Garrison University 19
  • 20. ď‚ž Alternatively, low cohesion is a situation in which a given element has too many unrelated responsibilities (“God Object”) ď‚žLow Cohesion implies:  Hard to reuse  Hard to maintain  Constantly changing Lahore Garrison University 20
  • 21. A A ?? ?? DoA() DoB() DoC() DoA() DoB() DoC() Lahore Garrison University 21
  • 23. 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. Lahore Garrison University 23
  • 25. 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. Lahore Garrison University 25
  • 26. Player ď‚ž There are (roughly) 3 types a polymorphism:  Ad hoc Polymorphism  Parametric Polymorphism  Subtype Polymorphism Square landedOn RegularSquare landedOn GoSquare landedOn OtherSquare landedOn Lahore Garrison University 26
  • 28. ď‚ž 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. Lahore Garrison University 28
  • 30. ď‚ž 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. Lahore Garrison University 30
  • 32. ď‚ž 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 CV pattern. Lahore Garrison University 32
  • 33. ď‚ž 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. Lahore Garrison University 33
  • 34. 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 Lahore GarArissons Uingivners iaty responsibility so that coh3e4 sion remains high.
  • 35. 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. Lahore Garrison University 35
  • 36. ď‚ž http://en.wikipedia.org/wiki/GRASP_%28object-oriented_ design%29 ď‚ž http://www.slideshare.net/snmgian/grasp-principles ď‚ž http://www.slideshare.net/eduardo_diederichsen/d esign-talk-grasp-patterns?related=1 ď‚ž http://www.slideshare.net/eduardo_diederichsen/d esign-talk-grasp-patterns?related=1 Lahore Garrison University 36
  • 37. Any Question Lahore Garrison University 37