aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Proxy Vs Decorative pattern 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 "Proxy Vs Decorative pattern" Watch "Proxy Vs Decorative pattern" New topic
Author

Proxy Vs Decorative pattern

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1368
What is the difference between Proxy pattern and Decorative pattern ?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
The intent.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
unni krishna
Ranch Hand

Joined: Jul 14, 2004
Posts: 39
Proxy is a creational pattern, that means, it is used for creating objects.
It is used when creating a new object is costly. In such cases we make a copy of the existing object. See Java Cloneable interface and clone method for more details.

Decorator pattern comes under structural patterns. The decorator pattern helps to add behavior or responsibilities to an object. This is also called �Wrapper�.


Software Engineer (SCJP)<br />USTechnology, CA
Arnold Reuser
Ranch Hand

Joined: Nov 20, 2003
Posts: 194
The Decorator Pattern is also known as the Wrapper pattern.
The purpose of this pattern is to add additional responsibilities to an object. These responsibilities can ofcourse be added through inheritence.
But because of the lack of flexibility a better way is to use composition, aka Wrapping aka the Decorator Pattern.
So the decorator pattern is about adding responsibilities through defining a new class, that wraps the old class, and adds the new responsibilities.

The Proxy Pattern is also known as the Surrogate pattern.
The purpose of this pattern is to add an intermediate between the client and the target object. This intermediate shares the same interface as the target object. The confusing part is that a Proxy also uses composition as the Decorator pattern does. But the proxy pattern doesn't add new responsibilities. It is just a surrogate of the object.

If i didn't make myself clear, please ask for more detail.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Proxy Vs Decorative pattern
 
Similar Threads
Decorator Pattern
deisgn patternbusiness delegate and Proxy pattern
Another 'Y' game
Proxy pattern
Question on Proxy pattern..