DEV Community

Cover image for What Are The Best Software Engineering Principles?

What Are The Best Software Engineering Principles?

luminousmen on January 20, 2019

Software Development Principles — it is a number of specific rules and recommendations, which engineers need to be followed during program implemen...
Collapse
 
fpuffer profile image
Frank Puffer

I agree that every developer should know these principles.

But it is at least as important to know that it is impossible to fully comply with all of these principles in practice. Especially when overdoing one of them, it is likely that you violate others.

One example: When applying DRY, you need to build abstractions, like moving the duplicate code to a function. This is fine to a certain extent but when you overdo it, the code will get harder to understand and violates the KISS principle.

Some of the principles are also highly subjective, for example SRP. During development, do you really know what a single resposibility is? Do you know which parts of the code are likely to change independently and which won't? Most of us are much worse than we think at predicting the future and that's where YAGNI comes from.

So in reality it is not that easy. Learning and obeying these principles will not automatically make you produce better code. You need to find a good compromise and that's much harder.

Collapse
 
romstar profile image
Rami

I agree with your comment completely. Even following Solid to the T can create overly complex code depending on the problem you're trying to solve, e.g. Business layer complemented with a repository layer and code bleed through.

Collapse
 
patzistar profile image
Patrick Schadler

Agree with all of them, but I would also add seperation of concerns as one of them.

Collapse
 
w3bist profile image
Webist

Here is my contribution

  • Declaring "abstract" classes is completely useless.
  • Composition over inheritance everywhere. With this you don't have to worry about Liskov principle, Cohesion.
  • Class is a bad word to build a communicating object. It should be named Cell. Assume that way.

Many more, but time is up for now.

Collapse
 
leightondarkins profile image
Leighton Darkins

As a person who spends a great deal of time evangelizing SOLID in particular, I totally agree.

Overly strict adherence to principles is just as bad as having no principles at all.

Collapse
 
codemouse92 profile image
Jason C. McDonald
Collapse
 
rachelsoderberg profile image
Rachel Soderberg

This is a fantastic list... I'm going to print it out and put it up in my cubicle when I get to work in the morning. <3

Collapse
 
luminousmen profile image
luminousmen

Thank you that means a lot

Collapse
 
twisted_code profile image
Twisted_Code

I was at first confused by the image for SOLID because I wasn't sure what "single repository principle" was supposed to mean.