PromleeBlog

posting thumbnail
Understanding and Applying the SOLID Principles

๐Ÿ“…

Hierarchy of Pattern Knowledge ๐Ÿ”—

  1. Design Patterns
    • Strategy Pattern
      Define a family of algorithms, encapsulate each one, and make them interchangeable.
      A client using a strategy can change that strategy while it is in use.
  2. Object-Oriented Principles
    • Encapsulate what varies.
    • Favor composition over inheritance.
    • Program to interfaces rather than implementations.
  3. Object-Oriented Basics
    • Classes and objects
    • Inheritance
    • Polymorphism
    • Encapsulation
    • Abstraction

Design Smells ๐Ÿ”—

Signs and symptoms of poor design.
NameSymptom
RigidityThe system is difficult to change. Every change triggers an endless sequence of further changes.
FragilityChanging one part of the system breaks several other, unrelated parts.
ImmobilityIt is difficult to separate the system into components that can be reused in other systems.
ViscosityViscosity is high when adding a workaround is easier than adding code that follows the design.
Needless ComplexityThere are many complicated code structures that are not needed now but might be useful someday.
Needless RepetitionThe code looks as if two programmers wrote it using copy and paste.
OpacityThe complexity of the expression creates particular difficulties in understanding the original author's intent.

Dependency Management ๐Ÿ”—

Design smells arise from
unmanaged dependencies
.
Unmanaged dependencies
Object-oriented languages provide various mechanisms for managing dependencies.

Object-Oriented Design Principles ๐Ÿ”—

  1. The SOLID principles by Robert C. Martin
  2. The GRASP principles by Craig Larman
  3. Program to interfaces rather than implementations (Interface-Oriented Programming).
  4. Favor object composition over class inheritance.
  5. Encapsulate what varies.

The SOLID principles ๐Ÿ”—

  1. S
    ingle Responsibility Principle โ€”
    SRP
  2. O
    pen-Closed Principle โ€”
    OCP
  3. L
    iskov Substitution Principle โ€”
    LSP
  4. I
    nterface Segregation Principle โ€”
    ISP
  5. D
    ependency Inversion Principle โ€”
    DIP
    Understanding and Applying the SOLID Principles | PromleeBlog