Hi,
Command Pattern: Normally if you
want to communicate between two objects, then first object have a reference of
second object. First object executes a particular method in the second object. But using command pattern, first object holds
a reference of the command object instead of second object. The first object
sends the command to the command object by executing a method command object.
The command object dispatches to a specific recipient
Strategy pattern: Encapsulating each and every behavior in a separate class
is called as strategy pattern. Basically decoupling algorithms.
If an object has several different behaviors, it is much simpler to keep track
of them if each behavior is a separate class, It is
easy to add, remove, or change any of the behaviors, it is a much simpler task,
since each one is its own class
-----Original Message-----
From: An interest list for Sun
Java Center J2EE Pattern Catalog [mailto:J2EEPATTERNS-INTEREST@JAVA.SUN.COM] On Behalf Of Julia Liu
Sent:
To:
J2EEPATTERNS-INTEREST@JAVA.SUN.COM
Subject: Q about command and
strategy patterns
Hi,
What is a difference between command pattern and
strategy pattern?
Thanks
Julia Liu
![]()
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
==================================================================== Companion
Site: http://www.corej2eepatterns.com J2EE BluePrints:
http://java.sun.com/blueprints/corej2eepatterns List Archive:
http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing:
email "signoff J2EEPATTERNS-INTEREST" to listserv@java.sun.com
| This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly prohibited and may be unlawful. |