Tuesday, November 2, 2010

Lets make it SOLID

One unfortunate aspect of working with object-oriented language is that people working with them think they are object oriented programmer just by using C#, Java etc. While design patterns do make you a better object-oriented programmer, they are also hard to learn especially when starting out. It is here that design principles come in handy. And the good thing is once you know design principles, you tend to find design patterns a natural fit into object-oriented programming.

SOLID Design Principles

Single Responsibility Principle (SRP)
SRP states that every object should only have one reason to change and a single focus of responsibility.

Open-Closed Principle (OCP)
A class should be open for extension but closed for modification.

Liskov Substitution Principle (LSP)
You should be able to use any derived class in place of a parent class and have it behave in the same manner without modification.

Interface Segregation Principle (ISP)
Clients should not be forced to depend upon interfaces that they do not use. Make fine grained interfaces that are client specific.

Dependency Inversion Principle (DIP)
Depend on abstractions, not on concrete classes.

Resources

Objectmentor has some good resources on design principles -

No comments: