khaleel. Powered by Blogger.

Explain Decorator Design Pattern in Java

Thursday 2 June 2011

Decorator design pattern attaches additional responsibilities or functions, dynamically or statically on an object.One can add new functionalities on an object without affecting other objects enhancing flexibility of an object.

The best example of Decorator pattern in a visual manner can be illustrated from JScrollPane object which can be used to decorate a JTextArea object or a JEditorPane object. The different borders of a window like BevelBorder, CompoundBorder, EtchedBorder TitledBorder etc. are other examples of classes working as decorators existent in Java API.

Decorator pattern can be used in a non-visual fashion. For example, BufferedInputStream, DataInputStream, and CheckedInputStream are decorating objects of FilterInputStream class. These decorators are standard Java API classes.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
Promote Your Blog

About This Blog

This blog is for java lovers

Total Pageviews

About Me

khaleel-bapatla
BAPATLA, ap, India
simple and honest
View my complete profile

  © Blogger template On The Road by Ourblogtemplates.com 2009

Back to TOP