O'Reilly logo

ActionScript 3.0 Design Patterns by Chandima Cumaranatunge, William Sanders

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Template Method Pattern

If you write a post and put it on a blog, that's a historical document. If you change your template, then that entry looks completely different. It's the same words, but not the same meaning. This all depends on what historical questions that people will be asking and we can't know what they will want.

Josh Greenberg
 

Well, I did all the pre-production and I did full demos of all the songs and then I took it into the studio and played it for all the guys and then we kind of took that as the template and did the album live very quickly.

 
 --David Sanborn

What is the Template Method Pattern?

You're going to like this pattern. Essentially the template method is an algorithm made up of a sequence of operations that accomplishes some goal. Imagine a general set of steps for getting something done such as going to work. If you take a car, boat, or airplane to work, you're going to be doing certain things that are similar and others that are different. You'll be transporting yourself in a vehicle, guiding it to a particular location, and you always grab a cup of coffee to take with you. So if you make a general template that covers going by car, boat, or airplane, your outline (algorithm) would look something like the following:

  1. Prepare transportation.

  2. Navigate vehicle.

  3. Drink your cup of coffee.

Preparing a car for transportation usually involves little more than making sure it's got enough gas and the tires aren't flat. With a boat, you might want to check ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required