Tuesday, 14 August 2012

SOLID principles


i found this very interesting article in Solid Principles



Single Responsibility Principle

"There should never be more than one reason for a class to change." — Robert Martin, SRP paper linked from The Principles of OOD
My translation: A class should concentrate on doing one thing

Open Closed Principle

"Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification." — Robert Martin paraphrasing Bertrand Meyer, OCP paper linked from The Principles of OOD
My translation: Change a class’ behaviour using inheritance and composition


Liskov Substitution Principle

"Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it." — Robert Martin, LSP paper linked from The Principles of OOD
My translation: Subclasses should behave nicely when used in place of their base class


Interface Segregation Principle

"Clients should not be forced to depend upon interfaces that they do not use." — Robert Martin, ISP paper linked from The Principles of OOD
My translation: Keep interfaces small and cohesive




Dependency Inversion Principle

"A. High level modules should not depend upon low level modules. Both should depend upon abstractions.
B. Abstractions should not depend upon details. Details should depend upon abstractions." — Robert Martin, DIP paper linked from The Principles of OOD
My translation: Use lots of interfaces and abstractions



Extracetd from - http://davesquared.net/2009/01/introduction-to-solid-principles-of-oo.html


Cheers !!!

No comments:

Post a Comment