SlideShare uma empresa 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

Mais conteúdo relacionado

Semelhante 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
 

Semelhante 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

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
 

Último (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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, ...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
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...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

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 do 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.