Flash
  Home arrow Flash arrow Delving More Deeply into the Decorator Pat...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FLASH

Delving More Deeply into the Decorator Pattern
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-12-18

    Table of Contents:
  • Delving More Deeply into the Decorator Pattern
  • Adding Properties and Methods
  • Multiple Concrete Components
  • Decorating with Multiple Properties

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Delving More Deeply into the Decorator Pattern


    (Page 1 of 4 )

    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.

    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.

    More Flash Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "ActionScript 3.0 Design Patterns Object...
     

    Buy this book now. 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). Check it out today at your favorite bookstore. Buy this book now.

    FLASH ARTICLES

    - 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
    - Organizing Frames and Layers for Flash Anima...
    - Organizing Frames and Layers
    - Using XML and ActionScript with Flex Applica...
    - Interfaces and Events with ActionScript and ...
    - Manipulating Data with ActionScript in Flex ...
    - ActionScript Syntax for Flex Applications
    - ActionScript in Flex Applications







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT