This is off the top of my head so if someone out there knows or can
explain better feel free to correct me...

I've not looked at the actual code but from your snippet it appears
that they are in fact still using constants, just not ones that are
defined in the ShopController. When you have an event that needs to
carry data with it, you have to subclass Event. In that case you would
also define the event type in that subclass, which is what they seem
to be doing. If you had an event that didn't require a data payload to
be sent with it, you'd define the constant in the controller. Make sense?

HTH,
Ben

--- In flexcoders@yahoogroups.com, "laidezmon" <[EMAIL PROTECTED]> wrote:
>
> Here is a question about Cairngorm best practices. 
> 
> In the documentation this is in part four feature driven development,
> page 3 for cairngorm .99 it says this:
> 
> "First recognize the best practice appraoch of naming all events as
> constants on the FrontController instance ShopController."
> 
> Later down it says:
> 
> "The compiler catches any mistyped events noisily at compile time
> rather than failing silently at run time. While Cairngorm does not
> require this, its a best practice we highly recommend."
> 
> I downloaded the latest Cairngorm store for 2.0 however, and thier
> shopController instance is not written in the same format. I was
> wondering why? In the 2.0 version they do NOT declare constants, but
> in the .99 version they do. What is the best practice? 
> 
> Below are the two different ShopController code samples. The .99 uses
> static vars, while the 2 version does not. In fact the entire method
> for calling the associated commands from events are different. So
> which is the actual best practice?
> 
> Help!
> JS.
> 
> 
> Here is the .99 ShopController example:
> 
> class org.nevis.cairngorm.samples.store.control.ShopController extends
> FrontController
> {
>     public function ShopController()
>    {
>        initialiseCommands();
>    }
>     
>    
>
//----------------------------------------------------------------------------
> 
>     public function initialiseCommands()
>     {
>       addCommand( ShopController.EVENT_GET_PRODUCTS, new
> GetProductsCommand() );
>       addCommand( ShopController.EVENT_ADD_PRODUCT_TO_SHOPPING_CART,
> new AddProductToShoppingCartCommand() );
>       addCommand(
> ShopController.EVENT_DELETE_PRODUCT_FROM_SHOPPING_CART, new
> DeleteProductFromShoppingCartCommand() );  
>       addCommand( ShopController.EVENT_FILTER_PRODUCTS, new
> FilterProductsCommand() );     
>       addCommand( ShopController.EVENT_SORT_PRODUCTS, new
> SortProductsCommand() );     
>       addCommand( ShopController.EVENT_VALIDATE_ORDER, new
> ValidateOrderCommand() );
>       addCommand( ShopController.EVENT_VALIDATE_CREDIT_CARD, new
> ValidateCreditCardCommand() );     
>       addCommand( ShopController.EVENT_COMPLETE_PURCHASE, new
> CompletePurchaseCommand() );     
>     }
>     
>    
>
//-------------------------------------------------------------------------
> 
>     public static var EVENT_GET_PRODUCTS = "getProducts";
>     public static var EVENT_ADD_PRODUCT_TO_SHOPPING_CART =
> "addProductToShoppingCart";
>     public static var EVENT_DELETE_PRODUCT_FROM_SHOPPING_CART =
> "deleteProductFromShoppingCart";  
>     public static var EVENT_FILTER_PRODUCTS = "filterProducts";
>     public static var EVENT_SORT_PRODUCTS = "sortProducts";
>     public static var EVENT_VALIDATE_ORDER = "validateOrder";
>     public static var EVENT_VALIDATE_CREDIT_CARD = "validateCreditCard";
>     public static var EVENT_COMPLETE_PURCHASE = "completePurchase";  
>          
>         
> }
> 
> 
> Here is the version 2.0 ShopController Example:
> 
> package com.adobe.cairngorm.samples.store.control
> {
>       import com.adobe.cairngorm.control.FrontController;
>       import com.adobe.cairngorm.samples.store.command.*
>       import com.adobe.cairngorm.samples.store.event.UpdateShoppingCartEvent;
>       import com.adobe.cairngorm.samples.store.event.FilterProductsEvent;
>       import com.adobe.cairngorm.samples.store.event.GetProductsEvent;;
>       import com.adobe.cairngorm.samples.store.event.SortProductsEvent;
>       import com.adobe.cairngorm.samples.store.event.ValidateOrderEvent;
>       import com.adobe.cairngorm.samples.store.event.ValidateCreditCardEvent;
>       import com.adobe.cairngorm.samples.store.event.PurchaseCompleteEvent;
>       
>       /**
>        * @version     $Revision: $
>        */
>       public class ShopController extends FrontController
>       {
>               public function ShopController()
>               {
>                       initialiseCommands();
>               }
>               
>               public function initialiseCommands() : void
>               {
>                       addCommand( GetProductsEvent.EVENT_GET_PRODUCTS,
> GetProductsCommand );   
>                       addCommand(
> UpdateShoppingCartEvent.EVENT_ADD_PRODUCT_TO_SHOPPING_CART,
> AddProductToShoppingCartCommand );
>                       addCommand(
> UpdateShoppingCartEvent.EVENT_DELETE_PRODUCT_FROM_SHOPPING_CART,
> DeleteProductFromShoppingCartCommand );         
>                       addCommand( FilterProductsEvent.EVENT_FILTER_PRODUCTS,
> FilterProductsCommand );               
>                       addCommand( SortProductsEvent.EVENT_SORT_PRODUCTS,
> SortProductsCommand );         
>                       addCommand( ValidateOrderEvent.EVENT_VALIDATE_ORDER,
> ValidateOrderCommand );       
>                       addCommand(
> ValidateCreditCardEvent.EVENT_VALIDATE_CREDIT_CARD,
> ValidateCreditCardCommand );             
>                       addCommand( 
> PurchaseCompleteEvent.EVENT_COMPLETE_PURCHASE,
> CompletePurchaseCommand );
>               }       
>       }
>       
>       }
>







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to