Every young developer gets to know the most common rules in programming quickly, either by their own research or by code review comments. Write small classes and small methods/functions. Be SOLIDDon’t Repeat YourselfKeep It Simple Stupid and a lot of other programming principles.

Today I would like to propose another way - one that may be a bit controversial in principle; let’s call it - DNIE (read as deny) unrolled to Do Not If Else.

If’s are often considered harmful. They are the source of evil and sometimes bugs. But the worst thing is that they hide abstractions.

Before we go further, I have to make an important disclaimer - I don’t want to say never ever use if or anything like that. There are cases when an if statement is the easiest, the cleanest and the most appropriate solution for a problem. E.g. I cannot imagine implementing most sorting algorithms without such construction. Unfortunately if’s are overused and often makes software harder to maintain.

#development #programming

How to become a better programmer: Do Not If Else
7.90 GEEK