Basic Programming Principles Every Programmer should Know

Hello World, will be explaining 7 different Programming principles in short enough to make you understand it.

If you want to be an effective and better programmer , then it is essential to follow these Principles of Programming !

1. KISS

Naah! I’m not talking about that Kiss !
Im talking about one of the most important principles of Programming " Keep It simple Stupid " . It means you should be writing code as simple as possible ! If you can write a code in just two lines , then why to write a paragraph in it !

2. Use DRY code

DRY : Don’t Repeat Yourself ! As its name suggests, it says not to repeat the code. It’s a common coding mistake, while coding. Avoid duplication of data or logic.
If you’ve every copied and pasted code within the same program , then it’s not a DRY code.

3. Open/closed

This principle means you should aim to make your code open to extension but closed to modification. This is an important principle when releasing a library or framework that others will use.

4. Composition over Inheritance

If you write code using objected oriented programming , then you are going to find this useful.
The composition over Inheritance principle states : objects with complex behaviour should contain instances of objects with individual behaviours. They should not inherit a class and add new behaviours !

5. Single Responsibility

Single Responsibility module says that every class or module in a program should only provide one functionality.

6. YAGNI

YAGNI stands for You are not going to need it.
This principle means you should never
Code for functionality on the chance that you may need in future. Don’t try and solve a problem that doesn’t exist.

7. Document your code

Any senior developer will stress the importance of documenting your code with proper comments . All languages offer them and you should make a habit to write them.
Leave comments to explain objects, Enhance variable definition and make functions easy to understand.

Hope you’ve read till last.
Many thanks for reading !

3 Likes

KISS is for arch buddies xD

1 Like

@Th3Director line for you

1 Like

okay… and the problem am solving? :thinking:

1 Like

urrgh leave it (-_-)

1 Like