Principles

Software Design Principles Link to heading

  • ETC (Easy to Change): One principle to rule them all; your code should be easy to change.
  • RTFM (Read The Friendly Manual): Just read the docs bro…
  • LOB (Locality of Behavior): The behavior of a unit of code should be as obvious as possible by looking only at that unit of code.
  • DRY (Don’t Repeat Yourself): This is more about repeating knowledge not code. You may have two identical pieces of code that fulfill different business requirements. You want to make sure that if you need to update one it does not affect the other.
  • SRP (Single Responsibility Principle): A class should have one job and only one reason to change.
  • OCP (Open-Closed Principle): Software entities should be open for extension but closed for modification.
  • LSP (Liskov Substitution Principle): Subclasses should be completely substitutable for their parent classes.
  • ISP (Interface Segregation Principle): A client should never be forced to implement an interface that it doesn’t use.
  • DIP (Dependency Inversion Principle): Entities must depend on abstractions not on concretions.
  • KISS (Keep It Simple, Stupid): I call myself the SimpleDev for a reason. Simplicity is a perquisite for reliability.
  • Only When Needed: Do not abstract or implement features until they are required.
  • SoC (Separation of Concerns): Divide responsibilities to keep your code focused and clear.
  • Law of Demeter: Keep your code’s reach short—each unit should have limited knowledge and only talk to its direct friends, not strangers.
  • Composition over Inheritance: Assemble behavior from smaller parts rather than building deep class trees.
  • Command/Query Separation: A function should do something or answer something not both

Naming Conventions Link to heading

  • Class: Noun
  • Function: Verb or Verb/Noun
  • Variable: Descriptive
    • Boolean: is/has/can/should name