KISS (Keep It Simple, Stupid)
Nobody in programming loves to debug, maintain, or make changes in complex code. It is very first principle, acronym stands for Keep It Simple, Stupid. The other famous alternate acronyms are
- Each unit should have only limited knowledge about other units: only units “closely” related to the current unit.
- Each unit should only talk to its friends; don’t talk to strangers.
- Only talk to your immediate friends.
“Keep It Simple, Stupid (KISS)“ states that most systems work best if they are kept simple rather than making it complex, so when you are writing code your solution should not be complicated that takes a lot of time and effort to understand. If your code is simple then other developers won’t face any problem understanding the code logic and they can easily proceed further with your code.
In KISS principal we neither want less nor more, we only want to have as much as is required. So always try to simplify your code using different approaches like breaking a complex problem into smaller chunks or taking out some unnecessary code you have written.
The purpose of software engineering is to reduce complexity, not to create it. -Pamela Zave
Example of KISS (Keep It Simple, Stupid)
function mul ( a, b ) {
return a*b
}
7 Common Programming Principles That Every Developer Must Follow
If we gave you half a story to continue it, how would you do that? How would you proceed further and add your storyline there?
Firstly, you need to understand the complete story, you will search for all the characters, their role in different chapters or parts of the story, which characters you need to take till the end or which one has the role only for a few chapters, you also need to understand how different parts of the story are connected to tell you what’s exactly happening in the story.
Programming is just like telling a story to a fellow programmer where variables are characters in your story some plays their role till the end and some end up in the middle, different functions are telling different parts of your story and connecting all the classes or functions in a specific order can only complete the story.
To write down the story further, you want everything in a specific order so that you can understand the story easily and continue it adding your lines from where it was left. No matter how good a coder you are, in programming, your job is not just writing code that works and give you the desired output but also writing a code that is maintainable, extensible and easy to understand so later the one who continue or maintains your project can understand it and he/she doesn’t have to go through a horror story which gives him/her a nightmare.
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -Martin Golding
Learning some programming principles and using them in your code makes you a better developer. It improves the quality of code and later adding other functionality or making changes in it becomes easier for everyone. Let’s discuss some basic principles of programming and the benefits of using it.
Table of Content
- 7 Common Programming Principles
- 1. KISS (Keep It Simple, Stupid)
- 2. DRY (Don’t Repeat Yourself )
- 3. YAGNI (You Aren’t Gonna Need It )
- 4. SOLID
- 5. Separation of Concerns (SoC):
- 6. Avoid Premature Optimization
- 7. Law of Demeter