SOLID Principles

  1. What is a design principle?
    A basic tool or technique that when applied to designing or writing code makes that code more flexible, maintainable or extensible
  2. What does SOLID stand for
    • Single responsibility principle
    • Open/closed principle
    • Liskov substitution principle
    • Interface segregation principle
    • Dependency inversion principle
  3. Define the single responsibility principle
    The SRP states that every object should have a single responsibility and all of the object's methods are focussed on carrying out that responsibility
  4. Define the open/closed principle
    Classes should be open to extension and closed to modification
  5. When should OCP be used?
    When code makes decisions depending on type
  6. Define the dependency inversion principle
    • 1. High level modules should not depend on low level modules. Both should depend on abstractions.
    • 1. Abstractions should not depend on details. Details should depend on abstractions.
  7. Define the Liskov substitution principle
    Subtypes must be substitutable for their based types
  8. When to use delegation?
    When you want to use another class's functionality, but don't want to change the functionality
  9. Three techniques for reusing behaviour without inheritance
    • Delegation
    • Composition
    • Aggregation
  10. Define the interface segregation principle
    No client should be forced to depend on methods that it does not use
Card Set
SOLID Principles