5 Replies Latest reply on Aug 14, 2009 1:48 AM by Rupinder.Paul

    Layouts using components

    spacehog
      This is more of a methodology question. I am trying to decide to what granularity to I break my application up into individual components. Currently I have two states (state1, state2). The first state has one vBox with 3 buttons in it. Eventually state1 will have more vBoxes with subforms in each. I currently plan on having each vBox be a separate component. Simple enough.

      The second state (state2) has a lineChart, an ApplicationControlBar (with and hSlider and a couple of buttons), a label, and a subform (with a comboBox, radioGroup, and a submit button). I am trying to decide whether the whole state (state2) should be one component, or should I break this into several components (an ApplicationControlBar component, a lineChart component, and a subform component)?

      If I break it into several components then do I call each as a child when state2 loads or is it better to create a single wrapper [parent] component (such as a vBox) and then load the other [child] components into it, then load the parent component from the state?

      I am just trying to figure out how much to break up my layout

      Thanks for the suggestions.
        • 1. Re: Layouts using components
          Level 7

          "spacehog" <webforumsuser@macromedia.com> wrote in message
          news:ghk9iu$7ct$1@forums.macromedia.com...
          > This is more of a methodology question. I am trying to decide to what
          > granularity to I break my application up into individual components.
          > Currently
          > I have two states (state1, state2). The first state has one vBox with 3
          > buttons in it. Eventually state1 will have more vBoxes with subforms in
          > each.
          > I currently plan on having each vBox be a separate component. Simple
          > enough.
          >
          > The second state (state2) has a lineChart, an ApplicationControlBar (with
          > and
          > hSlider and a couple of buttons), a label, and a subform (with a comboBox,
          > radioGroup, and a submit button). I am trying to decide whether the whole
          > state (state2) should be one component, or should I break this into
          > several
          > components (an ApplicationControlBar component, a lineChart component, and
          > a
          > subform component)?
          >
          > If I break it into several components then do I call each as a child when
          > state2 loads or is it better to create a single wrapper [parent] component
          > (such as a vBox) and then load the other [child] components into it, then
          > load
          > the parent component from the state?
          >
          > I am just trying to figure out how much to break up my layout

          Sounds like you need a ViewStack, not States.


          • 2. Re: Layouts using components
            spacehog Level 1
            Maybe I am not understanding, but even if I used viewstacks (vs1, vs2) I would still be looking for the best way to organize the objects within the viewstack. I am just trying to make my code more readable by breaking objects out into MXML components and calling the components. I am wondering how small each component should be?
            • 3. Re: Layouts using components
              ntsiii Level 3
              First, I am with Amy in the Viewstack vs States in this case. It is a matter of taste, but you will find Viewstack much easire to code than States, with fewer problems to deal with, especially for significantly different views, I use states to switch between a List and a TextInput, but Viewstacl for more complex views.

              Now, there is not one best answer to your question. The first obvious level is to make a component for each child view in the viewstack. That is also the most important break.

              If, within one of those views, there are groups of components that you use in many places, break them out into a custom component. (reuse)

              Or, if there is some logical functionality that occurs withing an area of code, break it out.(encapsulation)

              Play this by ear. If you find yourself scrolling through page after page of functions, trying to find something, that might be a sign that refactoring is needed. If working with your code is comfortable, then leave it. (common sense)

              Tracy
              • 4. Re: Layouts using components
                Level 7

                "ntsiii" <tspratt@lariatinc.com> wrote in message
                news:ghkl1f$knj$1@forums.macromedia.com...
                > First, I am with Amy in the Viewstack vs States in this case. It is a
                > matter
                > of taste, but you will find Viewstack much easire to code than States,
                > with
                > fewer problems to deal with, especially for significantly different views,
                > I
                > use states to switch between a List and a TextInput, but Viewstacl for
                > more
                > complex views.
                >
                > Now, there is not one best answer to your question. The first obvious
                > level
                > is to make a component for each child view in the viewstack. That is also
                > the
                > most important break.
                >
                > If, within one of those views, there are groups of components that you
                > use in
                > many places, break them out into a custom component. (reuse)
                >
                > Or, if there is some logical functionality that occurs withing an area of
                > code, break it out.(encapsulation)
                >
                > Play this by ear. If you find yourself scrolling through page after page
                > of
                > functions, trying to find something, that might be a sign that refactoring
                > is
                > needed. If working with your code is comfortable, then leave it. (common
                > sense)

                I've found this to be helpful for locating code when it gets over 150 lines
                or so:

                http://flexdiary.blogspot.com/2008/12/why-i-love-development-perspective.html


                • 5. Re: Layouts using components
                  Rupinder.Paul

                  Hi,

                   

                  I am in a similar dilema, I am building a video search app in Flex, where I require several custom components to be shown specifically for viewState 1 adn then with modifcations/add/remove of the combination of components to a different view states.

                   

                  I was earlier using  ViewStacks, but then I switched to view states believeing it would be better. But working with state transition is proving to be difficult., but my only reason to switch was history management between states..Which was kind of crutial ofr my search app.

                   

                  Is there something similar I can do with ViewStacks

                   

                  thanks in advance

                   

                  Rupinder