Home arrow Flash arrow Delving More Deeply into the Decorator Pattern

Delving More Deeply into the Decorator Pattern

In this fourth part of a six-part series on the decorator pattern, we use deadly sins and heavenly virtues to illustrate how to add properties and methods, and more. This article is excerpted from chapter four of ActionScript 3.0 Design Patterns Object Oriented Programming Techniques, written by William B. Sanders and Chandima Cumaranatunge (O'Reilly, 2007 ISBN: 0596528469). Copyright © 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

Author Info:
By: O'Reilly Media
Rating: 5 stars5 stars5 stars5 stars5 stars / 6
December 18, 2008
  1. · Delving More Deeply into the Decorator Pattern
  2. · Adding Properties and Methods
  3. · Multiple Concrete Components
  4. · Decorating with Multiple Properties

print this article

Delving More Deeply into the Decorator Pattern
(Page 1 of 4 )

Decorating with Deadly Sins and Heavenly Virtues

Action gaming pits different kinds of heroes and villains against one another, and the combatants have different weapons and shields. That is, they’re decorated with different characteristics and abilities. In order to see how to add some more functions to a Decorator pattern, what could be more appropriate than pitting good against evil?

Table 4-1 shows a list of deadly sins and heavenly virtues. (The list is considerably updated from Dante’s Inferno and Prudentius’ epic poem, Psychomachia, both of whom I understand were using Commodore-64’s to make their lists.)

Table 4-1. Decorations of good and evil

Deadly Sin Description Virtue Description
Rage Uncontrolled anger—striking out at syntax errors Compassion Caring about others—Helping procedural programmers transition to OOP
Malice Meanness, malevolence, ill will, cruelty, and hatred toward others–unkind remarks about Linux. Courage Doing the right thing regardless of the danger—taking on object-oriented programming
Obfuscation Hiding the truth— redefining an act, knowledge by adding confusion—coding without comments Hope Belief in eventual success of good over evil—you really can complete the project on time
Arrogance Excessive pride, not considering others’ beliefs, feelings, or knowledge—belief that Microsoft Windows is the only real OS Justice A fair balance and even chance—using Windows, Mac OS, and Linux
Prejudice Judging others on the basis of stereotypes and not their actions—teasing Mac users Openness Capacity to consider new knowledge, ideas, and contrary ideas—writing a program on a Mac
Dogmatisms Narrow, inflexible belief even in light of evidence to the contrary—continue to use procedural programming methods Integrity Maintaining values even when tempted to abandon them for short term gains—foregoing hacks even though they’d get the job done and the client would never know
Indifference Seeing suffering and doing nothing or not even caring to help—unwilling to offer help in learning OOP Diligence Willingness to stick with an especially difficult task to complete it—learning design patterns

Thinking about what has been presented so far in this chapter, the first thing that comes to mind is a property that describes each of the deadly sins and heavenly virtues. That’s easy enough, because just like the paper doll example, all we have to do is to assign a property value to each decorator. However, we can do more with the Decorator design pattern, as you’ll see in the next two sections.

blog comments powered by Disqus

- More Top Flash Game Tutorials
- Top Flash Game Tutorials
- Best Flash Photo Gallery Tutorials
- The Top Flash Tutorials for Menus
- 7 Great Flash Tutorials
- Adobe Creative Suite 5.5 Now Available
- Critical Flash Vulnerability Heats Up the Web
- More on Nonpersistent Client-Side Remote Sha...
- Nonpersistent Client-Side Remote Shared Obje...
- Using the Decorator Pattern for a Real Web S...
- Using Concrete Decorator Classes
- Delving More Deeply into the Decorator Patte...
- The Decorator Pattern in Action
- A Simple Decorator Pattern Example
- Decorator Pattern

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials