10.12.2012 Views

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

ActionScript 3.0 Design Patterns.pdf - VideoTutorials-bg.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 9 CHAPTER 9<br />

Template Method Pattern9<br />

What Is the Template Method Pattern?<br />

If you write a post and put it on a blog, that’s a<br />

historical document. If you change your template, then<br />

that entry looks <strong>com</strong>pletely different. It’s the same<br />

words, but not the same meaning. This all depends on<br />

what historical questions that people will be asking<br />

and we can’t know what they will want.<br />

—Josh Greenberg<br />

Well, I did all the pre-production and I did full demos<br />

of all the songs and then I took it into the studio and<br />

played it for all the guys and then we kind of took that<br />

as the template and did the album live very quickly.<br />

—David Sanborn<br />

You’re going to like this pattern. Essentially the template method is an algorithm<br />

made up of a sequence of operations that ac<strong>com</strong>plishes some goal. Imagine a general<br />

set of steps for getting something done such as going to work. If you take a car, boat,<br />

or airplane to work, you’re going to be doing certain things that are similar and others<br />

that are different. You’ll be transporting yourself in a vehicle, guiding it to a particular<br />

location, and you always grab a cup of coffee to take with you. So if you make<br />

a general template that covers going by car, boat, or airplane, your outline (algorithm)<br />

would look something like the following:<br />

1. Prepare transportation.<br />

2. Navigate vehicle.<br />

3. Drink your cup of coffee.<br />

Preparing a car for transportation usually involves little more than making sure it’s<br />

got enough gas and the tires aren’t flat. With a boat, you might want to check to<br />

make sure you have the necessary charts on board and that all the life preservers are<br />

in good shape. An airplane requires a walk around with a pre-flight checklist of items<br />

331

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!