SlideShare a Scribd company logo
1 of 4
Download to read offline
Articles from Jinal Desai
Software Design Principles
2012-05-03 19:05:33 Jinal Desai

There are many design principles that have become best practices over the years. Using these principles
we can develop scalable and maintainable enterprise application with time tested approaches.

   1. Keep It Simple Stupid (KISS)

       The main goal here is keep things simple. Avoiding unnecessary complexity will help to keep it clear
       and easy to understand. Also this principle will help in maintenance; if it is simple then also easy to
       modify. Usually the simplest solution is the best solution.

   2. Don’t Repeat Yourself (DRY)

       This principle states to not repeat things. We can abstract out repeated things and keep it at some
       common place where everybody can access it. We can also make common (repeating) things as
       general, so that it is available to all.

   3. Separation of Concerns (SoC)

       Separating things into discrete responsibilities increases reusability, maintenance and also
       testability. Here concerns refer to specific features or behavior of the system.

       For example, Object Oriented programming languages such as C++, C# and Java (to name a few)
       can separate concerns into objects. A Design Pattern like MVC (Model-View-Controller) can
       separate content from presentation and data processing (model) from content. Service Oriented
       design can separate concerns into services. Procedural programming languages such as C can
       separate concerns into procedures. Aspect Oriented programming languages can separate
       concerns into aspects and objects.

   4. The Pareto Principle

       The famous pareto principle states that 80% of effects comes from 20% of causes, i.e. 80% of
       sales comes from 20% of customers. The principle is named after Italian economist Vilfredo
       Pareto, who observed in 1906 that 80% of land in Italy is owned by 20% of the population. It can help
       to resist efforts to correct and optimize designs beyond critical 20%. So 80% focus is on 20% part
       of the stuff.

       In software engineering Pareto principle can be applied to optimization efforts. For example,
       Microsoft noted that by fixing the top 20% of the most reported bugs, 80% of the errors and crashes
       would be eliminated.

   5. The Robustness Principle

       The Robustness Principle states that, “Be liberal in what you accept, and be conservative in what
       you send”. In other words, code that sends commands or data to other parts of the system should
       conform completely to the specifications, but code that receives input should accept non-
       conformant input as long as the meaning is clear.

       For example, TCP implementation follows the principle.

   6. You Ain’t Gonna Need It (YAGNI)

       It is the principle in extreme programming, states that programmers should not add functionality
       until it is necessary. It tells programmers that always implement things when you actually need
       them, never when you just foresee that you need them. Even if you are sure that you will need it
       later on, do not implement it now. The principle is actually emerged from “Extreme Programming”
       methodologies.
7. Loose Coupling and High Cohesion

  Coupling means links between separate units of a program. In OOPs, if two classes depend closely
  on many details of each other, we say they are tightly coupled.

  Coupling is a measure of the interdependence between types/entities. If every object has a
  reference to every other object, then there is tight coupling, which is undesirable. Because there’s
  potentially too much information flow between objects. Loose coupling is desirable. It means that
  objects work more independently of each other. Loose coupling minimizes the “ripple effect” where
  changes in one class cause necessity for changes in other classes

  Cohesion refers to the number and diversity of tasks that a class is designed for. If a class is
  responsible for a few related logical tasks, we say it has high cohesion.

  Cohesion is a measurement of strengths of the association of variables and methods within a
  class. High cohesion is desirable because it means the class does one job well. Low cohesion is
  undesirable because it indicates that there are elements in the class which have little to do with
  each other. Modules whose elements are strongly and genuinely related to each other are desired.
  Each method should also be highly cohesive. Most methods have only one function to perform.
  Don’t add extra instructions into methods that cause it to perform more than one function

  Loose Coupling has following advantages:

        We can understand concerned class without reading other classes
        We can change one class without affecting other classes
        Loose Coupling improves maintainability

  High Cohesion has following advantages:

        We can easily understand what is the purpose of class or method
        High Cohesion makes it easier to use descriptive names
        We can easily reuse classes or methods

8. SOLID Principles
       Single Responsibility Principle (SRP)

        The Principle states that every object should have single responsibility, and the responsibility
        (reason to change) should be entirely encapsulated by the class. So a class or module
        should have one and only one reason to change.

        For example, we have a print report module. There are utmost two reasons to change the
        module. First is content of report is changed. Second is format of report is changed.

        Open Closed Principle (OCP)

        Software entities (i.e. classes, functions or modules) should be open for extension but closed
        for modification. Normally we close entities modification for providing backward compatibility
        (regression testing) and open entities extension for extending existing entities with new
        functionalities.

        For example, we can implement this principle by using Abstract classes, and thus enforcing
        concrete classes extend abstract classes rather than changing it. Some of the design
        patterns that supports this principle is template pattern and strategy pattern.

        In .NET Framework Microsoft has further supported this principle by providing partial
        classes/methods and extension methods. You can extend existing code by using these two
        new features in .NET.

        Liskov’s Substitution Principle (LSP)

        The principle states that derived types must be completely substitutable for their base types.
        It is just an extension of Open Closed Principle in terms of behavior. Meaning that the derived
        types must extend without changing behavior of base types, so that derived types is
replaceable with base types (No need to change code).

           For example, we have method called StoreAddress(Address address) which accepts type
           “Address” as input parameter and stores it into the data store. Now if we make derived type
           from the “Address” type named “HomeAddress” then I should be able to call the same
           method by passing type “HomeAddress” and it stores correctly into the data store.

           Interface Segregation Principle (ISP)

           In nutshell, the principle states that “Clients should not be forced to depend upon interfaces
           that they don’t use”. When we simplify it states that when interface is too heavy, just break it
           down to the smaller and more specific interfaces which is client oriented so that clients
           should only worry about their concerned part.

           For example if we have <> interface which has “fly()” method and is implemented by Duck
           class. Now if we have wooden duck?

           Dependency Inversion Principle (DIP) [also known as Inversion of Control or
           Hollywood Principle: Don’t call us, we’ll call you or Dependency Injection]

           The Dependency Inversion principle refers to specific form of decoupling where conventional
           dependency relationship established from high level. The principle states two things.

              1. High-level modules should not depend on low-level modules. Both should depend on
                 abstractions.
              2. Abstractions should not depend upon details. Details should depend upon abstractions.

           The main goal of dependency inversion principle is to decouple high-level components from
           low-level components in such a manner that reuse of low-level component implementations
           become possible.

           For example Adapter Pattern does the same thing. The high-level class defines its own
           adapter interface which is the abstraction that the high-level class depends on. The adaptee
           implementation also depends on the adapter interface abstraction. The high-level has no
           dependency to the low-level module since it only uses low-level indirectly through the adapter
           interface by working polymorphic methods to the interface which are implemented by the
           adaptee and its low-level module.

References
http://www.objectmentor.com/resources/articles/dip.pdf
http://www.oodesign.com/dependency-inversion-principle.html
http://www.oodesign.com/design-principles.html
https://www-01.ibm.com/software/ucd/designconcepts/designbasics.html
http://en.wikipedia.org


          Blog this!

          Bookmark on Delicious

          Digg this post

          Recommend on Facebook

          Share on FriendFeed

          Share on Linkedin

          Share on Orkut

          share via Reddit
Share with Stumblers

Share on technorati

Tweet about it

Subscribe to the comments on this post

More Related Content

What's hot

Ood and solid principles
Ood and solid principlesOod and solid principles
Ood and solid principlesAvinash Kadam
 
Learning solid principles using c#
Learning solid principles using c#Learning solid principles using c#
Learning solid principles using c#Aditya Kumar Rajan
 
SAD05 - Encapsulation
SAD05 - EncapsulationSAD05 - Encapsulation
SAD05 - EncapsulationMichael Heron
 
OO design principle
OO design principleOO design principle
OO design principleLi-Wei Cheng
 
SOLID Design Principles applied in Java
SOLID Design Principles applied in JavaSOLID Design Principles applied in Java
SOLID Design Principles applied in JavaIonut Bilica
 
Is your code solid
Is your code solidIs your code solid
Is your code solidNathan Gloyn
 
Open Close Principle
Open Close PrincipleOpen Close Principle
Open Close PrincipleThaichor Seng
 
25 java tough interview questions
25 java tough interview questions25 java tough interview questions
25 java tough interview questionsArun Banotra
 
Java design patterns
Java design patternsJava design patterns
Java design patternsShawn Brito
 
The Solid Principles
The Solid PrinciplesThe Solid Principles
The Solid PrinciplesLuke Smith
 
Dependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsDependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsJuan Lopez
 
Java day2016 "Reinventing design patterns with java 8"
Java day2016 "Reinventing design patterns with java 8"Java day2016 "Reinventing design patterns with java 8"
Java day2016 "Reinventing design patterns with java 8"Alexander Pashynskiy
 
Geecon09: SOLID Design Principles
Geecon09: SOLID Design PrinciplesGeecon09: SOLID Design Principles
Geecon09: SOLID Design PrinciplesBruno Bossola
 

What's hot (17)

Principle of OOD
Principle of OODPrinciple of OOD
Principle of OOD
 
Ood and solid principles
Ood and solid principlesOod and solid principles
Ood and solid principles
 
Strategy Pattern
Strategy PatternStrategy Pattern
Strategy Pattern
 
Learning solid principles using c#
Learning solid principles using c#Learning solid principles using c#
Learning solid principles using c#
 
SAD05 - Encapsulation
SAD05 - EncapsulationSAD05 - Encapsulation
SAD05 - Encapsulation
 
OO design principle
OO design principleOO design principle
OO design principle
 
SOLID Design Principles applied in Java
SOLID Design Principles applied in JavaSOLID Design Principles applied in Java
SOLID Design Principles applied in Java
 
Is your code solid
Is your code solidIs your code solid
Is your code solid
 
Open Close Principle
Open Close PrincipleOpen Close Principle
Open Close Principle
 
25 java tough interview questions
25 java tough interview questions25 java tough interview questions
25 java tough interview questions
 
Java design patterns
Java design patternsJava design patterns
Java design patterns
 
The Solid Principles
The Solid PrinciplesThe Solid Principles
The Solid Principles
 
Dependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsDependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and Patterns
 
Clean code-v2.2
Clean code-v2.2Clean code-v2.2
Clean code-v2.2
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Java day2016 "Reinventing design patterns with java 8"
Java day2016 "Reinventing design patterns with java 8"Java day2016 "Reinventing design patterns with java 8"
Java day2016 "Reinventing design patterns with java 8"
 
Geecon09: SOLID Design Principles
Geecon09: SOLID Design PrinciplesGeecon09: SOLID Design Principles
Geecon09: SOLID Design Principles
 

Viewers also liked

Pambansang sagisag
Pambansang sagisagPambansang sagisag
Pambansang sagisagsalve1028
 
Pambansang sagisag
Pambansang sagisagPambansang sagisag
Pambansang sagisagsalve1028
 
Pambansang sagisag
Pambansang sagisagPambansang sagisag
Pambansang sagisagsalve1028
 
Algunas ideas sobre la ética profesional
Algunas ideas sobre la ética profesionalAlgunas ideas sobre la ética profesional
Algunas ideas sobre la ética profesionalJose Luis Espinosa
 
Energy-Efficient Virtual Machines Placement - SBRC2014
Energy-Efficient Virtual Machines Placement - SBRC2014Energy-Efficient Virtual Machines Placement - SBRC2014
Energy-Efficient Virtual Machines Placement - SBRC2014vonpupp
 
Basic design pattern interview questions
Basic design pattern interview questionsBasic design pattern interview questions
Basic design pattern interview questionsjinaldesailive
 
Pambansang sagisag
Pambansang sagisagPambansang sagisag
Pambansang sagisagsalve1028
 

Viewers also liked (8)

Pambansang sagisag
Pambansang sagisagPambansang sagisag
Pambansang sagisag
 
Pambansang sagisag
Pambansang sagisagPambansang sagisag
Pambansang sagisag
 
Pambansang sagisag
Pambansang sagisagPambansang sagisag
Pambansang sagisag
 
Algunas ideas sobre la ética profesional
Algunas ideas sobre la ética profesionalAlgunas ideas sobre la ética profesional
Algunas ideas sobre la ética profesional
 
Energy-Efficient Virtual Machines Placement - SBRC2014
Energy-Efficient Virtual Machines Placement - SBRC2014Energy-Efficient Virtual Machines Placement - SBRC2014
Energy-Efficient Virtual Machines Placement - SBRC2014
 
Basic design pattern interview questions
Basic design pattern interview questionsBasic design pattern interview questions
Basic design pattern interview questions
 
Turnip
TurnipTurnip
Turnip
 
Pambansang sagisag
Pambansang sagisagPambansang sagisag
Pambansang sagisag
 

Similar to Software design principles - jinal desai

Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principlesrainynovember12
 
Design Principles to design Patterns
Design Principles to design PatternsDesign Principles to design Patterns
Design Principles to design PatternsFaizan Haider
 
An ultimate guide to SOLID Principles, developers must know.
An ultimate guide to SOLID Principles, developers must know.An ultimate guide to SOLID Principles, developers must know.
An ultimate guide to SOLID Principles, developers must know.ONE BCG
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionKnoldus Inc.
 
Inversion of Control
Inversion of ControlInversion of Control
Inversion of ControlShuhab Tariq
 
Solid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven DesignSolid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven DesignIrwansyah Irwansyah
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principlesdeonpmeyer
 
Nina Grantcharova - Approach to Separation of Concerns via Design Patterns
Nina Grantcharova - Approach to Separation of Concerns via Design PatternsNina Grantcharova - Approach to Separation of Concerns via Design Patterns
Nina Grantcharova - Approach to Separation of Concerns via Design Patternsiasaglobal
 
Design patterns fast track
Design patterns fast trackDesign patterns fast track
Design patterns fast trackBinu Bhasuran
 
Solid Principles, for better cohesion and lower coupling
Solid Principles, for better cohesion and lower coupling Solid Principles, for better cohesion and lower coupling
Solid Principles, for better cohesion and lower coupling Mohammad Shawahneh
 
SOLID Principles and The Clean Architecture
SOLID Principles and The Clean ArchitectureSOLID Principles and The Clean Architecture
SOLID Principles and The Clean ArchitectureMohamed Galal
 
Clean Code .Net Cheetsheets
Clean Code .Net CheetsheetsClean Code .Net Cheetsheets
Clean Code .Net CheetsheetsNikitaGoncharuk1
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_pptagnes_crepet
 
Top 30 Technical interview questions
Top 30 Technical interview questionsTop 30 Technical interview questions
Top 30 Technical interview questionsSohailSaifi15
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and DesignDr. C.V. Suresh Babu
 
The Clean Architecture
The Clean ArchitectureThe Clean Architecture
The Clean ArchitectureDmytro Turskyi
 
Tech challenges in a large scale agile project
Tech challenges in a large scale agile projectTech challenges in a large scale agile project
Tech challenges in a large scale agile projectHarald Soevik
 

Similar to Software design principles - jinal desai (20)

Object Oriented Design SOLID Principles
Object Oriented Design SOLID PrinciplesObject Oriented Design SOLID Principles
Object Oriented Design SOLID Principles
 
Design Principles to design Patterns
Design Principles to design PatternsDesign Principles to design Patterns
Design Principles to design Patterns
 
Solid
SolidSolid
Solid
 
An ultimate guide to SOLID Principles, developers must know.
An ultimate guide to SOLID Principles, developers must know.An ultimate guide to SOLID Principles, developers must know.
An ultimate guide to SOLID Principles, developers must know.
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test Automaion
 
Inversion of Control
Inversion of ControlInversion of Control
Inversion of Control
 
Solid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven DesignSolid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven Design
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
 
Nina Grantcharova - Approach to Separation of Concerns via Design Patterns
Nina Grantcharova - Approach to Separation of Concerns via Design PatternsNina Grantcharova - Approach to Separation of Concerns via Design Patterns
Nina Grantcharova - Approach to Separation of Concerns via Design Patterns
 
Design patterns fast track
Design patterns fast trackDesign patterns fast track
Design patterns fast track
 
Solid Principles, for better cohesion and lower coupling
Solid Principles, for better cohesion and lower coupling Solid Principles, for better cohesion and lower coupling
Solid Principles, for better cohesion and lower coupling
 
SOLID Principles and The Clean Architecture
SOLID Principles and The Clean ArchitectureSOLID Principles and The Clean Architecture
SOLID Principles and The Clean Architecture
 
Clean Code .Net Cheetsheets
Clean Code .Net CheetsheetsClean Code .Net Cheetsheets
Clean Code .Net Cheetsheets
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_ppt
 
Top 30 Technical interview questions
Top 30 Technical interview questionsTop 30 Technical interview questions
Top 30 Technical interview questions
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
 
The Clean Architecture
The Clean ArchitectureThe Clean Architecture
The Clean Architecture
 
Tech challenges in a large scale agile project
Tech challenges in a large scale agile projectTech challenges in a large scale agile project
Tech challenges in a large scale agile project
 
Writing Quality Code
Writing Quality CodeWriting Quality Code
Writing Quality Code
 

Recently uploaded

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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 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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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...Drew Madelung
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Recently uploaded (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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 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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
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...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Software design principles - jinal desai

  • 1. Articles from Jinal Desai Software Design Principles 2012-05-03 19:05:33 Jinal Desai There are many design principles that have become best practices over the years. Using these principles we can develop scalable and maintainable enterprise application with time tested approaches. 1. Keep It Simple Stupid (KISS) The main goal here is keep things simple. Avoiding unnecessary complexity will help to keep it clear and easy to understand. Also this principle will help in maintenance; if it is simple then also easy to modify. Usually the simplest solution is the best solution. 2. Don’t Repeat Yourself (DRY) This principle states to not repeat things. We can abstract out repeated things and keep it at some common place where everybody can access it. We can also make common (repeating) things as general, so that it is available to all. 3. Separation of Concerns (SoC) Separating things into discrete responsibilities increases reusability, maintenance and also testability. Here concerns refer to specific features or behavior of the system. For example, Object Oriented programming languages such as C++, C# and Java (to name a few) can separate concerns into objects. A Design Pattern like MVC (Model-View-Controller) can separate content from presentation and data processing (model) from content. Service Oriented design can separate concerns into services. Procedural programming languages such as C can separate concerns into procedures. Aspect Oriented programming languages can separate concerns into aspects and objects. 4. The Pareto Principle The famous pareto principle states that 80% of effects comes from 20% of causes, i.e. 80% of sales comes from 20% of customers. The principle is named after Italian economist Vilfredo Pareto, who observed in 1906 that 80% of land in Italy is owned by 20% of the population. It can help to resist efforts to correct and optimize designs beyond critical 20%. So 80% focus is on 20% part of the stuff. In software engineering Pareto principle can be applied to optimization efforts. For example, Microsoft noted that by fixing the top 20% of the most reported bugs, 80% of the errors and crashes would be eliminated. 5. The Robustness Principle The Robustness Principle states that, “Be liberal in what you accept, and be conservative in what you send”. In other words, code that sends commands or data to other parts of the system should conform completely to the specifications, but code that receives input should accept non- conformant input as long as the meaning is clear. For example, TCP implementation follows the principle. 6. You Ain’t Gonna Need It (YAGNI) It is the principle in extreme programming, states that programmers should not add functionality until it is necessary. It tells programmers that always implement things when you actually need them, never when you just foresee that you need them. Even if you are sure that you will need it later on, do not implement it now. The principle is actually emerged from “Extreme Programming” methodologies.
  • 2. 7. Loose Coupling and High Cohesion Coupling means links between separate units of a program. In OOPs, if two classes depend closely on many details of each other, we say they are tightly coupled. Coupling is a measure of the interdependence between types/entities. If every object has a reference to every other object, then there is tight coupling, which is undesirable. Because there’s potentially too much information flow between objects. Loose coupling is desirable. It means that objects work more independently of each other. Loose coupling minimizes the “ripple effect” where changes in one class cause necessity for changes in other classes Cohesion refers to the number and diversity of tasks that a class is designed for. If a class is responsible for a few related logical tasks, we say it has high cohesion. Cohesion is a measurement of strengths of the association of variables and methods within a class. High cohesion is desirable because it means the class does one job well. Low cohesion is undesirable because it indicates that there are elements in the class which have little to do with each other. Modules whose elements are strongly and genuinely related to each other are desired. Each method should also be highly cohesive. Most methods have only one function to perform. Don’t add extra instructions into methods that cause it to perform more than one function Loose Coupling has following advantages: We can understand concerned class without reading other classes We can change one class without affecting other classes Loose Coupling improves maintainability High Cohesion has following advantages: We can easily understand what is the purpose of class or method High Cohesion makes it easier to use descriptive names We can easily reuse classes or methods 8. SOLID Principles Single Responsibility Principle (SRP) The Principle states that every object should have single responsibility, and the responsibility (reason to change) should be entirely encapsulated by the class. So a class or module should have one and only one reason to change. For example, we have a print report module. There are utmost two reasons to change the module. First is content of report is changed. Second is format of report is changed. Open Closed Principle (OCP) Software entities (i.e. classes, functions or modules) should be open for extension but closed for modification. Normally we close entities modification for providing backward compatibility (regression testing) and open entities extension for extending existing entities with new functionalities. For example, we can implement this principle by using Abstract classes, and thus enforcing concrete classes extend abstract classes rather than changing it. Some of the design patterns that supports this principle is template pattern and strategy pattern. In .NET Framework Microsoft has further supported this principle by providing partial classes/methods and extension methods. You can extend existing code by using these two new features in .NET. Liskov’s Substitution Principle (LSP) The principle states that derived types must be completely substitutable for their base types. It is just an extension of Open Closed Principle in terms of behavior. Meaning that the derived types must extend without changing behavior of base types, so that derived types is
  • 3. replaceable with base types (No need to change code). For example, we have method called StoreAddress(Address address) which accepts type “Address” as input parameter and stores it into the data store. Now if we make derived type from the “Address” type named “HomeAddress” then I should be able to call the same method by passing type “HomeAddress” and it stores correctly into the data store. Interface Segregation Principle (ISP) In nutshell, the principle states that “Clients should not be forced to depend upon interfaces that they don’t use”. When we simplify it states that when interface is too heavy, just break it down to the smaller and more specific interfaces which is client oriented so that clients should only worry about their concerned part. For example if we have <> interface which has “fly()” method and is implemented by Duck class. Now if we have wooden duck? Dependency Inversion Principle (DIP) [also known as Inversion of Control or Hollywood Principle: Don’t call us, we’ll call you or Dependency Injection] The Dependency Inversion principle refers to specific form of decoupling where conventional dependency relationship established from high level. The principle states two things. 1. High-level modules should not depend on low-level modules. Both should depend on abstractions. 2. Abstractions should not depend upon details. Details should depend upon abstractions. The main goal of dependency inversion principle is to decouple high-level components from low-level components in such a manner that reuse of low-level component implementations become possible. For example Adapter Pattern does the same thing. The high-level class defines its own adapter interface which is the abstraction that the high-level class depends on. The adaptee implementation also depends on the adapter interface abstraction. The high-level has no dependency to the low-level module since it only uses low-level indirectly through the adapter interface by working polymorphic methods to the interface which are implemented by the adaptee and its low-level module. References http://www.objectmentor.com/resources/articles/dip.pdf http://www.oodesign.com/dependency-inversion-principle.html http://www.oodesign.com/design-principles.html https://www-01.ibm.com/software/ucd/designconcepts/designbasics.html http://en.wikipedia.org Blog this! Bookmark on Delicious Digg this post Recommend on Facebook Share on FriendFeed Share on Linkedin Share on Orkut share via Reddit
  • 4. Share with Stumblers Share on technorati Tweet about it Subscribe to the comments on this post