I understand that when an object recieves a request, the object can either handle it or delegate the request to another object. Does anyone has sample program for this, just a simple program will do. thanks.
I've read the article but i'm a little bit more confound with the example, sorry for asking but can you give me more simpler example or just explain its concepts and significants, i just like to see the pattern. Like when i asked, "how can i use model view controller in a simple gui which access the database" and someone answered... "well model is for accesing the database and the view is for your graphical interface and the controller will the one who'll listen to the user's action and will glue together the view and model" and that's it. I put it into practice and then it worked. I'm studying design pattern and delegation is one that i'm focusing now and the decorator design pattern. I hope this was not to much to ask. Thanks for your first reply.
Consider a iterface that every utility provider needs to implement.
Say then you have another class , someone is using it already and it's does a good job of fethcing you grocery items.
Note that this class does not implement the Utility interface you defined earlier. But it does the job! of getting you the grocery items but does'nt confine to your interface and you expect everyone to stick to your interface. So you have some options now. 1. Write a class Grocery that implements your Utility and copy the code from getGrocery method of GetGrocery class already available to you and make it work. c'd be messy. 2. Write a class Grocery that implements Utility and *delegate* the job to the GetGrocery instance