SlideShare a Scribd company logo
Design around the…

Single Responsibility Principle

By Eyal Golan
Agenda
1. SOLID
2. SRP overview
3. Why SRP?
4. Recognizing SRP violation
5. Develop for SRP
6. Summarize
2
3
S
O
L
I
D
• Robert C. Martin – Uncle Bob
• http://en.wikipedia.org/wiki/SOLID_(objectoriented_design)
4
SOLID
• Single responsibility principle
• A class should have only a single
responsibility

5
SOLID
• Open/closed principle
• Open for extension, but closed for
modification
• Alistair Cockburn: “…Identify points of predicted
variation and create a stable interface around them…”

6
SOLID
• Liskov substitution principle
• Replace objects with instances of their
subtypes without altering the correctness of
that program
Rectangle
Square

7
SOLID
• Interface segregation principle
• Many client-specific interfaces are better
than one general-purpose interface

8
SOLID
• Dependency inversion principle
• Abstractions should not depend on details
• Don’t depend on anything concrete
• Work with interfaces

9
10
Single Responsibility Principle
• Wikipedia
• …the single responsibility principle states that every class
should have a single responsibility, and that responsibility
should be entirely encapsulated by the class. All its services
should be narrowly aligned with that responsibility…

• Clean Code
• A class or module should have one, and only
one, reason to change
11
Which Components?
•
•
•
•
•

Methods
Classes
Packages
Modules
System

12
13
Why SRP?
• Organize the code

George A. Miller
14
Why SRP?
• A place for everything and
everything in its place

15
Why SRP?
• Less fragile code
• Low coupling
• High cohesion

16
Why SRP?
• Easier code changes (Refactoring)

17
Why SRP?
• Easier naming
• The smaller and more focused class, it will
be easier to name

18
Why SRP?
• Maintainability
• Testability and easier debugging

19
20
Recognizing By Structure
• Class / method is too long

21
Recognizing By Structure
• Too many dependencies (fields /
parameters)
Dependency
3

Dependency
4

Dependency
2

Dependency
1

Dependency
5

Class

Dependency
6

22
Recognizing By Structure
• Low cohesion

23
Recognizing By Structure
• Description / name needs: “AND”

• Generic name: “EmployeeManager”

24
Recognizing By Structure
• A method with many levels

25
Recognizing By Behavior
• Complicated test

26
Recognizing By Behavior
• Change here, break there
• Test may be broken elsewhere
• The “shotgun effect”

27
Recognizing By Behavior
• Unable to encapsulate the module

28
29
Develop for SRP
• Awareness
• The state or ability to perceive, to feel, or to
be conscious of events, objects, or sensory
patterns

30
Develop for SRP
• Testable code
Test

• TDD
Refactor

Code

31
Develop for SRP
• Code quality metrics
• Coverage
• SONAR

32
Develop for SRP
• Use other principles
•
•
•
•

High cohesion
Decrease coupling
Interfaces
Real encapsulation
• Law of Demeter

33
Develop for SRP

Keep it simple and short!

34
Develop for SRP
• Naming
• Think about it
• Role play your entities
• Longer and more focused name

35
Develop for SRP
• Extract method
• Extract class

36
Develop for SRP
• Refactor mercilessly
• Use design patterns
• Keep modularization clear

37
Example
Short class,
35 lines

Precise name
(method, class)

High cohesion

38
Conclusion
• OOD
• Clean code
• Better practice

SRP
Do 1 t h i
A
s
o
c

c l a s s
h o u l d h a v e
ne r e a s on t o
h a n g e !
39
Resources
• http://butunclebob.com/ArticleS.UncleBob.Principles
OfOod
• Uncle Bob about SRP

• http://www.codinghorror.com/blog/2007/03/curlyslaw-do-one-thing.html
• Coding Horror

• https://docs.google.com/file/d/0ByOwmqah_nuGNH
EtcU5OekdDMkk/
• PDF about SRP

• http://eyalgo.com/2014/02/01/the-singleresponsibility-principle/
• My blog post about SRP
40
Simple, Isn’t It?

41
Q&A

42
Eyal Golan
43

More Related Content

What's hot

SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesSamuel Breed
 
S.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software ArchitectsS.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software Architects
Ricardo Wilkins
 
Introduction to SOLID Principles
Introduction to SOLID PrinciplesIntroduction to SOLID Principles
Introduction to SOLID Principles
Ganesh Samarthyam
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
NexThoughts Technologies
 
Open Close Principle
Open Close PrincipleOpen Close Principle
Open Close Principle
Thaichor Seng
 
Learning solid principles using c#
Learning solid principles using c#Learning solid principles using c#
Learning solid principles using c#
Aditya Kumar Rajan
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
Giovanni Scerra ☃
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLID
Pranalee Rokde
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
BADR
 
SOLID Design Principles applied in Java
SOLID Design Principles applied in JavaSOLID Design Principles applied in Java
SOLID Design Principles applied in Java
Ionut Bilica
 
Dependency injection presentation
Dependency injection presentationDependency injection presentation
Dependency injection presentation
Ahasanul Kalam Akib
 
What is Dependency Injection in Spring Boot | Edureka
What is Dependency Injection in Spring Boot | EdurekaWhat is Dependency Injection in Spring Boot | Edureka
What is Dependency Injection in Spring Boot | Edureka
Edureka!
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin Fowler
Igor Crvenov
 
Single Responsibility Principle @ Clean Code Alliance Meetup
Single Responsibility Principle @ Clean Code Alliance MeetupSingle Responsibility Principle @ Clean Code Alliance Meetup
Single Responsibility Principle @ Clean Code Alliance Meetup
Eyal Golan
 
SOLID & IoC Principles
SOLID & IoC PrinciplesSOLID & IoC Principles
SOLID & IoC Principles
Pavlo Hodysh
 
SOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principlesSOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principlesSergey Karpushin
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
kim.mens
 
Dependency Inversion Principle
Dependency Inversion PrincipleDependency Inversion Principle
Dependency Inversion Principle
Shahriar Hyder
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
Sandeep Chawla
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1
Shahzad
 

What's hot (20)

SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
S.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software ArchitectsS.O.L.I.D. Principles for Software Architects
S.O.L.I.D. Principles for Software Architects
 
Introduction to SOLID Principles
Introduction to SOLID PrinciplesIntroduction to SOLID Principles
Introduction to SOLID Principles
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Open Close Principle
Open Close PrincipleOpen Close Principle
Open Close Principle
 
Learning solid principles using c#
Learning solid principles using c#Learning solid principles using c#
Learning solid principles using c#
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Design principles - SOLID
Design principles - SOLIDDesign principles - SOLID
Design principles - SOLID
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
 
SOLID Design Principles applied in Java
SOLID Design Principles applied in JavaSOLID Design Principles applied in Java
SOLID Design Principles applied in Java
 
Dependency injection presentation
Dependency injection presentationDependency injection presentation
Dependency injection presentation
 
What is Dependency Injection in Spring Boot | Edureka
What is Dependency Injection in Spring Boot | EdurekaWhat is Dependency Injection in Spring Boot | Edureka
What is Dependency Injection in Spring Boot | Edureka
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin Fowler
 
Single Responsibility Principle @ Clean Code Alliance Meetup
Single Responsibility Principle @ Clean Code Alliance MeetupSingle Responsibility Principle @ Clean Code Alliance Meetup
Single Responsibility Principle @ Clean Code Alliance Meetup
 
SOLID & IoC Principles
SOLID & IoC PrinciplesSOLID & IoC Principles
SOLID & IoC Principles
 
SOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principlesSOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principles
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Dependency Inversion Principle
Dependency Inversion PrincipleDependency Inversion Principle
Dependency Inversion Principle
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1
 

Viewers also liked

SOLID principles
SOLID principlesSOLID principles
SOLID principles
Dmitry Kandalov
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
Deddy Setyadi
 
[CEFET][ESw] Aula 5 - Diagrama de Classe
[CEFET][ESw] Aula 5 - Diagrama de Classe[CEFET][ESw] Aula 5 - Diagrama de Classe
[CEFET][ESw] Aula 5 - Diagrama de Classe
Universidade Federal de Minas Gerais
 
Implementing The Open/Closed Principle
Implementing The Open/Closed PrincipleImplementing The Open/Closed Principle
Implementing The Open/Closed PrincipleSam Hennessy
 
物件導向設計原則:SOLID + DI
物件導向設計原則:SOLID + DI物件導向設計原則:SOLID + DI
物件導向設計原則:SOLID + DI
Jeff Chu
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo design
Confiz
 
PHP in the Real World
PHP in the Real WorldPHP in the Real World
PHP in the Real World
Ivo Jansch
 

Viewers also liked (7)

SOLID principles
SOLID principlesSOLID principles
SOLID principles
 
Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
 
[CEFET][ESw] Aula 5 - Diagrama de Classe
[CEFET][ESw] Aula 5 - Diagrama de Classe[CEFET][ESw] Aula 5 - Diagrama de Classe
[CEFET][ESw] Aula 5 - Diagrama de Classe
 
Implementing The Open/Closed Principle
Implementing The Open/Closed PrincipleImplementing The Open/Closed Principle
Implementing The Open/Closed Principle
 
物件導向設計原則:SOLID + DI
物件導向設計原則:SOLID + DI物件導向設計原則:SOLID + DI
物件導向設計原則:SOLID + DI
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo design
 
PHP in the Real World
PHP in the Real WorldPHP in the Real World
PHP in the Real World
 

Similar to Single Responsibility Principle

Code qualities and practices to achieve them
Code qualities and practices to achieve themCode qualities and practices to achieve them
Code qualities and practices to achieve them
Remus Langu
 
Birth of a developer
Birth of a developerBirth of a developer
Birth of a developer
Piyush Rahate
 
Object Oriented Programming Ch3 SRP, DIP, ISP
Object Oriented Programming Ch3 SRP, DIP, ISPObject Oriented Programming Ch3 SRP, DIP, ISP
Object Oriented Programming Ch3 SRP, DIP, ISP
Chihyang Li
 
The Dependency Injection - Sorin Damian, Software Developer@RomSoft
The Dependency Injection - Sorin Damian, Software Developer@RomSoftThe Dependency Injection - Sorin Damian, Software Developer@RomSoft
The Dependency Injection - Sorin Damian, Software Developer@RomSoftRomSoft SRL
 
Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1
Julie Iskander
 
"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design Principles"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design PrinciplesSerhiy Oplakanets
 
S.O.L.I.D xp
S.O.L.I.D xpS.O.L.I.D xp
S.O.L.I.D xp
XP Conference India
 
Writing S.O.L.I.D Code
Writing S.O.L.I.D CodeWriting S.O.L.I.D Code
Writing S.O.L.I.D Code
Rajeev Bharshetty
 
Solid as OOP abstraction
Solid as OOP abstractionSolid as OOP abstraction
Solid as OOP abstraction
Pawel Klimczyk
 
Apply SOLID Design principles to javascript code with immediate function invo...
Apply SOLID Design principles to javascript code with immediate function invo...Apply SOLID Design principles to javascript code with immediate function invo...
Apply SOLID Design principles to javascript code with immediate function invo...
Anuradha Bandara
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentation
Bhavin Gandhi
 
Is your code SOLID enough?
 Is your code SOLID enough? Is your code SOLID enough?
Is your code SOLID enough?
SARCCOM
 
2009 training - tim m - object oriented programming
2009   training - tim m - object oriented programming2009   training - tim m - object oriented programming
2009 training - tim m - object oriented programming
Tim Mahy
 
Improving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design PrinciplesImproving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design Principles
Dr. Syed Hassan Amin
 
Clean code
Clean codeClean code
Clean code
Simon Sönnby
 
Solid principles
Solid principlesSolid principles
Solid principles
Kumaresh Chandra Baruri
 
Intro to event sourcing and CQRS
Intro to event sourcing and CQRS Intro to event sourcing and CQRS
Intro to event sourcing and CQRS
Savvas Kleanthous
 
Rebuilding Legacy Apps with Domain-Driven Design - Lessons learned
Rebuilding Legacy Apps with Domain-Driven Design - Lessons learnedRebuilding Legacy Apps with Domain-Driven Design - Lessons learned
Rebuilding Legacy Apps with Domain-Driven Design - Lessons learned
Kacper Gunia
 
Growing Software and Growing Ourselves
Growing Software and Growing OurselvesGrowing Software and Growing Ourselves
Growing Software and Growing Ourselves
Daniel Parkin
 

Similar to Single Responsibility Principle (20)

Code qualities and practices to achieve them
Code qualities and practices to achieve themCode qualities and practices to achieve them
Code qualities and practices to achieve them
 
Birth of a developer
Birth of a developerBirth of a developer
Birth of a developer
 
Object Oriented Programming Ch3 SRP, DIP, ISP
Object Oriented Programming Ch3 SRP, DIP, ISPObject Oriented Programming Ch3 SRP, DIP, ISP
Object Oriented Programming Ch3 SRP, DIP, ISP
 
The Dependency Injection - Sorin Damian, Software Developer@RomSoft
The Dependency Injection - Sorin Damian, Software Developer@RomSoftThe Dependency Injection - Sorin Damian, Software Developer@RomSoft
The Dependency Injection - Sorin Damian, Software Developer@RomSoft
 
Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1
 
"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design Principles"SOLID" Object Oriented Design Principles
"SOLID" Object Oriented Design Principles
 
S.O.L.I.D xp
S.O.L.I.D xpS.O.L.I.D xp
S.O.L.I.D xp
 
Writing S.O.L.I.D Code
Writing S.O.L.I.D CodeWriting S.O.L.I.D Code
Writing S.O.L.I.D Code
 
Solid as OOP abstraction
Solid as OOP abstractionSolid as OOP abstraction
Solid as OOP abstraction
 
Apply SOLID Design principles to javascript code with immediate function invo...
Apply SOLID Design principles to javascript code with immediate function invo...Apply SOLID Design principles to javascript code with immediate function invo...
Apply SOLID Design principles to javascript code with immediate function invo...
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentation
 
Is your code SOLID enough?
 Is your code SOLID enough? Is your code SOLID enough?
Is your code SOLID enough?
 
2009 training - tim m - object oriented programming
2009   training - tim m - object oriented programming2009   training - tim m - object oriented programming
2009 training - tim m - object oriented programming
 
Improving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design PrinciplesImproving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design Principles
 
Clean code
Clean codeClean code
Clean code
 
Solid principles
Solid principlesSolid principles
Solid principles
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
Intro to event sourcing and CQRS
Intro to event sourcing and CQRS Intro to event sourcing and CQRS
Intro to event sourcing and CQRS
 
Rebuilding Legacy Apps with Domain-Driven Design - Lessons learned
Rebuilding Legacy Apps with Domain-Driven Design - Lessons learnedRebuilding Legacy Apps with Domain-Driven Design - Lessons learned
Rebuilding Legacy Apps with Domain-Driven Design - Lessons learned
 
Growing Software and Growing Ourselves
Growing Software and Growing OurselvesGrowing Software and Growing Ourselves
Growing Software and Growing Ourselves
 

Recently uploaded

FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 

Single Responsibility Principle

Editor's Notes

  1. And more…Not only SRP but some technics around it
  2. SOLID Principle as a part of good OOD
  3. SOLID was introduced by Robert C. Martin – Uncle BobThis are PRINCIPLES !
  4. SRP – We’ll discuss in more details in following slides
  5. OCPAn entity can allow its behavior to be modified without altering its source codeNew or changed features would require that a different class be createdExample: if shape is circle the area = … else if shape is square then area = …
  6. LSPIf S is a subtype of T, then objects of type T may be replaced with objects of type SNew derived classes just extend without replacing the functionality of old classes.Square class that derives from a Rectangle classIf a Square object is used in a context where a Rectangle is expected, unexpected behavior may occur because the dimensions of a Square cannot (or rather should not) be modified independently
  7. ISPSmall and specific interfacesClient should not be depend upon an interface it does not need ISPstates that no client should be forced to depend on methods it does not useISP is intended to keep a system decoupled
  8. While developing, code for interfaces and not concreteI find that TDD really helps me achieve that
  9. At each level of the system, we need to take care that any component has one responsibilitySymbol of “everything”
  10. 7+-2: Limits on Our Capacity for Processing Information Cognitive psychologist: George A. Mille
  11. When we were young we ordered our room like the pictureOur parents taught us betterOur experience taught us even better
  12. Change due needs of C might break B.
  13. Refactoring is much easier for a single responsibility module
  14. You will usually end up with longer, more precise name for your classes
  15. Simpler tests for simple code
  16. We’re going to see some hints (smell) of breaking the SRPBy structure and then by behavior of the code
  17. A class should be longer than 200-250 LOC as a rule of thumb
  18. Some tips on how to develop in order to apply the SRPMost of them will move you towards more OOD / SOLID principles
  19. This is a general tip for being craftsman and professional
  20. TDD will show when a class does too muchThe code which is designed by TDD will usually evolve to code that holds many principles
  21. Enough said. Let’s finish !
  22. If you can’t find a focused name (and handler / manager are not focused), try to make the module more focused
  23. Refactorrefactorrefactor
  24. OOD , Clean Code, Better practice – SRP is helping to achieve them
  25. I chose simple items to show how they things can be extremely good when doing just one thing (+SMS)