Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SOLID Fundamentals

SOLID Fundamentals

Super quick introduction to the five basic principles of object-oriented design known by the acronymn SOLID.

Slide from the 2nd florida coders user group meeting. 2014/01/08

Avatar for Michael Minton

Michael Minton

January 08, 2014
Tweet

More Decks by Michael Minton

Other Decks in Programming

Transcript

  1. It absolutely is NOT a repeatable science There is no

    answer that’s correct 100% of the time
  2. S - Single Responsibility O - Open/Closed L - Liskov

    Substituion I - Interface Segregation D - Dependency Inversion
  3. Single Responsibility a class should have only a single responsibility.

    Super simple to understand Hard to get right Avoid God classes
  4. Single Responsibility a class should have only a single responsibility.

    Super simple to understand Hard to get right Avoid God classes Many smaller classes
  5. Open/Closed software entities should be open to extension, but closed

    to modification Think virtual & overrides Don’t change your body just to change your clothes
  6. Open/Closed software entities should be open to extension, but closed

    to modification Think virtual & overrides Don’t change your body just to change your clothes Avoid switch on types
  7. Liskov Substitution objects in a program should be replaceable with

    instances of their subtypes without altering the correctness of that program
  8. Liskov Substitution objects in a program should be replaceable with

    instances of their subtypes without altering the correctness of that program demo time
  9. Interface Segregation many client-specific interfaces are better than one general-purpose

    interface Similar to SRP Don’t be afraid of interfaces Don’t force unnecessary methods