SlideShare a Scribd company logo
Boutique product development company 
It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products.
GRASP 
PRINCIPLES 
Boutique product development company 
It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products. 
Raheel Arif | Software Engineer
Understanding responsibilities is key to object-oriented 
design - Martin Fowler 
GRASP 
o GRASP = General Responsibility Assignment Software 
Patterns 
o A set of principles for assigning responsibilities to classes – 
the key skill in OO software design 
Raheel Arif | Software Engineer
GRASP PRINCIPLES 
Raheel Arif | Software Engineer 
9 GRASP principles: 
o Information Expert 
o Creator 
o Low Coupling 
o Controller 
o High Cohesion 
o Polymorphism 
o Pure Fabrication 
o Indirection 
o Protected Variations
GRASP Principles 
Information Expert 
Problem: What is a general principle for assigning 
responsibilities to objects? 
Solution: Assign a responsibility to the information expert, that 
is, the class that has the information necessary to fulfill the 
responsibility. 
Example: E.g., Board information needed to get a Square 
Raheel Arif | Software Engineer
GRASP Principles 
Pros and Cons 
• Facilitates information encapsulation: why? 
o Classes use their own info to fulfill tasks 
• Encourages cohesive, lightweight class definitions 
But: 
• Information expert may contradict patterns of 
Low Coupling and High Cohesion 
Raheel Arif | Software Engineer
GRASP Principles 
Creator 
Problem: Who creates an A? 
Solution: 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 instances of A 
• B closely uses A 
• B has the initializing data for A. 
Raheel Arif | Software Engineer
GRASP Principles 
Who creates the Squares? 
Raheel Arif | Software Engineer
GRASP Principles 
Raheel Arif | Software Engineer
GRASP Principles 
Low Coupling 
Problem: How to support low dependency, low change 
impact, increased reuse? 
Solution: Assign a responsibility so coupling is low. 
Coupling – a measure of how strongly one element is 
connected to, has knowledge of, or relies on other elements 
Raheel Arif | Software Engineer
GRASP Principles 
Low Coupling 
A class with high coupling relies on many other classes – 
leads to problems: 
• Changes in related classes forces local changes 
• Harder to understand in isolation 
• Harder to reuse 
Raheel Arif | Software Engineer
GRASP Principles 
Example 
Raheel Arif | Software Engineer
GRASP Principles 
Benefits 
• Understandability: Classes are easier to understand in 
Raheel Arif | Software Engineer 
isolation 
• Maintainability: Classes aren’t affected by changes in 
other components 
• Reusability: easier to grab hold of classes
GRASP Principles 
Controller 
Problem: Who should be responsible for handling a system 
event? (Or, what object receives and coordinates a system 
operation?) 
Solution: Assign the responsibility for receiving and/or 
handling a system event to one of following choices: 
• Represent the overall system, device or subsystem 
(façade controller) 
• Represent a use case scenario within which the system 
event occurs (a <UseCase>Handler) 
Raheel Arif | Software Engineer
GRASP Principles 
High Cohesion 
Problem: How to keep classes focused and manageable? 
Solution: Assign responsibility so that cohesion remains 
high. 
Cohesion measures how strongly related and focused are 
the responsibilities of an element 
Raheel Arif | Software Engineer
GRASP Principles 
High Cohesion 
Problems from low cohesion (does many unrelated things or 
does too much work): 
• Hard to understand/comprehend 
• Hard to reuse 
• Hard to maintain 
Brittle – easily affected by change 
Raheel Arif | Software Engineer
GRASP Principles 
High Cohesion 
Raheel Arif | Software Engineer
GRASP Principles 
High Cohesion 
• Very low cohesion – a class is responsible for many things 
in different functional areas 
• High cohesion – a class has moderate responsibilities in 
one functional area and collaborates with other classes to 
fulfill tasks 
Raheel Arif | Software Engineer
GRASP Principles 
High Cohesion 
Typically high cohesion => few methods with highly related 
functionality 
Benefits of high cohesion: 
• Easy to maintain 
• Easy to understand 
• Easy to reuse 
Raheel Arif | Software Engineer
GRASP Principles 
Polymorphism 
Problem: How to handle alternatives based on type? 
How to create pluggable software components 
Solution: When related alternatives or behaviors vary by 
type (class), assign responsibilities for the behavior—using 
polymorphic operations—to the 
types for which the behavior varies. 
• Polymorphic operations are those that operate on 
Raheel Arif | Software Engineer 
differing classes 
• Don’t test for the type of the object and use conditional 
logic to perform varying statements based on type.
GRASP Principles 
Monopoly Problem: How to Design for Different Square Actions? 
Raheel Arif | Software Engineer
GRASP Principles 
Polymorphism 
Raheel Arif | Software Engineer
GRASP Principles 
Pure Fabrication 
Problem: What object should have the responsibility, when 
you do not want to violate High Cohesion and Low Coupling, 
or other goals, but solutions offered by Expert (for example) 
are not appropriate? 
Solution: Assign a highly cohesive set of responsibilities to 
an artificial or convenience class that does not represent a 
problem domain concept something made up, to support 
high cohesion, low coupling, and reuse. 
Raheel Arif | Software Engineer
GRASP Principles 
Pure Fabrication- Example 
Who should be responsible for saving Sale instances in a 
relational database? 
- by Information Expert ?? 
- leads to low cohesion 
- and high coupling 
- better: create (“fabricate”) a new class that has this 
Raheel Arif | Software Engineer 
responsibility
GRASP Principles 
Indirection 
Sometimes objects must interact with other objects or external 
systems, which may change (or replaced) in future. Direct coupling to 
such objects or systems may result in modification in our objects 
Problem: Where to assign a responsibility, to avoid direct coupling 
between two (or more) things? How to de-couple objects so that low 
coupling is supported and reuse potential remains higher? 
Solution: 
Assign the responsibility to an intermediate object to mediate 
between other components or services so that they are not directly 
coupled. The intermediary creates an indirection between other 
components. 
Raheel Arif | Software Engineer
GRASP Principles 
Indirection--A Simple Example 
Consider a CreditAuthorizationService class that needs to 
use a Modem 
Bad approach: 
Put low-level calls to the Modem API directly in the methods of the 
CreditAuthorizationClass 
Better approach: 
Add an intermediateModemclass that insulates 
CreditAuthorizationClass from the Modem API. 
Raheel Arif | Software Engineer
GRASP Principles 
Indirection--A Simple Example 
Problems: 
In a Sales System, there are multiple external third-party tax calculators 
that must be supported. 
The system needs to be able to integrate with different calculators 
according to some conditions. 
For example; if total is above 500TL it uses the external "Tax Master" 
program, otherwise "Good As Gold" program. 
Each tax calculator has a different interface . 
One product may support a raw TCP socket protocol, another may offer a 
SOAP interface, and a third may offer a Java RMI interface. 
In the future, a new calculator program may be integrated into the system 
or an existing calculator may be removed 
Actually Sale class is responsible to calculate the total and therefore needs 
the tax. 
However, we want to keep our system (Sale) independent from the varying 
external tax calculators. 
Raheel Arif | Software Engineer
GRASP Principles 
Example: Third-Party (External) Tax Calculators in the NextGen System 
Raheel Arif | Software Engineer
GRASP Principles 
Example: Third-Party (External) Tax Calculators in the NextGen System 
Raheel Arif | Software Engineer
GRASP Principles 
Indirection - Notes 
● The GoF Proxy, Bridge, and Mediator patterns utilize indirection. 
● For that matter, classes created for Indirection are usually also Pure 
Fabrications, thus exemplifying two patterns for the price of one. :-) 
Raheel Arif | Software Engineer 
● Lower coupling between components 
● Indirection is pervasive in computer science: 
"Most problems in computer science can be solved by another 
level of indirection."- David Wheeler 
..but: 
"Most problems in performance can be solved by removing 
another layer of indirection." - anonymous
GRASP Principles 
Protected Variations 
Problem: How to design objects, subsystems, and systems so that 
the variations or instability in these elements does not have an 
undesirable impact on other elements? 
Solution: Identify points of predicted variation or instability; assign 
responsibilities to create a stable interface around them. 
(The term "interface" is used in the broadest sense of an access 
view; it does not literally only mean something like a Java interface. 
Raheel Arif | Software Engineer
GRASP Principles 
Protected Variations - Example 
Problem: a client explained that the logistical support application 
used by an airline was a maintenance headache. There was frequent 
modification of the business logic to support the logistics. How do you 
protect the system from variations at this point? 
Raheel Arif | Software Engineer
GRASP Principles 
Protected Variations - Example 
Solution: A rules engine was added to the system, and an external 
rule editor let the subject matter experts update the rules without 
requiring changes to the source code of the system. 
Raheel Arif | Software Engineer
GRASP Principles 
Thank you for your time 
If you have any questions 
then please ask 
Waleed Bin Dawood | Software Engineer

More Related Content

What's hot

Sequence diagram
Sequence diagramSequence diagram
Sequence diagram
Rahul Pola
 
Coding standard and coding guideline
Coding standard and coding guidelineCoding standard and coding guideline
Coding standard and coding guideline
Dhananjaysinh Jhala
 
Requirement specification (SRS)
Requirement specification (SRS)Requirement specification (SRS)
Requirement specification (SRS)
kunj desai
 
Quality concept
Quality concept Quality concept
Loc and function point
Loc and function pointLoc and function point
Loc and function point
Mitali Chugh
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML Diagrams
Manish Kumar
 
Iterative model
Iterative modelIterative model
Iterative model
Vaibhav Dash
 
Unit 4 designing classes
Unit 4  designing classesUnit 4  designing classes
Unit 4 designing classesgopal10scs185
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
Sudarsun Santhiappan
 
Programming team structure
Programming team structureProgramming team structure
Programming team structure
NancyBeaulah_R
 
Rad model
Rad modelRad model
Uml in software engineering
Uml in software engineeringUml in software engineering
Uml in software engineering
Mubashir Jutt
 
Aspect oriented architecture
Aspect oriented architecture Aspect oriented architecture
Aspect oriented architecture tigneb
 
unit testing and debugging
unit testing and debuggingunit testing and debugging
unit testing and debugging
KarthigaGunasekaran1
 
INTRODUCTION TO UML DIAGRAMS
INTRODUCTION TO UML DIAGRAMSINTRODUCTION TO UML DIAGRAMS
INTRODUCTION TO UML DIAGRAMS
Ashita Agrawal
 
Uml class diagram and packages ppt for dot net
Uml class diagram and packages ppt for dot netUml class diagram and packages ppt for dot net
Uml class diagram and packages ppt for dot net
mekhap
 
Chapter 1 2 - some size factors
Chapter 1   2 - some size factorsChapter 1   2 - some size factors
Chapter 1 2 - some size factors
NancyBeaulah_R
 
Uml diagrams
Uml diagramsUml diagrams
Uml diagrams
barney92
 
Analysis modeling
Analysis modelingAnalysis modeling
Analysis modeling
Inocentshuja Ahmad
 
Software estimation
Software estimationSoftware estimation
Software estimationMd Shakir
 

What's hot (20)

Sequence diagram
Sequence diagramSequence diagram
Sequence diagram
 
Coding standard and coding guideline
Coding standard and coding guidelineCoding standard and coding guideline
Coding standard and coding guideline
 
Requirement specification (SRS)
Requirement specification (SRS)Requirement specification (SRS)
Requirement specification (SRS)
 
Quality concept
Quality concept Quality concept
Quality concept
 
Loc and function point
Loc and function pointLoc and function point
Loc and function point
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML Diagrams
 
Iterative model
Iterative modelIterative model
Iterative model
 
Unit 4 designing classes
Unit 4  designing classesUnit 4  designing classes
Unit 4 designing classes
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
 
Programming team structure
Programming team structureProgramming team structure
Programming team structure
 
Rad model
Rad modelRad model
Rad model
 
Uml in software engineering
Uml in software engineeringUml in software engineering
Uml in software engineering
 
Aspect oriented architecture
Aspect oriented architecture Aspect oriented architecture
Aspect oriented architecture
 
unit testing and debugging
unit testing and debuggingunit testing and debugging
unit testing and debugging
 
INTRODUCTION TO UML DIAGRAMS
INTRODUCTION TO UML DIAGRAMSINTRODUCTION TO UML DIAGRAMS
INTRODUCTION TO UML DIAGRAMS
 
Uml class diagram and packages ppt for dot net
Uml class diagram and packages ppt for dot netUml class diagram and packages ppt for dot net
Uml class diagram and packages ppt for dot net
 
Chapter 1 2 - some size factors
Chapter 1   2 - some size factorsChapter 1   2 - some size factors
Chapter 1 2 - some size factors
 
Uml diagrams
Uml diagramsUml diagrams
Uml diagrams
 
Analysis modeling
Analysis modelingAnalysis modeling
Analysis modeling
 
Software estimation
Software estimationSoftware estimation
Software estimation
 

Similar to GRASP Principles

Software process model
Software process modelSoftware process model
Software process model
Muhammad Yousuf Abdul Qadir
 
Chapter 3 Software Process Model.ppt
Chapter 3 Software Process Model.pptChapter 3 Software Process Model.ppt
Chapter 3 Software Process Model.ppt
RayonJ1
 
Introduction to DevOps slides-converted (1).pptx
Introduction to DevOps slides-converted (1).pptxIntroduction to DevOps slides-converted (1).pptx
Introduction to DevOps slides-converted (1).pptx
aasssss1
 
Sfeldman performance bb_worldemea07
Sfeldman performance bb_worldemea07Sfeldman performance bb_worldemea07
Sfeldman performance bb_worldemea07Steve Feldman
 
Software Process Model in software engineering
Software Process Model in software engineeringSoftware Process Model in software engineering
Software Process Model in software engineering
MuhammadTalha436
 
Assess enterprise applications for cloud migration
Assess enterprise applications for cloud migrationAssess enterprise applications for cloud migration
Assess enterprise applications for cloud migration
nanda1505
 
Timeline Consulting_Where Next For ERP
Timeline Consulting_Where Next For ERPTimeline Consulting_Where Next For ERP
Timeline Consulting_Where Next For ERPJim Foster
 
Top trends in erp 2017v8.compressed
Top trends in erp 2017v8.compressedTop trends in erp 2017v8.compressed
Top trends in erp 2017v8.compressed
Jon Sturgeon
 
Online student management system
Online student management systemOnline student management system
Online student management systemMumbai Academisc
 
RUP
RUPRUP
Maximize your Oracle Cloud Investment and Drive Innovation
 Maximize your Oracle Cloud Investment and Drive Innovation Maximize your Oracle Cloud Investment and Drive Innovation
Maximize your Oracle Cloud Investment and Drive Innovation
Smart ERP Solutions, Inc.
 
IBM Cloud Service Management and Operations Field Guide
IBM Cloud Service Management and Operations Field GuideIBM Cloud Service Management and Operations Field Guide
IBM Cloud Service Management and Operations Field Guide
Carol Wingfield
 
Enterprise Agile at Lockheed Martin - 4th February 2014
Enterprise Agile at Lockheed Martin - 4th February 2014Enterprise Agile at Lockheed Martin - 4th February 2014
Enterprise Agile at Lockheed Martin - 4th February 2014
Association for Project Management
 
Different Methodologies Used By Programming Teams
Different Methodologies Used By Programming TeamsDifferent Methodologies Used By Programming Teams
Different Methodologies Used By Programming Teams
Nicole Gomez
 
Automation, Audits, and Apps Tour
Automation, Audits, and Apps TourAutomation, Audits, and Apps Tour
Automation, Audits, and Apps Tour
Chef
 
9 Principles for Salesforce Application Architecture
9 Principles for Salesforce Application Architecture9 Principles for Salesforce Application Architecture
9 Principles for Salesforce Application Architecture
Steven Herod
 
Four principles seminar manageware seminar
Four principles seminar   manageware seminarFour principles seminar   manageware seminar
Four principles seminar manageware seminarManageware
 
David Leslie - Testing at MACH Speed.pptx
David Leslie - Testing at MACH Speed.pptxDavid Leslie - Testing at MACH Speed.pptx
David Leslie - Testing at MACH Speed.pptx
QA or the Highway
 
Introduction to ERP Concept
Introduction to ERP ConceptIntroduction to ERP Concept
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing Software
Steven Smith
 

Similar to GRASP Principles (20)

Software process model
Software process modelSoftware process model
Software process model
 
Chapter 3 Software Process Model.ppt
Chapter 3 Software Process Model.pptChapter 3 Software Process Model.ppt
Chapter 3 Software Process Model.ppt
 
Introduction to DevOps slides-converted (1).pptx
Introduction to DevOps slides-converted (1).pptxIntroduction to DevOps slides-converted (1).pptx
Introduction to DevOps slides-converted (1).pptx
 
Sfeldman performance bb_worldemea07
Sfeldman performance bb_worldemea07Sfeldman performance bb_worldemea07
Sfeldman performance bb_worldemea07
 
Software Process Model in software engineering
Software Process Model in software engineeringSoftware Process Model in software engineering
Software Process Model in software engineering
 
Assess enterprise applications for cloud migration
Assess enterprise applications for cloud migrationAssess enterprise applications for cloud migration
Assess enterprise applications for cloud migration
 
Timeline Consulting_Where Next For ERP
Timeline Consulting_Where Next For ERPTimeline Consulting_Where Next For ERP
Timeline Consulting_Where Next For ERP
 
Top trends in erp 2017v8.compressed
Top trends in erp 2017v8.compressedTop trends in erp 2017v8.compressed
Top trends in erp 2017v8.compressed
 
Online student management system
Online student management systemOnline student management system
Online student management system
 
RUP
RUPRUP
RUP
 
Maximize your Oracle Cloud Investment and Drive Innovation
 Maximize your Oracle Cloud Investment and Drive Innovation Maximize your Oracle Cloud Investment and Drive Innovation
Maximize your Oracle Cloud Investment and Drive Innovation
 
IBM Cloud Service Management and Operations Field Guide
IBM Cloud Service Management and Operations Field GuideIBM Cloud Service Management and Operations Field Guide
IBM Cloud Service Management and Operations Field Guide
 
Enterprise Agile at Lockheed Martin - 4th February 2014
Enterprise Agile at Lockheed Martin - 4th February 2014Enterprise Agile at Lockheed Martin - 4th February 2014
Enterprise Agile at Lockheed Martin - 4th February 2014
 
Different Methodologies Used By Programming Teams
Different Methodologies Used By Programming TeamsDifferent Methodologies Used By Programming Teams
Different Methodologies Used By Programming Teams
 
Automation, Audits, and Apps Tour
Automation, Audits, and Apps TourAutomation, Audits, and Apps Tour
Automation, Audits, and Apps Tour
 
9 Principles for Salesforce Application Architecture
9 Principles for Salesforce Application Architecture9 Principles for Salesforce Application Architecture
9 Principles for Salesforce Application Architecture
 
Four principles seminar manageware seminar
Four principles seminar   manageware seminarFour principles seminar   manageware seminar
Four principles seminar manageware seminar
 
David Leslie - Testing at MACH Speed.pptx
David Leslie - Testing at MACH Speed.pptxDavid Leslie - Testing at MACH Speed.pptx
David Leslie - Testing at MACH Speed.pptx
 
Introduction to ERP Concept
Introduction to ERP ConceptIntroduction to ERP Concept
Introduction to ERP Concept
 
Improving the Quality of Existing Software
Improving the Quality of Existing SoftwareImproving the Quality of Existing Software
Improving the Quality of Existing Software
 

Recently uploaded

Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Yara Milbes
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 

Recently uploaded (20)

Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 

GRASP Principles

  • 1. Boutique product development company It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products.
  • 2. GRASP PRINCIPLES Boutique product development company It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products. Raheel Arif | Software Engineer
  • 3. Understanding responsibilities is key to object-oriented design - Martin Fowler GRASP o GRASP = General Responsibility Assignment Software Patterns o A set of principles for assigning responsibilities to classes – the key skill in OO software design Raheel Arif | Software Engineer
  • 4. GRASP PRINCIPLES Raheel Arif | Software Engineer 9 GRASP principles: o Information Expert o Creator o Low Coupling o Controller o High Cohesion o Polymorphism o Pure Fabrication o Indirection o Protected Variations
  • 5. GRASP Principles Information Expert Problem: What is a general principle for assigning responsibilities to objects? Solution: Assign a responsibility to the information expert, that is, the class that has the information necessary to fulfill the responsibility. Example: E.g., Board information needed to get a Square Raheel Arif | Software Engineer
  • 6. GRASP Principles Pros and Cons • Facilitates information encapsulation: why? o Classes use their own info to fulfill tasks • Encourages cohesive, lightweight class definitions But: • Information expert may contradict patterns of Low Coupling and High Cohesion Raheel Arif | Software Engineer
  • 7. GRASP Principles Creator Problem: Who creates an A? Solution: 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 instances of A • B closely uses A • B has the initializing data for A. Raheel Arif | Software Engineer
  • 8. GRASP Principles Who creates the Squares? Raheel Arif | Software Engineer
  • 9. GRASP Principles Raheel Arif | Software Engineer
  • 10. GRASP Principles Low Coupling Problem: How to support low dependency, low change impact, increased reuse? Solution: Assign a responsibility so coupling is low. Coupling – a measure of how strongly one element is connected to, has knowledge of, or relies on other elements Raheel Arif | Software Engineer
  • 11. GRASP Principles Low Coupling A class with high coupling relies on many other classes – leads to problems: • Changes in related classes forces local changes • Harder to understand in isolation • Harder to reuse Raheel Arif | Software Engineer
  • 12. GRASP Principles Example Raheel Arif | Software Engineer
  • 13. GRASP Principles Benefits • Understandability: Classes are easier to understand in Raheel Arif | Software Engineer isolation • Maintainability: Classes aren’t affected by changes in other components • Reusability: easier to grab hold of classes
  • 14. GRASP Principles Controller Problem: Who should be responsible for handling a system event? (Or, what object receives and coordinates a system operation?) Solution: Assign the responsibility for receiving and/or handling a system event to one of following choices: • Represent the overall system, device or subsystem (façade controller) • Represent a use case scenario within which the system event occurs (a <UseCase>Handler) Raheel Arif | Software Engineer
  • 15. GRASP Principles High Cohesion Problem: How to keep classes focused and manageable? Solution: Assign responsibility so that cohesion remains high. Cohesion measures how strongly related and focused are the responsibilities of an element Raheel Arif | Software Engineer
  • 16. GRASP Principles High Cohesion Problems from low cohesion (does many unrelated things or does too much work): • Hard to understand/comprehend • Hard to reuse • Hard to maintain Brittle – easily affected by change Raheel Arif | Software Engineer
  • 17. GRASP Principles High Cohesion Raheel Arif | Software Engineer
  • 18. GRASP Principles High Cohesion • Very low cohesion – a class is responsible for many things in different functional areas • High cohesion – a class has moderate responsibilities in one functional area and collaborates with other classes to fulfill tasks Raheel Arif | Software Engineer
  • 19. GRASP Principles High Cohesion Typically high cohesion => few methods with highly related functionality Benefits of high cohesion: • Easy to maintain • Easy to understand • Easy to reuse Raheel Arif | Software Engineer
  • 20. GRASP Principles Polymorphism Problem: How to handle alternatives based on type? How to create pluggable software components Solution: When related alternatives or behaviors vary by type (class), assign responsibilities for the behavior—using polymorphic operations—to the types for which the behavior varies. • Polymorphic operations are those that operate on Raheel Arif | Software Engineer differing classes • Don’t test for the type of the object and use conditional logic to perform varying statements based on type.
  • 21. GRASP Principles Monopoly Problem: How to Design for Different Square Actions? Raheel Arif | Software Engineer
  • 22. GRASP Principles Polymorphism Raheel Arif | Software Engineer
  • 23. GRASP Principles Pure Fabrication Problem: What object should have the responsibility, when you do not want to violate High Cohesion and Low Coupling, or other goals, but solutions offered by Expert (for example) are not appropriate? Solution: Assign a highly cohesive set of responsibilities to an artificial or convenience class that does not represent a problem domain concept something made up, to support high cohesion, low coupling, and reuse. Raheel Arif | Software Engineer
  • 24. GRASP Principles Pure Fabrication- Example Who should be responsible for saving Sale instances in a relational database? - by Information Expert ?? - leads to low cohesion - and high coupling - better: create (“fabricate”) a new class that has this Raheel Arif | Software Engineer responsibility
  • 25. GRASP Principles Indirection Sometimes objects must interact with other objects or external systems, which may change (or replaced) in future. Direct coupling to such objects or systems may result in modification in our objects Problem: Where to assign a responsibility, to avoid direct coupling between two (or more) things? How to de-couple objects so that low coupling is supported and reuse potential remains higher? Solution: Assign the responsibility to an intermediate object to mediate between other components or services so that they are not directly coupled. The intermediary creates an indirection between other components. Raheel Arif | Software Engineer
  • 26. GRASP Principles Indirection--A Simple Example Consider a CreditAuthorizationService class that needs to use a Modem Bad approach: Put low-level calls to the Modem API directly in the methods of the CreditAuthorizationClass Better approach: Add an intermediateModemclass that insulates CreditAuthorizationClass from the Modem API. Raheel Arif | Software Engineer
  • 27. GRASP Principles Indirection--A Simple Example Problems: In a Sales System, there are multiple external third-party tax calculators that must be supported. The system needs to be able to integrate with different calculators according to some conditions. For example; if total is above 500TL it uses the external "Tax Master" program, otherwise "Good As Gold" program. Each tax calculator has a different interface . One product may support a raw TCP socket protocol, another may offer a SOAP interface, and a third may offer a Java RMI interface. In the future, a new calculator program may be integrated into the system or an existing calculator may be removed Actually Sale class is responsible to calculate the total and therefore needs the tax. However, we want to keep our system (Sale) independent from the varying external tax calculators. Raheel Arif | Software Engineer
  • 28. GRASP Principles Example: Third-Party (External) Tax Calculators in the NextGen System Raheel Arif | Software Engineer
  • 29. GRASP Principles Example: Third-Party (External) Tax Calculators in the NextGen System Raheel Arif | Software Engineer
  • 30. GRASP Principles Indirection - Notes ● The GoF Proxy, Bridge, and Mediator patterns utilize indirection. ● For that matter, classes created for Indirection are usually also Pure Fabrications, thus exemplifying two patterns for the price of one. :-) Raheel Arif | Software Engineer ● Lower coupling between components ● Indirection is pervasive in computer science: "Most problems in computer science can be solved by another level of indirection."- David Wheeler ..but: "Most problems in performance can be solved by removing another layer of indirection." - anonymous
  • 31. GRASP Principles Protected Variations Problem: How to design objects, subsystems, and systems so that the variations or instability in these elements does not have an undesirable impact on other elements? Solution: Identify points of predicted variation or instability; assign responsibilities to create a stable interface around them. (The term "interface" is used in the broadest sense of an access view; it does not literally only mean something like a Java interface. Raheel Arif | Software Engineer
  • 32. GRASP Principles Protected Variations - Example Problem: a client explained that the logistical support application used by an airline was a maintenance headache. There was frequent modification of the business logic to support the logistics. How do you protect the system from variations at this point? Raheel Arif | Software Engineer
  • 33. GRASP Principles Protected Variations - Example Solution: A rules engine was added to the system, and an external rule editor let the subject matter experts update the rules without requiring changes to the source code of the system. Raheel Arif | Software Engineer
  • 34. GRASP Principles Thank you for your time If you have any questions then please ask Waleed Bin Dawood | Software Engineer