Flash
  Home arrow Flash arrow Page 3 - 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 - Multiple Concrete Components


    (Page 3 of 4 )

    We could look at one soul at a time, but what fun is that? More important, in a lot of applications, having a single component to decorate isn’t too useful either. So instead of having a single soul to decorate, we’ll add two. For the time being, we’ll forego any debates about original sin and start our souls with a clean slate. Both goodness and vice will be set to zero. Just give them different soulvalues so they can be differentiated.

    Examples 4-18 and 4-19 provide the concrete components for DickandJaneclasses. Each class just needs a string value forsouland numeric values forgoodnessandvice—all inherited properties from theComponentclass. Save Example 4-18 asDick.as, and Example4-19 asJane.as.

    Example 4-18. Dick.as

    package
    {
       public class Dick extends Component
       {
         
    public function Dick()
         
    {
             soul = "Dick's soul\n";
             goodness=0;
             vice=0;
         
    }
       }
    }

    Example 4-19. Jane.as

    package
    {
       public class Jane extends Component
       {
         
    public function Jane()
         
    {
             soul = "Jane's soul\n";
             goodness=0;
             vice=0;
         
    }
       }
    }

    These concrete component classes are exactly like the previous examples we’ve examined, except we have two instead of one. Furthermore, instead of using a single string variable, two additional numeric variables are added, along with their assigned values. Otherwise, they’re just the same.

    In these two concrete classes, the properties are inherited directly from the abstractComponentclass. No overrides or other special adjustments are needed. This is because theDickandJaneclasses are components, both to be decorated by the decorator classes. The overrides that generate unique methods and characteristics for the concrete decorators are accomplished by the decorator classes. Therefore, overrides by the concrete component classes are unnecessary.

    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

    - 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
    - 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







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek