SlideShare a Scribd company logo
SOLID
Single Responsibility Principle
           Open/Closed Principle

                       Dennis van der Stelt               Pascal de Jonge
                          Software Architect            Development Lead
                                      Tellus                         Tellus
      http://bloggingabout.net/blogs/dennis/   http://www.pazquality.com/
                                  @dvdstelt                   @pdejonge
                        dvdstelt@tellus.com           pdejonge@tellus.com




                                                    Software Development Network 2013
Software Development Network 2013
AGENDA




         Software Development Network 2013
SOLID
History




          Software Development Network 2013
Guidance




   Software Development Network 2013
SOLID
Five principles




       Single Responsibility                        SOLID                   Open/Closed




        Liskov Substitution                 Interface Seggregation      Dependency Inversion




     Learn them, love them, live by them…




                                                                     Software Development Network 2013
Software Craftsmanship
is really, really, ridiculously good looking code


                                            Software Development Network 2013
SOLID
Books




        Software Development Network 2013
SOLID
Single Responsibility Principle




                                  Software Development Network 2013
SINGLE RESPONSIBILITY PRINCIPLE




                 there should never be more than
                 one reason for a class to change




                                  Software Development Network 2013
SINGLE RESPONSIBILITY PRINCIPLE




 just because you can, doesn’t mean you should

                                  Software Development Network 2013
SINGLE RESPONSIBILITY PRINCIPLE


Rules that apply to classes
 rule                                            rule   same goes for methods,
           they should be small                         which we count by #
01                                               03     lines
 rule                                            rule
           they should be smaller                       how to measure class
02         than that                             04     size?


        Responsibility : “a reason for change”




                                                              Software Development Network 2013
SINGLE RESPONSIBILITY PRINCIPLE
Why would we want to separate responsibilities?




                                                  Software Development Network 2013
SINGLE RESPONSIBILITY PRINCIPLE
Why would we want to separate responsibilities?




                                                  Software Development Network 2013
SINGLE RESPONSIBILITY PRINCIPLE

Sometimes hard to see…
interface IModem
{
    void Dial(string phoneNumber);
    void Hangup();
    void Send(char c);
    char Receive();
}




                                     Software Development Network 2013
SINGLE RESPONSIBILITY PRINCIPLE
 public interface IConnection
 {
     void Dial(string phoneNumber);
     void Hangup();
 }


 public interface IDataChannel
 {
     void Send(char c);
     char Receive();
 }


 public class Modem
 {
     public Modem(IConnection connection, IDataChannel dataChannel)
     {
         // ...
     }
 }


                                                                 Software Development Network 2013
SINGLE RESPONSIBILITY PRINCIPLE

                     Rule of thumb
             If you can’t come up with a
  name for your class, it’s probably doing too much!




                                        Software Development Network 2013
DEMO
InvoiceCreator




                 Software Development Network 2013
SINGLE RESPONSIBILITY PRINCIPLE
 Violation


• God class unneeded complexity
  Don’t create
• However
   public class OrderService
  {
      public   Order Get(int orderId) { }
      public   Order Get(string name) { }
      public   Order Save(Order order) { }
      public   Order SubmitOrder(Order order) { }
      public   void CancelOrder(Order order) { }
      public   void ProcessOrderReturn(int orderId) { }
      public   void ShipOrder(Order order) { }
  }


                                               Software Development Network 2013
more classes != more
      complex




                       Software Development Network 2013
Software Development Network 2013
SOLID
Open/Closed Principle




                        Software Development Network 2013
OPEN/CLOSED PRINCIPLE




               software entities should be open for
                    extension, but closed for
                          modification




                                 Software Development Network 2013
OPEN/CLOSED PRINCIPLE
Non changed code doesn’t need new…




                                     Software Development Network 2013
DEMO
Useful patterns




                  Software Development Network 2013
TEMPLATE METHOD PATTERN



           AbstractBase class
 Program          Initialize
               SendMessage
                  Finalize
                  Execute

           EmailSende
           r

               SendMessage




                                Software Development Network 2013
Software Development Network 2013
CONCLUSION




  Single Responsibility           SOLID                   Open/Closed




   Liskov Substitution    Interface Seggregation      Dependency Inversion




                                                   Software Development Network 2013
Thank you
                                            questions?

                 Dennis van der Stelt               Pascal de Jonge
                    Software Architect            Development Lead
                                Tellus                         Tellus
http://bloggingabout.net/blogs/dennis/   http://www.pazquality.com/
                            @dvdstelt                   @pdejonge
                  dvdstelt@tellus.com           pdejonge@tellus.com




                                                                        33
                                              Software Development Network 2013

More Related Content

PPTX
Object Oriented Design SOLID Principles
PPTX
SOLID Principles of Refactoring Presentation - Inland Empire User Group
PDF
Introduction to SOLID Principles
PDF
Solid Principle
PDF
SOLID Design principles
ODP
Geecon09: SOLID Design Principles
PPT
The OO Design Principles
PDF
Solid principles of oo design
Object Oriented Design SOLID Principles
SOLID Principles of Refactoring Presentation - Inland Empire User Group
Introduction to SOLID Principles
Solid Principle
SOLID Design principles
Geecon09: SOLID Design Principles
The OO Design Principles
Solid principles of oo design

What's hot (20)

PDF
SOLID Design Principles applied in Java
PDF
Object Oriented Design Principles
KEY
SOLID Design Principles
PPTX
Learning solid principles using c#
PPTX
Writing Maintainable Software Using SOLID Principles
PPT
3.o o design -_____________lecture 3
PPTX
S.O.L.I.D. Principles for Software Architects
PPT
Principle of OOD
PDF
Introduction to Object Oriented Design
PDF
Refactoring for Software Design Smells
PPTX
Refactoring Applications using SOLID Principles
PPTX
IoC and Mapper in C#
PPTX
Solid principles
KEY
"SOLID" Object Oriented Design Principles
PDF
The Open Closed Principle - Part 1 - The Original Version
PPT
Design poo my_jug_en_ppt
PDF
Applying Design Principles in Practice
PPTX
CodeCamp Iasi 10 march 2012 - Scratching-SOLID
PPT
Design Smells
ODP
Principles of Object Oriented Design
SOLID Design Principles applied in Java
Object Oriented Design Principles
SOLID Design Principles
Learning solid principles using c#
Writing Maintainable Software Using SOLID Principles
3.o o design -_____________lecture 3
S.O.L.I.D. Principles for Software Architects
Principle of OOD
Introduction to Object Oriented Design
Refactoring for Software Design Smells
Refactoring Applications using SOLID Principles
IoC and Mapper in C#
Solid principles
"SOLID" Object Oriented Design Principles
The Open Closed Principle - Part 1 - The Original Version
Design poo my_jug_en_ppt
Applying Design Principles in Practice
CodeCamp Iasi 10 march 2012 - Scratching-SOLID
Design Smells
Principles of Object Oriented Design
Ad

Viewers also liked (20)

PPTX
Open Closed Principle kata
PPTX
Dependency Inversion Principle
PPTX
SOLID Principles part 2
PPT
Smolen Alex Securing The Mvc Architecture Part Two
PPTX
Solid principles
ODP
Open Close Principle
PDF
jeas_0816_4883
PDF
[Webinar] Refatoração em PHP
PPTX
Implementing The Open/Closed Principle
PPTX
The Style of C++ 11
PPTX
Idiomatic C++
PDF
Distributed Systems Design
PPT
STL ALGORITHMS
PPT
Operator overloading
PPTX
Improving The Quality of Existing Software
PPT
C++ Advanced
PPTX
Web Service Basics and NWS Setup
PPTX
Bjarne Stroustrup - The Essence of C++: With Examples in C++84, C++98, C++11,...
PPTX
SOLID principles
PPT
Operator overloading
Open Closed Principle kata
Dependency Inversion Principle
SOLID Principles part 2
Smolen Alex Securing The Mvc Architecture Part Two
Solid principles
Open Close Principle
jeas_0816_4883
[Webinar] Refatoração em PHP
Implementing The Open/Closed Principle
The Style of C++ 11
Idiomatic C++
Distributed Systems Design
STL ALGORITHMS
Operator overloading
Improving The Quality of Existing Software
C++ Advanced
Web Service Basics and NWS Setup
Bjarne Stroustrup - The Essence of C++: With Examples in C++84, C++98, C++11,...
SOLID principles
Operator overloading
Ad

Similar to SOLID Principles part 1 (20)

PDF
ElizabethPrattConsulting_DellPortfolio
PPTX
JDXA, The KISS ORM for Android
PPTX
It’s All About Developers. Discover Cisco DevNet. - Jason Goecke - Codemotion...
PDF
Are You a SOLID Coder?
PDF
Curious Coders Java Web Frameworks Comparison
PDF
Create first android app with MVVM Architecture
PPTX
Applying DevOps, PaaS and cloud for better citizen service outcomes - IBM Fe...
PDF
From desktop to the cloud, cutting costs with Virtual kubelet and ACI
PDF
GDSC NIET ORIENTATION ).pdf
PPTX
.NET Architecture for Enterprises
PDF
JAVA Magazine Sep-Oct 2013
PDF
Pense fora da caixa: Aplique Agilidade com Domain Driven Design. Você ainda u...
PPTX
Dependency Injection, Design Principles and Patterns
PDF
Deploy Angular to the Cloud
ODP
Intro to Open Cloud Initiative
PDF
Clean Architecture
PPT
bGenius kennissessie_20120510
PPTX
Gdsc lbce offline accelerator meet -1
PDF
CampDevOps keynote - DevOps: Using 'Lean' to eliminate Bottlenecks
PDF
JavaOne 2015: 14 Key Lessons, you should learn
ElizabethPrattConsulting_DellPortfolio
JDXA, The KISS ORM for Android
It’s All About Developers. Discover Cisco DevNet. - Jason Goecke - Codemotion...
Are You a SOLID Coder?
Curious Coders Java Web Frameworks Comparison
Create first android app with MVVM Architecture
Applying DevOps, PaaS and cloud for better citizen service outcomes - IBM Fe...
From desktop to the cloud, cutting costs with Virtual kubelet and ACI
GDSC NIET ORIENTATION ).pdf
.NET Architecture for Enterprises
JAVA Magazine Sep-Oct 2013
Pense fora da caixa: Aplique Agilidade com Domain Driven Design. Você ainda u...
Dependency Injection, Design Principles and Patterns
Deploy Angular to the Cloud
Intro to Open Cloud Initiative
Clean Architecture
bGenius kennissessie_20120510
Gdsc lbce offline accelerator meet -1
CampDevOps keynote - DevOps: Using 'Lean' to eliminate Bottlenecks
JavaOne 2015: 14 Key Lessons, you should learn

More from Dennis van der Stelt (16)

PDF
Change your architecture during deployment
PDF
Dealing with eventual consistency
PDF
Dealing with eventual consistency
PDF
Death of the batch job
PDF
Death of the batch job - NServiceBus Sagas
PDF
Distributed Systems Principles
PDF
Building reliable applications with messaging
PDF
Distributed Systems principles
PDF
Een andere kijk op Microservices
PDF
Duplicating data or replicating data in Micro Services
PDF
LIDNUG : Reliable applications with messaging
PPTX
Silverlight & WCF RIA
PPTX
Test Driven Development
PPTX
AppFabric Velocity
PPTX
Continuous integration
PPTX
App fabric introduction
Change your architecture during deployment
Dealing with eventual consistency
Dealing with eventual consistency
Death of the batch job
Death of the batch job - NServiceBus Sagas
Distributed Systems Principles
Building reliable applications with messaging
Distributed Systems principles
Een andere kijk op Microservices
Duplicating data or replicating data in Micro Services
LIDNUG : Reliable applications with messaging
Silverlight & WCF RIA
Test Driven Development
AppFabric Velocity
Continuous integration
App fabric introduction

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
August Patch Tuesday
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
WOOl fibre morphology and structure.pdf for textiles
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
project resource management chapter-09.pdf
Approach and Philosophy of On baking technology
Chapter 5: Probability Theory and Statistics
cloud_computing_Infrastucture_as_cloud_p
gpt5_lecture_notes_comprehensive_20250812015547.pdf
A novel scalable deep ensemble learning framework for big data classification...
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
August Patch Tuesday
Digital-Transformation-Roadmap-for-Companies.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
WOOl fibre morphology and structure.pdf for textiles
Group 1 Presentation -Planning and Decision Making .pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Heart disease approach using modified random forest and particle swarm optimi...
MIND Revenue Release Quarter 2 2025 Press Release
A comparative study of natural language inference in Swahili using monolingua...
Encapsulation_ Review paper, used for researhc scholars
Building Integrated photovoltaic BIPV_UPV.pdf
project resource management chapter-09.pdf

SOLID Principles part 1

  • 1. SOLID Single Responsibility Principle Open/Closed Principle Dennis van der Stelt Pascal de Jonge Software Architect Development Lead Tellus Tellus http://bloggingabout.net/blogs/dennis/ http://www.pazquality.com/ @dvdstelt @pdejonge dvdstelt@tellus.com pdejonge@tellus.com Software Development Network 2013
  • 3. AGENDA Software Development Network 2013
  • 4. SOLID History Software Development Network 2013
  • 5. Guidance Software Development Network 2013
  • 6. SOLID Five principles Single Responsibility SOLID Open/Closed Liskov Substitution Interface Seggregation Dependency Inversion Learn them, love them, live by them… Software Development Network 2013
  • 7. Software Craftsmanship is really, really, ridiculously good looking code Software Development Network 2013
  • 8. SOLID Books Software Development Network 2013
  • 9. SOLID Single Responsibility Principle Software Development Network 2013
  • 10. SINGLE RESPONSIBILITY PRINCIPLE there should never be more than one reason for a class to change Software Development Network 2013
  • 11. SINGLE RESPONSIBILITY PRINCIPLE just because you can, doesn’t mean you should Software Development Network 2013
  • 12. SINGLE RESPONSIBILITY PRINCIPLE Rules that apply to classes rule rule same goes for methods, they should be small which we count by # 01 03 lines rule rule they should be smaller how to measure class 02 than that 04 size? Responsibility : “a reason for change” Software Development Network 2013
  • 13. SINGLE RESPONSIBILITY PRINCIPLE Why would we want to separate responsibilities? Software Development Network 2013
  • 14. SINGLE RESPONSIBILITY PRINCIPLE Why would we want to separate responsibilities? Software Development Network 2013
  • 15. SINGLE RESPONSIBILITY PRINCIPLE Sometimes hard to see… interface IModem { void Dial(string phoneNumber); void Hangup(); void Send(char c); char Receive(); } Software Development Network 2013
  • 16. SINGLE RESPONSIBILITY PRINCIPLE public interface IConnection { void Dial(string phoneNumber); void Hangup(); } public interface IDataChannel { void Send(char c); char Receive(); } public class Modem { public Modem(IConnection connection, IDataChannel dataChannel) { // ... } } Software Development Network 2013
  • 17. SINGLE RESPONSIBILITY PRINCIPLE Rule of thumb If you can’t come up with a name for your class, it’s probably doing too much! Software Development Network 2013
  • 18. DEMO InvoiceCreator Software Development Network 2013
  • 19. SINGLE RESPONSIBILITY PRINCIPLE Violation • God class unneeded complexity Don’t create • However public class OrderService { public Order Get(int orderId) { } public Order Get(string name) { } public Order Save(Order order) { } public Order SubmitOrder(Order order) { } public void CancelOrder(Order order) { } public void ProcessOrderReturn(int orderId) { } public void ShipOrder(Order order) { } } Software Development Network 2013
  • 20. more classes != more complex Software Development Network 2013
  • 22. SOLID Open/Closed Principle Software Development Network 2013
  • 23. OPEN/CLOSED PRINCIPLE software entities should be open for extension, but closed for modification Software Development Network 2013
  • 24. OPEN/CLOSED PRINCIPLE Non changed code doesn’t need new… Software Development Network 2013
  • 25. DEMO Useful patterns Software Development Network 2013
  • 26. TEMPLATE METHOD PATTERN AbstractBase class Program Initialize SendMessage Finalize Execute EmailSende r SendMessage Software Development Network 2013
  • 28. CONCLUSION Single Responsibility SOLID Open/Closed Liskov Substitution Interface Seggregation Dependency Inversion Software Development Network 2013
  • 29. Thank you questions? Dennis van der Stelt Pascal de Jonge Software Architect Development Lead Tellus Tellus http://bloggingabout.net/blogs/dennis/ http://www.pazquality.com/ @dvdstelt @pdejonge dvdstelt@tellus.com pdejonge@tellus.com 33 Software Development Network 2013

Editor's Notes

  • #4: There are other talks that will go into Big Data and Hadoop so we’ll only do a quick overview of that right now. We’ll spend most of our time on Hive.
  • #5: 5 basic principles of OOPDIntroduced in 2000By Robert C. Martin (Uncle Bob)Whenapplied, more likelyto have a bettermaintainableandextendable system over time.
  • #6: Guidelines, not hard rules, not a dogmaUse common senseDon’tjustthrowthemaway
  • #14: Major problem, as we have toinclude GUI related .dll’stoourGeometryService, but it NEVER uses these.
  • #15: Major problem, as we have toinclude GUI related .dll’stoourGeometryService, but it NEVER uses these.
  • #16: What is wrong with this modem interface?Answer :Connection & Data Transfer are combined
  • #17: What is wrong with this modem interface?Answer :Connection & Data Transfer are combined
  • #21: Don’tcreatedunneededcomplexityHowever, more classes != more complexityThis is supposedto make your life easier!But noteasiertobelazy
  • #22: Classes are organized, as top left pictureNot chaos, like bottom right picture
  • #24: What do you like more?Changing other people’s code?Or writing new code?
  • #25: OCPExisting code should not be edited when new functionality is added, because…don’tneedto re-test working code;don’tneed new code reviews;don’tneedtoexamindependent code
  • #28: Some examples of organizations that delivering new value based in the form of revenue growth, cost savings or creating entirely new business models.Yahoo - AS with Hive, Klout - AS with Hive (white paper), GE - Hive AnalyticsYahoo! (Gartner BI Excellence Award Winner) is driving growth for existing revenue streams:Yahoo! manages a powerful, scalable advertising exchange that includes publishers and advertisers.Advertisers want to get the most out of their investment by reaching their targeted audiences effectively and efficiently.Yahoo! needs visibility into how consumers are responding to ads alongmany dimensions (websites, creative, time of day, gender, age, location) to make the exchangework as efficiently and effectivelyas possible.Yahoo! doubled its revenue by allowing campaign managers to “tune” campaign targeting and creative.Yahoo! drove an increase in spending from advertisers since they got better performance by advertising through Yahoo!.Yahoo! TAO exposed customer segment performance to campaign managers and advertisers for the first time.Klout is creating new businesses and revenue streams:Klout’s mission is to help everyone understand and leverage their influence. Klout uses Big Data to unify the social web (consumers, brands, and partners) with social networking and activity, along with data to generate a Klout score and enable analysis, targeting, and social graphs.Helps consumers manage their “social brand.”Helps brands reach influencers at scale.Helps data partners enhance their services (customer loyalty, CRM, media and identity, and marketing). For example, the Palms uses Klout scores in addition to their normal customer rewards program to determine whether or not to upgrade their customers to a better room during their stay. The Huffington Post uses Klout to help serve the best curated Twitter content.Klout Case Study: http://www.microsoft.com/casestudies/Microsoft-SQL-Server-2012-Enterprise/Klout/Data-Services-Firm-Uses-Microsoft-BI-and-Hadoop-to-Boost-Insight-into-Big-Data/710000000129Case Study on Thailand’s Department of Special Investigations : http://www.microsoft.com/casestudies/Microsoft-SQL-Server-2012-Enterprise/Department-of-Special-Investigation/Thai-Law-Enforcement-Agency-Optimizes-Investigations-with-Big-Data-Solution/710000001175 GE is driving operational efficiencies:GE is running several use cases on its Hadoop cluster while incorporating several different disparate sources to produce results. Along with sentiment analysis, GE is running web analytics on its internal cloud structure and looking at load usage, user analytics, and failure mode analytics. GE built a recommendation engine for its intranet involving various press releases users might be interested in based on their function, user profiles, and prior visits to its site. GE is working with several types of remote monitoring and diagnostic data from energy and wind businesses.
  • #29: Big data is often described as problems that have one or more of the 3 (or 4) Vs – volume, velocity, variety, variability. Think about big data when you describe a problem with terms like tame the chaos, reduce the complexity, explore, I don’t know what I don’t know, unknown unknowns, unstructured, changing quickly, too much for what my environment can handle now, unused data.Volume = more data than the current environment can handle with vertical scaling, need to make sure of data that it is currently too expensive to useVelocity = Small decision window compared to data change rate, ask how quickly you need to analyze and how quickly data arrivesVariety = many different formats that are expensive to integrate, probably from many data sources/feedsVariability = many possible interpretations of the data
  • #30: Append only, bulk data operations