CSC/ECE 517 Fall 2012/ch2b 2w40 sn: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
== Introduction to Command Pattern ==
= Introduction to Command Pattern =
The command pattern is one of the most used behavioral design patterns. The main concept of the pattern is an object which can be used to represent and encapsulate all the information needed to call a method at a later time. This information includes the method name, the object that owns the method and values for the method parameters.
The command pattern is one of the most used behavioral design patterns. The main concept of the pattern is an object which can be used to represent and encapsulate all the information needed to call a method at a later time. This information includes the method name, the object that owns the method and values for the method parameters.


Line 8: Line 8:
# allows the parametrization of clients with different requests
# allows the parametrization of clients with different requests
# allows saving the requests in a queue
# allows saving the requests in a queue
= A Java Example =
== A Java Example ==


=== Real life applications ===
== Real life applications ==


== Chain of Responsibility ==
= Chain of Responsibility =


=== Comparison with Command Pattern ===
== Comparison with Command Pattern ==
=== Real life applications ===
== Real life applications ==


== Memento ==
= Memento =
== Comparison with Command Pattern ==
== Real life applications ==


=== Comparison with Command Pattern ===
= Strategy =
=== Real life applications ===


== Strategy ==
== Comparison with Command Pattern ==
== Real life applications ==


=== Comparison with Command Pattern ===
= Conclusion =
=== Real life applications ===
== Advantages and Disadvantages ==
 
== Conclusion ==
=== Advantages and Disadvantages ===

Revision as of 02:04, 17 November 2012

Introduction to Command Pattern

The command pattern is one of the most used behavioral design patterns. The main concept of the pattern is an object which can be used to represent and encapsulate all the information needed to call a method at a later time. This information includes the method name, the object that owns the method and values for the method parameters.

The command pattern has been often associated with these terms client, invoker and receiver. The client instantiates the command object and provides the information required to call the method at a later time. The invoker decides when the method should be called. The receiver is an instance of the class that contains the method's code.

The intent of the Command pattern can be listed as:

  1. encapsulate a request in an object
  2. allows the parametrization of clients with different requests
  3. allows saving the requests in a queue

A Java Example

Real life applications

Chain of Responsibility

Comparison with Command Pattern

Real life applications

Memento

Comparison with Command Pattern

Real life applications

Strategy

Comparison with Command Pattern

Real life applications

Conclusion

Advantages and Disadvantages