hi all, I have a question about the use of Context in Strategy Pattern, could anyone tell me what's the benefits of using the Context other than use a concrete strategy directly?
In the above code InterfaceAlgorithm
interface common to all supported algorithm classes Algorithm1
. Class Context
is configured with different algorithm object either object of Algorithm1
class or Algorithm2
class and maintains a reference to InterfaceAlgorithm
type class. Advantage
Scalability of J2EE components which uses this pattern.Developing application as J2EE component makes it pluggable and portable. With regards to the type of bean to be used used in J2EE component, it is going to depend upon the situation.
We need to come up with some code on this! Drawbacks
- Adds communication overhead between objects.
- Increased number of objects.
Hope this helps,
PS : I am working on some J2EE code based on Strategy Pattern.Will post it as soon as I am done with it.
[This message has been edited by Desai Sandeep (edited June 22, 2001).][/qb]
[ August 11, 2004: Message edited by: Jacky Chow ]