Codementor Events

Design Principles For Balanced Coding

Published Feb 07, 2019
Design Principles For Balanced Coding

Below are the design principles that Every developer should know while implementing,designing and reviewing any code:

** SINGLE RESPONSIBILITY PRINCIPLE **
Every object should have a single responsibility and all its services should be aligned to that responsibility.
SwissArmyKnife.jpg

Things that change together can be put together.

** LISKOV SUBSTITUTION PRINCIPLE **
If it looks like a duck, quack like a duck but needs batteries,you probably have the wrong Abstraction.
duck1.png

In class hierarchies,We should be able to treat a specialized object as if it were a base class object.

** DON'T REPEAT YOURSELF(DRY) **
Repetition is the root for all software evil.DRY is a principle aimed at reducing repetition of information of all kinds.
dry.png

Just don't repeat the code that you/somebody have already written.Try to re use the same existing code.

** FAVOUR COMPOSITION OVER INHERITANCE **
Inheritance is the most abused concept.
composition.jpeg

Classes should achieve polymorphic behavior and code reuse by their composition (by containing instances of other classes that implement the desired functionality) rather than inheritance from a base or parent class.

** INTERFACE SEGREGATION **
Tailor Interfaces to individual client's need.
InterfaceSegregation.jpg

Clients should not be forced to depend upon interfaces they don't use.

** YOU AREN'T GONNA NEED IT **
Don't waste your resources on what you think you might need.
You-Arent-Gonna-Need-It-Oct-2013-300x300.png

Solve tomorrow's problem tomorrow, it should be good for now design.

** KEEP IT SIMPLE STUPID (KISS) **
“If you can’t explain it to a six year old, you don’t understand it well enough"
--Albert Einstein
kiss.jpg

Discover and read more posts from Udit Rastogi
get started