SlideShare a Scribd company logo
1 of 37
Download to read offline
Neversettle
intive.com
_GRASP
Karol Kreft
PHPers Summit 2019
06.09.2019, Poznań
Neversettle
intive.com
2
Neversettle
intive.com
3
Neversettle
intive.com
4
Neversettle
intive.com
• www.craiglarman.com
• UML, OOP, Analysis & Design
• GRASP
• Agile and LeSS
5
Craig Larman
Neversettle
intive.com
6
The GRASP name was
chosen to suggest the
importance of grasping
these principles to
successfully design
object-oriented software.
Neversettle
intive.com
7
General
Responsibility
Assignment
Software
Patterns
Neversettle
intive.com
8
Responsibilities
Neversettle
intive.com
• do something
• know something{
Responsibilities
Neversettle
intive.com
10
Neversettle
intive.com
11
Neversettle
intive.com
GRASP
1. Information Expert
2. Creator
3. Controller
4. Low coupling
5. High cohesion
6. Indirection
7. Polymorphism
8. Pure Fabrication
9. Protected Variations
Neversettle
intive.com
Information Expert
_Assign a responsibility to the information expert
– the class that has the information necessary to
fulfill the responsibility.
Neversettle
intive.com
Information Expert
_Place responsibilities with data
_That which knows, does
_Do it Myself
_Put Services with the Attributes They Work On
Neversettle
intive.com
15
Neversettle
intive.com
16
Neversettle
intive.com
Creator
_Who should be responsible for creating a new
instance of some class?
_Choose class B when
_B aggregates A objects
_B contains A objects
_B closely uses A objects
_B as the initializing data that are required to creatingA
Neversettle
intive.com
18
Neversettle
intive.com
Neversettle
intive.com
Controller
_Who should be responsible for handling
system event?
Neversettle
intive.com
21
Neversettle
intive.com
Bloated Controller
_Controllers which handle too many system
events leading to low cohesion. This can be
avoided by addition of a few more controllers.
_Always remember about delegating
responsibilities to other objects.
_Use Command Pattern in a message-handling
systems.
Neversettle
intive.com
Low coupling
High cohesion
Neversettle
intive.com
Low Coupling
_How to support low dependency
and increased reuse?
High Cohesion
_How to keep complexity manageable?
Neversettle
intive.com
Low Coupling
_Assign responsibilities so that coupling
remains low.
High Cohesion
_Assign responsibilities so that cohesion
remains high.
Neversettle
intive.com
High Coupling
_Changes in related classes force local changes
_Harder to understand in isolation
_Harder to reuse because its use requires the
additional presence of the classes it
dependent upon
_Coupling may not be important if reuse
is not a goal.
Neversettle
intive.com
Low Cohesion
_Hard to comprehend
_Hard to reuse
_Hard to maintain
_Delicate; constantly effected by change
Neversettle
intive.com
_Low Coupling and High Cohesion are principles
to keep in mind during all design decisions.
_They are evaluative patterns which a designer
applies while evaluating all design decisions.
Neversettle
intive.com
29
Neversettle
intive.com
30
_Where to assign a responsibility to avoid
direct coupling between two or more
things?
Neversettle
intive.com
31
_Where to assign a responsibility to avoid
direct coupling between two or more
things?
_Assign the responsibility to an
intermediate object to mediate
between other components or
services to avoid direct coupling.
Neversettle
intive.com
32
Neversettle
intive.com
GRASP
1. Information Expert
2. Creator
3. Controller
4. Low coupling
5. High cohesion
6. Indirection
7. Polymorphism
8. Pure Fabrication
9. Protected Variations
Neversettle
intive.com
34
Do we need
object oriented design?
Neversettle
intive.com
35
Neversettle
intive.com
36
http://bit.ly/grasp-talk
@karol_kreft
Neversettle
intive.com
37
• Photo by La-Rel Easter on Unsplash
• Photo by Feliphe Schiarolli on Unsplash
• Photo by Andrej Lišakov on Unsplash
• Photo by Rohit Choudhari on Unsplash
• Photo by Javier Allegue Barros on Unsplash
Photos

More Related Content

Similar to GRASP - one more way to reach clean code

Mainframes agile2012
Mainframes agile2012Mainframes agile2012
Mainframes agile2012
drewz lin
 
Site-Reliability-Engineering-v2[6241].pdf
Site-Reliability-Engineering-v2[6241].pdfSite-Reliability-Engineering-v2[6241].pdf
Site-Reliability-Engineering-v2[6241].pdf
DeepakGupta747774
 

Similar to GRASP - one more way to reach clean code (20)

Digests for the book "Scalability Rules: 50 Principles for Scaling Web Sites"
Digests for the book "Scalability Rules: 50 Principles for Scaling Web Sites"Digests for the book "Scalability Rules: 50 Principles for Scaling Web Sites"
Digests for the book "Scalability Rules: 50 Principles for Scaling Web Sites"
 
Software design principles for evolving architectures
Software design principles for evolving architecturesSoftware design principles for evolving architectures
Software design principles for evolving architectures
 
Intro to Cloud Native _ v1.0en (2021/01)
Intro to Cloud Native _ v1.0en (2021/01)Intro to Cloud Native _ v1.0en (2021/01)
Intro to Cloud Native _ v1.0en (2021/01)
 
Approaches for Distributed Agile
Approaches for Distributed AgileApproaches for Distributed Agile
Approaches for Distributed Agile
 
Structured Software Design
Structured Software DesignStructured Software Design
Structured Software Design
 
Maintaining Large Scale Julia Ecosystems
Maintaining Large Scale Julia EcosystemsMaintaining Large Scale Julia Ecosystems
Maintaining Large Scale Julia Ecosystems
 
Architecting Solutions and Systems – Randy’s Secrets to Success
Architecting Solutions and Systems – Randy’s Secrets to SuccessArchitecting Solutions and Systems – Randy’s Secrets to Success
Architecting Solutions and Systems – Randy’s Secrets to Success
 
DOIS22 Why you need Cloud-agnostic practices to fuel your DevSecOps adoption ...
DOIS22 Why you need Cloud-agnostic practices to fuel your DevSecOps adoption ...DOIS22 Why you need Cloud-agnostic practices to fuel your DevSecOps adoption ...
DOIS22 Why you need Cloud-agnostic practices to fuel your DevSecOps adoption ...
 
2022 DOI SKILup Days_Your Developers Decide Your Security Posture_Not Your Se...
2022 DOI SKILup Days_Your Developers Decide Your Security Posture_Not Your Se...2022 DOI SKILup Days_Your Developers Decide Your Security Posture_Not Your Se...
2022 DOI SKILup Days_Your Developers Decide Your Security Posture_Not Your Se...
 
GRASP Principles
GRASP PrinciplesGRASP Principles
GRASP Principles
 
unit-1 agile development.pptx
unit-1 agile development.pptxunit-1 agile development.pptx
unit-1 agile development.pptx
 
Mainframes agile2012
Mainframes agile2012Mainframes agile2012
Mainframes agile2012
 
Clean code: SOLID
Clean code: SOLIDClean code: SOLID
Clean code: SOLID
 
Clean code: SOLID (iOS)
Clean code: SOLID (iOS)Clean code: SOLID (iOS)
Clean code: SOLID (iOS)
 
Site-Reliability-Engineering-v2[6241].pdf
Site-Reliability-Engineering-v2[6241].pdfSite-Reliability-Engineering-v2[6241].pdf
Site-Reliability-Engineering-v2[6241].pdf
 
Building Large Sustainable Apps
Building Large Sustainable AppsBuilding Large Sustainable Apps
Building Large Sustainable Apps
 
Agile Project Failures: Root Causes and Corrective Actions
Agile Project Failures: Root Causes and Corrective ActionsAgile Project Failures: Root Causes and Corrective Actions
Agile Project Failures: Root Causes and Corrective Actions
 
Orchestration, the conductor's score
Orchestration, the conductor's scoreOrchestration, the conductor's score
Orchestration, the conductor's score
 
Kks sre book_ch1,2
Kks sre book_ch1,2Kks sre book_ch1,2
Kks sre book_ch1,2
 
Principles that Guide Practice
Principles that Guide PracticePrinciples that Guide Practice
Principles that Guide Practice
 

Recently uploaded

Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..
MaherOthman7
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
Kira Dess
 
electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
benjamincojr
 
Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networks
IJECEIAES
 

Recently uploaded (20)

Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
 
engineering chemistry power point presentation
engineering chemistry  power point presentationengineering chemistry  power point presentation
engineering chemistry power point presentation
 
Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..
 
Adsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptAdsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) ppt
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTUUNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
UNIT-2 image enhancement.pdf Image Processing Unit 2 AKTU
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded Systems
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, Functions
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
 
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
 
electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligence
 
Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Students
 
The Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptxThe Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptx
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdf
 
Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networks
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.ppt
 

GRASP - one more way to reach clean code