Thursday, November 24, 2011

Great Example of Open Closed Design Principle in Java

Great Example of Open Closed Design Principle
I am big fan of design pattern article and love to read articles on design patterns and recently wrote about decorator design pattern in Java. Today I come across this good article on open closed design pattern, what I like most is there example and clear way of explanation, first example is true value and it will help you understand open closed principle very quickly and second example is also not bad.

open closed design principle exampleOne word about Open Closed principle is a design principle which says that a class should be open for extension but closed for modification. 

Benefit or Open Closed Design Principle:
1) Application will be more robust because we are not changing already tested class.
2) Flexible because we can easily accommodate new requirements.
3) Easy to test and less error prone.

How to make code extensible
Basic principle of making your code extensible and following open closed principle is providing object to class at run time and making use of polymorphism to invoke extended functionality.
If functionality is hard Coded than it wouldn’t be extensible but if you write interface and provide implementation of that interface at run time you make it extensible.


For detailed example see this link open closed design pattern on sanaulla blog.

Interview Questions you may like

Do you like Books?
If you love to read books here are few Java titles which is worth of money :
Please vote +1 or consider sharing if your like this article

10 comments:

jaylen watkins said...

Java is evergreen applications. It has good future. the Interview Questionsrelated to java are big help to its aspirants.

Anonymous said...

Blogs by Country

Anonymous said...

Blogs Directory

Anonymous said...

link directory

Anonymous said...

Blogpedia

Anonymous said...

Blogging Critic

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

Anonymous said...

Blog Directory

Anonymous said...
This comment has been removed by a blog administrator.

Post a Comment

What is this blog about

This blog is about my experience in Java, Tibco Rendezvous and FIX protocol. FIX is a technology which is used to build equity trading system and heavily used in electronic trading , high frequency trading and Algorithmic trading, so on most of Investment bank job you need to know FIX Protocol on the other hand Tibco Rendezvous is used to implement messaging backbone on many big commercial and global banks. This blog help you to get clear any FIX protocol job interview. It also includes Java and Tibco Rendezvous article written for new user mainly my experience in my own word.