Skip to content
Go to file
Cannot retrieve contributors at this time
49 lines (28 sloc) 1.23 KB

Programming principles (SOLID)

SOLID Principles

Single Responsibility Principle

  • Do one thing and do it well.
  • Short and focused methods, small and focused classes.

Open Closed Principle

  • Be open for extension and closed for modification.

Liskov Substitution Principle

  • Derived classes can stand in for base classes.
  • Replacing an object with an instance of a subtype shouldn't alter the correctness of a program.

Interface Segregation Principle

  • Make interfaces fine grained and client specific.
  • Expose only those things that you absolutely have to.
  • Many client-specific interfaces are better than one general-purpose interface.

Dependency Inversion

  • Depend on abstractions, not concrete implementations.

Other Principles

Don't Repeat Yourself (DRY)

  • Clipboard inheritance is an anti-pattern.

The Boy Scout Principle

  • Clean up after yourself, clean up after others.
  • For instance, add some unit tests if there are none.

You Ain't Gonna Need It (YAGNI)

  • Focus on current actual requirements.

Separation Of Concerns

  • Focusing one's attention upon some aspect.
  • For instance, don't mix your UI and your database logic all together.
  • (Similar to Single Responsibility Principle).