4 Replies Latest reply on Nov 1, 2011 12:02 PM by shadethX

    Removal of Cairngorm 2 from a Flex SDK 3.4 project?

    shadethX Level 1



      I am looking into how practical it is to remove the Cairngorm 2 MVC from my project.  It is currently using Flex SDK 3.4, but I wish to move it to Flex 4, and it seems like Cairngorm 2 is incompatiable.  Cairngorm 3 is a totally different beast, so it's not as easy as just upgrading to that (I wish it was).


      My main difficulties lie in replacing some of the core functionalities Cairngorm has provided for this project including:





      Does anyone have experience with "removing" or "substituting" those Cairngorm elements with something native to Flex, or other MVCs such as Parsley?  I have not used Parsley so I'm unsure if it would help in this case or not.


      I realize this is a complicated question to ask here, but I just wanted to know if anyone had experience or a recommendation as to how to go about getting Cairngorm 2 removed from my application, short of re-writing the entire architecture of the application.  Thanks.

        • 1. Re: Removal of Cairngorm 2 from a Flex SDK 3.4 project?
          UbuntuPenguin Level 4

          UP walks into room and takes off surgeons mask...

          I'm sorry, the cancer was too large and had spread throughout the whole application.  The further we dug down into the components, the more singletons we saw, far more than preliminary test indicated.  We weren't able to remove one without crippling the rest of the application since their interdependencies were so great, creating a sinister web of architectural pick-up sticks.


          We administered 100cc of Mate, began Parsley therapy and flew in the best Swizologists in the region but to no avail.  We have a grief counselor available to help you through this time on the Photoshop flo...


          UP's beeper goes of

          I'm sorry, looks like multiple applications have been involved in a PureMVCarousel crash.  I have to go...

          • 2. Re: Removal of Cairngorm 2 from a Flex SDK 3.4 project?
            shadethX Level 1

            Hahahaha!!!  Thanks for the laugh, unfortunate as my situation is...  Yes, indeed there are a TON of Singletons, and trying to remove any of this stuff causes catastrophic failures. It's like a cancer indeed and spread far and wide.


            This rather large application was developed by a team in the Fall 2009 / winter of 2010, shortly before Adobe abandoned Cairngorm 2, and during a time they were instead recommending it.  I've had to update it with several patches, but moving forward I wanted to be able to use Flex 4 and the Spark components, however this is holding me back from upgrading.


            So is the picture really that bleak?  I guess this may be a massive undertaking to get it removed, may be easier to redo it entirely with a new MVC?  Any suggestions?

            • 3. Re: Removal of Cairngorm 2 from a Flex SDK 3.4 project?
              Claudiu Ursica Level 4

              I would start by doing some sort of Hierarchical presentation model e.g. move the singleton's as up to the root app, e.g instead of having in view private someOhterProp:SomeOtherProp =model.getInsance().someProp.someOhterProp, have the parent pass someOtherProp in... So every component gets it's model data from it's parent. This will be a little bit ugly but once you get rid of the singletons inside view's you'll be a step closer.... Maybe you don't have the singleton inside view's which will be even better. You need to do it in steps and here Unit tests will help alot ... One you cleaned a view e.g the dependencies can be passed through setters you can put parsley to work e.g inject the dependency into the view, and cut the reference from the parent .... The move towards a componetized presentation model and have that model dispatch the cairngorm event. After this you can move towards parsely manage events ....


              This is fairly generic, the whole idea is to do it in steps and most probably for quite sometimes you'll be running with both parsely and gairngorm ...


              After you moved to Parsley start moving to flex 4, and swap components...



              HTH in some way,


              1 person found this helpful
              • 4. Re: Removal of Cairngorm 2 from a Flex SDK 3.4 project?
                shadethX Level 1

                OK, in case anyone else happens to stumble upon this, here is some of the progress I've been making on this as I have time.  I've found an easy fix for 2 of the 3 issues:





                Both of these classes are quite frankly empty classes, almost nothing in them at all.  I was therefore able to create my own versions of these clases, based on what I saw here:

                http://www.google.com/codesearch#l8D5yY3i8ho/trunk/code/src/com/adobe/cairngorm/vo/IValueO bject.as


                So, I just added a trimmed down version of those empty classes into a util folder in my classes, and changed the reference to that and bam, it works with no reference to cairngorm!!  I was floored by how simple that was for the IValueObject and the IModelLocator.  They all still work as expected and they're used all over the place.


                The other issue however, the CairngormEvent is proving to be more troublesome, especially since I have a multitude of Events and Services tied into a cairngorm FrontController, and so I have a business folder chuck full of a lot of dependent delegates, other related folders with commands, and events.  There are also CallBack events, etc.  It's a big mess, and so I'm still working on that, will probably have to create an alternate dispatch system for the web service events and write in custom stuff for it.  I did find this of great use when researching different ways to make web service calls through Flex without using MXML:  http://blogs.4point.com/brad.white/2008/12/4-ways-to-invoke-a-webservice-in-flex-with-mxml -and-actionscript.html


                So, hopefully that new info helps someone else stuck in this situation.

                1 person found this helpful