-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Design Patterns and Best Practices in Java
By :
One of the most important things to do in object-oriented programming is to adopt a design that lets us decouple the code. For example, let's imagine that we need to develop a complex application in which we can draw graphic shapes: points, lines, segments, circles, rectangles, and many more.
Along with the code to draw all kinds of shapes, we need to implement many operations to handle the menu operations. In order to make our application maintainable, we are going to create a unified way to define all those commands in such a way that it will hide the implementation details from the rest of the application (which plays the client role).
The command pattern does the following:
The class diagram of the command pattern is as follows:

We can distinguish the following actors in the preceding...