Sunday, April 4, 2010

SOLID programming principles

In today's fast paced development who cares of following the programming principles which would enhance the performance and makes the developer's life easy in maintaining the code base.

Most of us care about the deadlines, in time deliveries but are we making sure that we follow all the stringent principles of programming?

Here comes the SOLID programming principles which should be followed during the Object Oriented Programming and Design to enhance the code base for easy maintenance and high performance. And also there would be no code smells if SOLID programming styles followed by the developers or designers.

Lets see what SOLID has for us:

S - Single responsibility principle
O - Open/Closed principle
L - Liskov substitution principle
I - Interface segregation principle
D - Dependency Injection

Though the buzz words are not catchy, if we carefully look into the internals, we already heard about these principles.

Single responsibility means that an object should be handling a single responsibility. As simple as that. For example, We have an entity Student, this entity should be handling operations pertaining to Student alone.

Open-Closed principle - This is pretty much common in Object Oriented Programming. Any framework supports this. Any class is open for extension and closed for modification.

ISP - says that generalize the interface instead of having multiple interfaces.

Liskov - This principle is known for its behavioral sub-typing. Specifies the semantic relation rather than syntactic relation.


Dependency Injection - This is a separate topic which can take hours of discussion if we start. Lets put the definition here and discuss in detail about this at a later stage or in a different post. Dependency Injection or earlier called " Inversion of Control" is the base for Spring Core and Hibernate and many more frameworks.
Dependent objects will be injected automatically by the framework ( say Spring Core, Hibernate etc) whenever the owner needs it.

So to conclude this post, I hope we realize the intention of these SOLID programming principles and religiously follow the principles.

No comments:

Post a Comment