Java Reference
In-Depth Information
Mini-antipatterns: Coarse and Fine Commands
One of the primary benefits of commands is the convenient organization of
model interface points that they can provide. Commands make an easy point
of reuse for applications. With them, we can wrap a variety of different tech-
nologies. allmystuff used commands as the exclusive interface points to its
EJB -based architecture. Its API literally consisted of a set of commands.
New users of the Command design pattern frequently struggle with the
appropriate granularity for commands. It's not surprising—partitioning a
model into commands takes experience. If command granularity is too coarse,
no reuse is possible; if it's too fine, some benefits, such as a reduction in
round-tripping (see chapter 8), are diminished.
Consider an auto insurance application. Figure 4.3 shows a user interface
for the display of information on the customer and policy.
As usual, we will implement the Triangle pattern. We can decide to divide
the commands in several different ways.
Figure 4.3 This is a simplified user interface for a display of information on a
customer's insurance policy. The user interface will allow us to make several possible
choices regarding command granularity.
Search WWH ::

Custom Search