SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

Similar a 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 Of
Kissmetrics on SlideShare
 
Media Studies EVALUATION
Media Studies EVALUATIONMedia Studies EVALUATION
Media Studies EVALUATION
Arjun Singh
 
YouTubeVideoCatagorization
YouTubeVideoCatagorizationYouTubeVideoCatagorization
YouTubeVideoCatagorization
Urjit Patel
 

Similar a 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
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

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 )

Notas del editor

  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.