A cheatsheet of programming principles

As I continue my career as a software engineer I hear these principles everywhere I go. In this article, I wanna list them down. I think these principles are quite well known and you might know some or all of them.

For example, Dan Abramov is proposing in this article not to be too DRY and try to be WET sometimes. Where he points out that writing wrong abstracting is worse than no abstraction.

We as developers, like to hear these phrases and write abstractions to keep our codebase clean. But sometimes we also like to stick to them a bit too much and in the end we over complicate stuff.

DRY

  • don't repeat yourself (or DIE → Duplication of Evil)
  • this principle is aimed to reduce code repetition
  • This could be applicable to daily life as if you find something that you are doing all over again then you should automate it.
  • Dan abramov is proposing not to be too DRY and be WET sometimes

KISS

  • Keep It Simple Stupid
  • Sometimes we like to complicate things which leads to over-engineering things

SOLID

acronym referring to the SOLID Principles of class design that were popularized by Robert C. Martin.

  • Single responsibility
    • Each function or class shoud be doing one thing only
  • Open–closed
    • entities should be open for extension, but closed for modification
  • Liskov substitution
    • Subtypes must be substitutable for their base types
  • Interface segregation (ISP)
  • Dependency inversion
    • Hight level modules should not be depended on lower modules. Both shall depend on abstractions
    • Abstraction shall not depend on details. Details shall depend on abstractins

YAGNI

  • You ain’t gonna need it
  • If it is not required don't do it → focus only on important things