I'm trying to memorize design patterns as best as I can.
I understood the best way is to see where design patterns being used in the Java API.
Can someone provide me other Java API examples of the command pattern other than classics like Java Swing and the Runnable
interface?
Description on wiki is here
Important Points on Command Pattern
Command Pattern in Java API
Implementations of java.lang.Runnable and javax.swing.Action follows command design pattern , and as @Dave Newton said
They're pretty good examples
.Then you don't need to find out another much better examples in the java api .Example
I have an example about using runnable with swing. In the code below Runnable object (command) is send to a method as argument and can be invoked at any time.
Summary
The command pattern is a powerful and flexible design idiom, commonly used in Graphical User Interface design to handle events and commands issued by a user. Design patterns are intended to allow greater modularity when designing programs, reducing the dependencies placed on any given block of code.
Practise Exercise
Using the command pattern , Create a small app which simulates a simple calculator, with operations such as add, subtract and multiply.