Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question on Decorator pattern

Status
Not open for further replies.

dragonwell

Programmer
Oct 21, 2002
863
0
0
US
In all examples of the Decorator pattern I've seen, for example :
the functionality being extended is on a method with a void return type. So it's easy to see how one could add additional functionality before or after passing the execution along to the decorated object. But I am wondering about methods that have a return type. Is it common to decorate methods with return types?

PreProcessing would be the same, but what about afterwards? It seems you would need to hold on to the return value of the decorated method if you wanted to add postprocessing.

For example:
Code:
public Customer GetCustomer(long customerID){
  Customer toReturn = this.decoratedObject.GetCustomer(customerID);

  //do my post processing here....

  return toReturn;

}

I haven't seen that in any examples and wonder if I am not understanding the pattern, or if there is a better way.

Thanks

[blue]_______________________________________[/blue]
 
Looks like a good book...
Thanks

[blue]_______________________________________[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top