Social Media

SOLID

  • Single responsibilty – class only has single responsibility
  • Open-closed – “software entities … should be open for extension, but closed for modification.”
  • Liskov Substitution – “objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.”
  • Interface Segregation – “many client-specific interfaces are better than one general purpose interface”
  • Dependency Inversion – “depend on abstractions. Do not depend upon concretions”

Single Responsibility

  • Single responsibility
  • Encapsulated in class
  • Makes class more robust

Open/Closed Principle

  • Implementations can be changed and multiple implementations created and polymorphically substituted
  • Inheritance from base classes
  • Existing interface closed to modification
  • New implementations must implement this interface

Liskov Substitution Principle

  • Substitutability for mutable objects
  • S subtype of T, then T can be replaced with S

Interface Segregation Principle

  • No client should be forced to depend on interfaces it does not use
  • ie you dont leave methods blank if you dont implement them. Instead use 2 interfaces

Dependency Inversion Principle

  • High-level modules should not depend on low-level modules. Both should depend on abstractions.
  • Abstractions should not depend on details. Details should depend on abstractions.

References

http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)

About the Author Martin Farrell

My name is Martin Farrell. I have almost 20 years Java experience. I specialize inthe Spring Framework and JEE. I’ve consulted to a range of businesses, and have provide Java and Spring mentoring and training. You can learn more at About or on my consultancy website Glendevon Software

follow me on:

Leave a Comment: