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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Decorating with Deadly Sins and Heavenly Virtues<br />

Action gaming pits different kinds of heroes and villains against one another, and the<br />

<strong>com</strong>batants have different weapons and shields. That is, they’re decorated with different<br />

characteristics and abilities. In order to see how to add some more functions to<br />

a Decorator pattern, what could be more appropriate than pitting good against evil?<br />

Table 4-1 shows a list of deadly sins and heavenly virtues. (The list is considerably<br />

updated from Dante’s Inferno and Prudentius’ epic poem, Psychomachia, both of<br />

whom I understand were using Commodore-64’s to make their lists.)<br />

Table 4-1. Decorations of good and evil<br />

Deadly Sin Description Virtue Description<br />

Rage Uncontrolled anger—striking out at<br />

syntax errors<br />

Malice Meanness, malevolence, ill will, cruelty,<br />

and hatred toward others–unkind<br />

remarks about Linux.<br />

Obfuscation Hiding the truth— redefining an act,<br />

knowledge by adding confusion—coding<br />

without <strong>com</strong>ments<br />

Arrogance Excessive pride, not considering others’<br />

beliefs, feelings, or knowledge—belief<br />

that Microsoft Windows is the only real OS<br />

Prejudice Judging others on the basis of stereotypes<br />

and not their actions—teasing Mac users<br />

Dogmatisms Narrow, inflexible belief even in light of<br />

evidence to the contrary—continue to<br />

use procedural programming methods<br />

Indifference Seeing suffering and doing nothing or not<br />

even caring to help—unwilling to offer<br />

help in learning OOP<br />

Thinking about what has been presented so far in this chapter, the first thing that<br />

<strong>com</strong>es to mind is a property that describes each of the deadly sins and heavenly virtues.<br />

That’s easy enough, because just like the paper doll example, all we have to do<br />

is to assign a property value to each decorator. However, we can do more with the<br />

Decorator design pattern, as you’ll see in the next two sections.<br />

148 | Chapter 4: Decorator Pattern<br />

Compassion Caring about others—Helping procedural<br />

programmers transition to OOP<br />

Courage Doing the right thing regardless of the<br />

danger—taking on object-oriented programming<br />

Hope Belief in eventual success of good over<br />

evil—you really can <strong>com</strong>plete the project on<br />

time<br />

Justice A fair balance and even chance—using<br />

Windows, Mac OS, and Linux<br />

Openness Capacity to consider new knowledge, ideas,<br />

and contrary ideas—writing a program on a<br />

Mac<br />

Integrity Maintaining values even when tempted to<br />

abandon them for short term gains—foregoing<br />

hacks even though they’d get the job<br />

done and the client would never know<br />

Diligence Willingness to stick with an especially difficult<br />

task to <strong>com</strong>plete it—learning design<br />

patterns

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

Saved successfully!

Ooh no, something went wrong!