dragonwell
Programmer
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:
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]
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]