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.
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.
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.
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.
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.
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.
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