You first identify the differences in the existing code and then separate the

You first identify the differences in the existing

This preview shows page 6 - 10 out of 10 pages.

You first identify the differences in the existing code and then separate the differences into new operations. Finally, you replace the differing code with a template method that calls one of these new operations. To control subclasses extensions. You can define a template method that calls "hook" operations (see Consequences) at specific points, thereby permitting extensions only at those points.
Image of page 6
Example The Template Method defines a skeleton of an algorithm in an operation, and defers some steps to subclasses. Home builders use the Template Method when developing a new subdivision. A typical subdivision consists of a limited number of floor plans with different variations available for each. Within a floor plan, the foundation, framing, plumbing, and wiring will be identical for each house. Variation is introduced in the later stages of construction to produce a wider variety of models.
Image of page 7
Example Daily routine of a worker.
Image of page 8
Check list Examine the algorithm, and decide which steps are standard and which steps are peculiar to each of the current classes.
Image of page 9
Image of page 10

You've reached the end of your free preview.

Want to read all 10 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes