SlideShare a Scribd company logo
1 of 17
SINGLE RESPONSIBLE
Object design principle
Tu Pham
SINGLE RESPONSIBLE PRINCIPLE
 What
 Why
 How
 When
WHAT
 Software entities to have a single-minded quality, in
other words, to have a single purpose or reason for
existing
Alan Shalloway
 A class should have only one reason to change.
Robert Martin
WHAT(CONST)
 SRP is the way we organize property and method
to fulfill specific responsible
WHY
 Easy to change code
 Easy to adapt to requirement change
 Easy to find bug
 Easy to understand code
 Help program faster
 Easy life
WHY
HOW
 Consider when starting design
20%
HOW( CONTS)
 Continuous improvement (Refactor)
80%
HOW ( EXAMPLE )
 The program is told which movies a customer
rented and for how long. It then calculates the
charges, which depend on how long the movie is
rented, and identifies the type movie. There are
three kinds of movies: regular, children's, and new
releases. In addition to calculating charges, the
statement also computes frequent renter points,
which vary depending on whether the film is a new
release.
HOW(CONST)
Start with real example
HOW(CONST)
WHEN
 The Rule of Three
 The first time you do something, you just do it.
 The second time you do something similar, you
wince at the duplication, but you do the duplicate
thing anyway.
 The third time you do something similar, you
refactor
WHEN(CONST)
 Add function
 Fix bug
 Code review
WHAT IS IT MEAN?
Daily work
WHAT IS IT MEAN?
Don’t wait to deadline
Preparing your tomb
HOW TO TELL YOUR MANAGER
 Your manager is technical savvy – He knows
 If he is Quality or Schedule savvy – Don’t tell
Surely, Refactoring reduce bug( improve quality ) and
also help us faster ( ahead schedule )
Single responsible principle

More Related Content

Similar to Single responsible principle

The Best A/B Test Idea You Haven’t Thought Of
The Best A/B Test Idea You Haven’t Thought OfThe Best A/B Test Idea You Haven’t Thought Of
The Best A/B Test Idea You Haven’t Thought OfKissmetrics on SlideShare
 
Core Web Vitals & Google Page Experience por Seo Martin
Core Web Vitals & Google Page Experience por Seo MartinCore Web Vitals & Google Page Experience por Seo Martin
Core Web Vitals & Google Page Experience por Seo MartinSeo Martin
 
How To Hack The YouTube Algorithm in 2020
How To Hack The YouTube Algorithm in 2020 How To Hack The YouTube Algorithm in 2020
How To Hack The YouTube Algorithm in 2020 Oscar Mooy
 
Best Cost Calculation to Make a Mobile App Development in 2020
Best Cost Calculation to Make a Mobile App Development in 2020Best Cost Calculation to Make a Mobile App Development in 2020
Best Cost Calculation to Make a Mobile App Development in 2020Pencil Agency
 
Media Studies EVALUATION
Media Studies EVALUATIONMedia Studies EVALUATION
Media Studies EVALUATIONArjun Singh
 
Computer science homework help
Computer science homework helpComputer science homework help
Computer science homework helpandrey_milev
 
Computer science homework help
Computer science homework helpComputer science homework help
Computer science homework helproman nnelson
 
How to Build a Proof of Concept
How to Build a Proof of Concept How to Build a Proof of Concept
How to Build a Proof of Concept Michael Hamilton
 
Can I Buy An Essay Now Oelbert Gymnasiumoelbert
Can I Buy An Essay Now Oelbert GymnasiumoelbertCan I Buy An Essay Now Oelbert Gymnasiumoelbert
Can I Buy An Essay Now Oelbert GymnasiumoelbertAngela Gibbs
 
YouTubeVideoCatagorization
YouTubeVideoCatagorizationYouTubeVideoCatagorization
YouTubeVideoCatagorizationUrjit Patel
 
A DATA-DRIVEN INTELLIGENT APPLICATION FOR YOUTUBE VIDEO POPULARITY ANALYSIS U...
A DATA-DRIVEN INTELLIGENT APPLICATION FOR YOUTUBE VIDEO POPULARITY ANALYSIS U...A DATA-DRIVEN INTELLIGENT APPLICATION FOR YOUTUBE VIDEO POPULARITY ANALYSIS U...
A DATA-DRIVEN INTELLIGENT APPLICATION FOR YOUTUBE VIDEO POPULARITY ANALYSIS U...gerogepatton
 
Rianomics 10 ways to ensure RIA failure
Rianomics 10 ways to ensure RIA failureRianomics 10 ways to ensure RIA failure
Rianomics 10 ways to ensure RIA failureguestd27670
 
The Salesforce Playbook- 6 Steps to Better Deployments
The Salesforce Playbook- 6 Steps to Better DeploymentsThe Salesforce Playbook- 6 Steps to Better Deployments
The Salesforce Playbook- 6 Steps to Better DeploymentsAlex Cowan
 
mba solved resitting assignments
mba solved resitting assignmentsmba solved resitting assignments
mba solved resitting assignmentssolved_assignments
 
mba solved resitting assignments
mba solved resitting assignmentsmba solved resitting assignments
mba solved resitting assignmentssolved_assignments
 
MBA solved resitting assignments
MBA solved resitting assignmentsMBA solved resitting assignments
MBA solved resitting assignmentssolved_assignments
 
mba solved resitting assignments
mba solved resitting assignmentsmba solved resitting assignments
mba solved resitting assignmentssolved_assignments
 
How to Present Test Results to Inspire Action
How to Present Test Results to Inspire ActionHow to Present Test Results to Inspire Action
How to Present Test Results to Inspire ActionJason Packer
 

Similar to Single responsible principle (20)

The Best A/B Test Idea You Haven’t Thought Of
The Best A/B Test Idea You Haven’t Thought OfThe Best A/B Test Idea You Haven’t Thought Of
The Best A/B Test Idea You Haven’t Thought Of
 
Core Web Vitals & Google Page Experience por Seo Martin
Core Web Vitals & Google Page Experience por Seo MartinCore Web Vitals & Google Page Experience por Seo Martin
Core Web Vitals & Google Page Experience por Seo Martin
 
How To Hack The YouTube Algorithm in 2020
How To Hack The YouTube Algorithm in 2020 How To Hack The YouTube Algorithm in 2020
How To Hack The YouTube Algorithm in 2020
 
Youtube marketing software
Youtube marketing softwareYoutube marketing software
Youtube marketing software
 
Computer science homework help
Computer science homework helpComputer science homework help
Computer science homework help
 
Best Cost Calculation to Make a Mobile App Development in 2020
Best Cost Calculation to Make a Mobile App Development in 2020Best Cost Calculation to Make a Mobile App Development in 2020
Best Cost Calculation to Make a Mobile App Development in 2020
 
Media Studies EVALUATION
Media Studies EVALUATIONMedia Studies EVALUATION
Media Studies EVALUATION
 
Computer science homework help
Computer science homework helpComputer science homework help
Computer science homework help
 
Computer science homework help
Computer science homework helpComputer science homework help
Computer science homework help
 
How to Build a Proof of Concept
How to Build a Proof of Concept How to Build a Proof of Concept
How to Build a Proof of Concept
 
Can I Buy An Essay Now Oelbert Gymnasiumoelbert
Can I Buy An Essay Now Oelbert GymnasiumoelbertCan I Buy An Essay Now Oelbert Gymnasiumoelbert
Can I Buy An Essay Now Oelbert Gymnasiumoelbert
 
YouTubeVideoCatagorization
YouTubeVideoCatagorizationYouTubeVideoCatagorization
YouTubeVideoCatagorization
 
A DATA-DRIVEN INTELLIGENT APPLICATION FOR YOUTUBE VIDEO POPULARITY ANALYSIS U...
A DATA-DRIVEN INTELLIGENT APPLICATION FOR YOUTUBE VIDEO POPULARITY ANALYSIS U...A DATA-DRIVEN INTELLIGENT APPLICATION FOR YOUTUBE VIDEO POPULARITY ANALYSIS U...
A DATA-DRIVEN INTELLIGENT APPLICATION FOR YOUTUBE VIDEO POPULARITY ANALYSIS U...
 
Rianomics 10 ways to ensure RIA failure
Rianomics 10 ways to ensure RIA failureRianomics 10 ways to ensure RIA failure
Rianomics 10 ways to ensure RIA failure
 
The Salesforce Playbook- 6 Steps to Better Deployments
The Salesforce Playbook- 6 Steps to Better DeploymentsThe Salesforce Playbook- 6 Steps to Better Deployments
The Salesforce Playbook- 6 Steps to Better Deployments
 
mba solved resitting assignments
mba solved resitting assignmentsmba solved resitting assignments
mba solved resitting assignments
 
mba solved resitting assignments
mba solved resitting assignmentsmba solved resitting assignments
mba solved resitting assignments
 
MBA solved resitting assignments
MBA solved resitting assignmentsMBA solved resitting assignments
MBA solved resitting assignments
 
mba solved resitting assignments
mba solved resitting assignmentsmba solved resitting assignments
mba solved resitting assignments
 
How to Present Test Results to Inspire Action
How to Present Test Results to Inspire ActionHow to Present Test Results to Inspire Action
How to Present Test Results to Inspire Action
 

Recently uploaded

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Single responsible principle

  • 2. SINGLE RESPONSIBLE PRINCIPLE  What  Why  How  When
  • 3. WHAT  Software entities to have a single-minded quality, in other words, to have a single purpose or reason for existing Alan Shalloway  A class should have only one reason to change. Robert Martin
  • 4. WHAT(CONST)  SRP is the way we organize property and method to fulfill specific responsible
  • 5. WHY  Easy to change code  Easy to adapt to requirement change  Easy to find bug  Easy to understand code  Help program faster  Easy life
  • 6. WHY
  • 7. HOW  Consider when starting design 20%
  • 8. HOW( CONTS)  Continuous improvement (Refactor) 80%
  • 9. HOW ( EXAMPLE )  The program is told which movies a customer rented and for how long. It then calculates the charges, which depend on how long the movie is rented, and identifies the type movie. There are three kinds of movies: regular, children's, and new releases. In addition to calculating charges, the statement also computes frequent renter points, which vary depending on whether the film is a new release.
  • 12. WHEN  The Rule of Three  The first time you do something, you just do it.  The second time you do something similar, you wince at the duplication, but you do the duplicate thing anyway.  The third time you do something similar, you refactor
  • 13. WHEN(CONST)  Add function  Fix bug  Code review
  • 14. WHAT IS IT MEAN? Daily work
  • 15. WHAT IS IT MEAN? Don’t wait to deadline Preparing your tomb
  • 16. HOW TO TELL YOUR MANAGER  Your manager is technical savvy – He knows  If he is Quality or Schedule savvy – Don’t tell Surely, Refactoring reduce bug( improve quality ) and also help us faster ( ahead schedule )

Editor's Notes

  1. Let’s take classes, for instance. A class should be defined by its responsibility, and there should be only one general responsibility per class. Within a class are methods, state, and relationships to other objects that enable the class to fulfil its responsibility. Class cohesion is strong when all the internal aspects of a class relate to each other within the context of the class’s single responsibility.