4 Replies Latest reply on Jul 18, 2007 2:36 AM by nwebb.co.uk

    Anyone versed in Cairngorm willing to have an offline discussion?

    bitwyse
      I have been looking at Cairngorm for several days now. I have reviewed a couple sample applications and read the 6 part article and other on-line resources, yet I am still not getting enough out of it to create my own application using it.

      Is anyone willing to discuss the framework either here or off-line to provide some insights into this great looking architecture? If your local to the Chicago area I'm buying the beer!

      Thanks in advance for any help. . . .
        • 1. Re: Anyone versed in Cairngorm willing to have an offline discussion?
          bayani.portier
          Lol.

          Local to Sydney, and I don't think the beer will fare well in transit.

          Anyway, the most important thing to think about in Cairngorm is that it is a design pattern based upon an MVC/MVP approach, with the model being a singleton.

          Without a more specific problem, I'll give a basic approach.

          You have to seperate everything out into 3 tiers:

          1. User Interface
          2. Commands
          3. Model

          These 3 tiers each perform their own function.
          1. User interface
          The user interface handles everything that is displayed on screen. You will usually end up with mix of MXML and actionscript components.

          The user interface contains display objects, which will call events. The objects are invoked by user gestures. The events hit the front controller, which will invoke tier 2 (Commands).

          2. Command
          Commands contain your business logic. (Can be seperated out into delegates, but usually only when you are calling a server for information.)

          The business logic will mangle your model's variables, and change their state, which brings us to Tier 3. (Model)

          3. Model
          The model is basically a Singleton pattern. It contains all of the variables of the software.

          I have seen 2 forms of implementation. The first is to access the model variables directly, and the second is to access them through functions in an attempt to avoid race condition situations, especially if you are dealing with binding.

          When a variable changes in the model, the idea is that the particular model variable is bound in your MXML. If it changes, the Setter is called in the particular component, it becomes dirty, and is redrawn with the new state.


          So where do you start thinking in this circle?

          Wholistically think about the process you are trying to complete.

          Here is a simple example on a system of selling widgets (random item) via a Flex shopping cart.

          1. User logs in
          2. User selects widget
          3. User selects quantity and gets a price
          4. User adds to cart
          ?User may go back to step 2?
          5. User checks out
          6. User pays

          Think about every gesture that the user makes.

          Ie.
          -Login
          - User Enters Username (d)
          - User Enters Password (d)
          - User clicks login (g)

          -Select Widget
          - User Selects widget from a list (g)

          - User selects quantity and gets a price
          - Select numerical quantity (d, g)
          - user Reads Price (b)
          - User adds to cart (g)

          - User checks out
          - User reads list of products (b)
          - User removes unwanted products (g)
          - User changes quantity of wanted products (d, g)
          - User Accepts Order (g)

          - User pays
          - User reads price (b)
          - User enters CC details (d)
          - User clicks pay (g)
          - System records order completed, ready for administration interface.

          So what do the letters in brackets mean?
          d - data input by the user
          b - data binding -> when the model changes, update the display
          g - gesture. When this is clicked, something on the display changes. Usually OK buttons, submit buttons, dynamic drop downs etc.

          Each gesture will have its own command.
          For instance, you will have a userLoginCommand.
          The userLoginCommand will follow these steps:
          1. Check if username exists
          1.1 if yes, do passwords match?
          1.1.1 if yes,
          1.1.1.1 authenticate user
          1.1.1.2 change viewstate of model to change to next page
          1.1.2 if no,
          1.1.2.1 display username / password mismatch message
          1.2 if no,
          1.2.1 display username / password mismatch message

          I can't stress enough how important it is to design your app appropriately, or you will run into HUGE problems down the track, and be stuck refactoring your entire program.

          Hope this helps!

          b
          • 2. Re: Anyone versed in Cairngorm willing to have an offline discussion?
            bitwyse Level 1
            Thanks so much for the great post bayani!!!

            This is exactly the type of information I am looking for. I really appreciate you taking the time to offer your assistance!!!!

            I totally agree with you on the need to design the application correctly from the beginning. That is why I have been trying to get my arms around Cairngorm.

            Thank you again for your insights! The next beer is on me! Make it a Fosters .
            • 3. Re: Anyone versed in Cairngorm willing to have an offline discussion?
              bayani.portier Level 1
              No worries mate.

              If you want to know anything else, feel free to contact me by E-Mail. It's a gmail account, and the same username as what is in my post.

              Digressing a little, it's quite funny about "Australian Beer". Everyone who's never been in Australia seems to think that Fosters is our best. If you ever get the chance, try a Toohey's, Carlton Draught, or my favourite, the good ol' XXXX (pronounced Four-Ex) Beer.

              b
              • 4. Anyone versed in Cairngorm willing to have an offline discussion?
                nwebb.co.uk
                I wrote a three part series here, starting with this post:
                http://nwebb.co.uk/blog/?p=58

                Feel free to leave some feedback on the blog to let me know if it was helpful and how it could be improved.