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.

and <strong>ActionScript</strong> <strong>3.0</strong>. However, the plan illustrates a basic truth about software in<br />

general and web development in particular. You’re going to spend more time on<br />

maintenance and changing a site than you are building it in the first place. As a<br />

result, you need to plan for maintenance and extensibility, and not just to get things<br />

working right in the first place.<br />

Had the web site that had been planned for change been done with design patterns,<br />

not only would it be able to adapt to change, we wouldn’t have to scrap the current<br />

design and start all over from scratch to extend the site. That is, only part of the<br />

planning process should address change of a static category. You also need to plan<br />

for extending the site to incorporate more than what you originally planned to<br />

change. That is, you may need to add new materials to change.<br />

Planning Only for Maintenance<br />

While the web site described as built for change has persisted, it has not evolved. The<br />

site has been easy to maintain because its main function loads an image, a text file,<br />

and menu items for a given product. By either changing the label on an existing button<br />

or adding a button, changing and adding products is pretty simple as well. So it<br />

has a little extensibility in the sense that its not fixed to a single product.<br />

However, the site really isn’t set up for robust extensibility. For instance, adding a<br />

blog to the site or changing the way that the menus work would take the same<br />

amount of re-structuring as it would to start from scratch. So, while changing products<br />

in the site is simple, changing the site is not. Structurally, the site looks something<br />

like Figure 1-9—The Big Function.<br />

Figure 1-9. The Big Function<br />

The Big Function<br />

function BigFunction (product)<br />

{<br />

load image in SWF<br />

load text from text file<br />

load menu items into array<br />

load array into Combo box<br />

}<br />

It doesn’t matter whether the big function is directly instantiated, gained through<br />

inheritance, or a delegate of <strong>com</strong>position. It has no flexibility other than the parameter<br />

to tell it what to place on the stage. If its algorithm is changed, it could wreck<br />

havoc on its use. You can view it as tough and inflexible because it gets one job done<br />

in one way. Alternatively, the big function can be seen as dainty and fragile because<br />

of its dependency on a single routine, and because it is subject to freeze up when<br />

58 | Chapter 1: Object-Oriented Programming, <strong>Design</strong> <strong>Patterns</strong>, and <strong>ActionScript</strong> <strong>3.0</strong>

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

Saved successfully!

Ooh no, something went wrong!