This is the 38th Step towards gaining the Programming Enlightenment series. If you didn’t learn the 38th Step, read it.
Less is more. It’s a trite maxim, and most of the times it really is true.
Why less is more?
Wouldn’t say it always is the case, but more lines of code means more chances of introducing bugs.
- You’ve got less code to test and debug.
- By trying to reduce the lines, we find some ingenious ways to tackle the problem.
if(x > 1){
return true;
} else {
return false;
}Alternativelyreturn (x > 1)? true : false; // Pretty concise
How to practice less is more?
- Write code because it adds value, not because it amuses you.
- Follow YAGNI vehemently.
- Write, re-write, refactor, do self code-review before committing it.
- Just because there is new component in the programming language, one shouldn’t try to use it, unless, the use case isn’t satisfied by the current case or it removes some bugs.
TL;DR Write, re-write and self Code-Review, you can always improve the code.
Go to 38th Step
Go to the 40th Step.
References:
- 97 things Every Programmer Should Know ~ Git Book
- 97 Things Every Programmer Should Know ~ Paperback