views:

139

answers:

1

I have created a few Event and Command classes for use in my Cairngorm projects.

For example, I created an class that extends com.adobe.cairngorm.control.CairngormEvent that allows me to set callback functions upon completion or failure of the corresponding Command. To accomplish this, I also had to create a new Class that implements com.adobe.cairngorm.commands.ICommand that I extend for all Commands in my projects.

Now, I want to use these two classes across all of my Cairngorm applications. What is the best way to do this? Should I just edit the Cairngorm source for CairngormEvent and ICommandand recompile the Cairngorm MVC (is that even possible)? Or add my two classes to the Cairngorm source and recompile the Cairngorm MVC? Or should I just add them to a shared library?

I've chose the third option for now, but this requires that I reference the Cairngorm library in both my library and each project. I am wondering if there is a better practice and what the benefits are.

Thanks.

+3  A: 

All the options you propose will work. However I would suggest to leave the Cairngorm sources and SWC as is and just create a separate SWC with your classes. You don't want to patch the Cairngorm sources each time they release a new version.

You have 2 options for compiling your custom SWC (in the build path options of the referenced libraries):

  1. Externally reference the Cairngorm lib: you'll then need to link both the Cairngorm SWC and your custom SWC into your projects.

  2. Merge the Cairngorm lib into your SWC: you'll only need to reference your lib if you make sure all Cairngorm classes are also compiled into it. Only the Cairngorm classes that you reference (by extending them for instance) will be merged into your custom SWC. You can force an include of the other Cairngorm classes by referencing them somewhere in your code.

I personally prefer option 1 since this is the cleanest way of separating code libraries and it allows you to swap/upgrade versions of Cairngorm without having to recompile your library.

Christophe Herreman