aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Give me example of Decorater Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Give me example of Decorater" Watch "Give me example of Decorater" New topic
Author

Give me example of Decorater

Umair Uddin
Greenhorn

Joined: Sep 12, 2001
Posts: 14
please some body give me the example of Decorater.
Umair Uddin
------------------
narasimha reddy
Greenhorn

Joined: Nov 24, 2001
Posts: 13
1)
The best example can be I/O streams in java.
Normally whenever u create input or output stream, you will create bufferstream by passing the create I/O stream as parameter so that additional functionality to the stream can be provided by bufferstream.
ex.. new BufferInputStream(new InputStream(new File())).....
2) In AWT, all the decorations to the components(say borders etc) are provided through Decorator Pattern.
I hope now you got better idea about how decorator pattern works.


Narasimha Reddy<BR>---------------<BR>Sun certified Enterprise architect(Part-I)<BR>Sun Certified Web Component Developer<BR>IBM Certified in OOAD with UML<BR>IBM Certified in enterprise connectivity test<BR>Oracle Certified in SQL and PL/SQL.<BR>Sun Certified Java2 Programmer
Alan Shalloway
Ranch Hand

Joined: Sep 26, 2001
Posts: 60
This is a good example. You can see more on this in Bruce Eckel's free electronic book- Thinking in Java, 2nd Ed. Go to http://www.mindview.net/Books/TIJ/ He describes how Java's I/O is controlled with the decorator.

------------------
Alan Shalloway.
Look for Jim Trott and my book: Design Patterns Explained
Visit our site Net Objectives.
Visit our Design Patterns Explained Community of Practice
Check out our CDROM based audio training in XML


Alan Shalloway.<BR>Look for Jim Trott and my book: <A HREF="http://www.amazon.com/exec/obidos/ASIN/0201715945/ref=ase_electricporkchop/103-0514572-3811868" TARGET=_blank rel="nofollow">Design Patterns Explained</A><BR>Visit our site <A HREF="http://www.netobjectives.com" TARGET=_blank rel="nofollow">Net Objectives</A>.<BR>Visit our <A HREF="http://www.netobjectives.com/dpexplained/index.html" TARGET=_blank rel="nofollow">Design Patterns Explained Community of Practice</A><BR>Check out our <A HREF="http://www.netobjectives.com/xml/xml_cdrom_info.htm" TARGET=_blank rel="nofollow">CDROM based audio training in XML</A>
Jim Baiter
Ranch Hand

Joined: Jan 05, 2001
Posts: 532
There's also some interesting stuff on the Wiki patterns site:
http://wiki.cs.uiuc.edu/PatternStories/DecoratorPattern
 
Consider Paul's rocket mass heater.
 
subject: Give me example of Decorater