Hi,
Recently i encountered one question about design
patterns.
The question is can you think of any design pattern which motivated use of comparator. Well i thought for a while then i replied "Decorator Pattern".
My logic behind this answer is that "Decorator Pattern" is used to decorate a single object in different ways by using different decorator still maintaining the object functionality the same.
When we use Comparator we don's change the object but we just change the way they get used for e.g. In Sort i can pass different comparator and can have the method or API show different result but the functionality is same its still sorting just using a different way.
Now the big question is AM I CORRECT?
Please shed some light on your thoughts on my answer.
Thanks,
Prabhat
SCJP 1.5, SCWCD 1.5, SCBCD 1.5