Software Principles

Principle 1: KISS (Keep It Simple, Stupid)

The first principle on our list of the most important software engineering principles is KISS. It is an acronym for “Keep It Simple, Stupid”

Software systems work best when they are kept simple. Avoiding unnecessary complexity will make your system more robust, easier to understand, easier to reason about, and easier to extend.

It’s so obvious. But we, engineers, often tend to complicate things. We use those fancy language features that no one knows about and feel proud. We introduce countless dependencies in our project for every simple thing and end up in a dependency hell. We create endless micro-services for every simple thing.

Simple Example For KISS Principle:

// KISS Principle 

Instead of This:
console.log(Math.round(22.4)) // 22

Use this:
console.log(~~22.4) // 22

Principle 2: DRY (Don’t Repeat Yourself)

The DRY principle aims at reducing the repetition of code and effort in software systems.

It basically means that you should not write the same code/configuration in multiple places. If you do that, then you’ll have to keep them in sync; and any changes to the code at one place will require changes at other places as well.

Simple Example For Dry Principle:

// DRY Principle

Instead of this:

header p:hover,
main p:hover,
footer p:hover {
  color: red;
  cursor: pointer;
}

Use this:

:is(header, main, footer) p:hover {
  color: red;
  cursor: pointer;
}

Principle 3: YAGNI (You Aren’t Gonna Need It)

Like KISS principle, YAGNI also aims at avoiding complexity, especially the kind of complexity that arises from adding functionality that you think you may need in the future.

It states that you should not introduce things in order to solve a future problem that you don’t have right now. Always implement things when you actually need them. It will help you keep your software lean and simple. It will also save you extra money and effort.

Moreover, you may think that you need that functionality in the future. But a lot of times, you may not even need it due to the ever-changing requirements of our software world.

SOLID Principles (5 Principles):

  • SRP (Single Responsibility Principle)\

SRP (Single Responsibility Principle)
  • OCP (Open Closed Principle)

OCP (Open Closed Principle)
  • LSP (Liskov Substitution Principle)

LSP (Liskov Substitution Principle)
  • ISP (Interface Segregation Principle)

ISP (Interface Segregation Principle)
  • DIP (Dependency Inversion Principle)

DIP (Dependency Inversion Principle)

Last updated