13 Replies Latest reply on Dec 26, 2008 8:57 PM by ntsiii

    Just starting a new project

    Alce Alvarez

      I am just starting a new project and decided to use Flex for the front-end.

      It is a somewhat complicated project to be my first and I'm afraid I will be pestering this forum
      with a bunch of questions. As a lone developer, forums are the only chance I have to interact
      with more experience developers.

      I thank you all in advance.

      So here are my first couple of questions:

      The first one is about the methodology I intend to follow.
      I will be doing both the front and back-end myself so I have a lot of information to digest.
      I decided to break the project in 3 and I intend to tackle them in this order:

      1. Design all the views: layouts, flow, transitions and behaviors using the default styles for all components.
      2. Hook up the views with the back-end application.
      3. Apply better styles/skins to the finished application. I might try to find freely available ones,
      buy them or hire someone to do them for me.

      In your experience, is this a sensible approach to develop an application?

      My second question actually involves some code I started sketching.
      Users of the application will fall into 4 predefined roles, each with different levels of authorization,
      so I need to hide/display top level components accordingly.

      This is what I have so far (I removed some unnecessary code).

      The only thing I can see that smells fishy is that I'm actually creating
      components and then removing them if I don't need them. The opposite
      approach (creating only the objects I'll actually need depending
      on the logged-in users' credentials) would need some more complicated
      code. Is it worth it?

      Am I on the right track or would Obi-Wan send me home to rethink my life?
      Thanks again.

        • 1. Just starting a new project
          WestSide Level 1
          I would look into PureMVC, its a framework that offers a flavor for Flex Development. Check out www.puremvc.org.

          Since it's just yourself, prior to coding, I would suggest writing out a project plan, even if its bare nuts and bolts at least something to outline what you are building and ideally, something that will prevent or reduce scope creep.

          I would then maybe start with the data model, if your UI is going to pull data, you need a database or some other persistence tier to store your data.

          In otherwords, build the engine before you paint the car. Grab a piece of scratch paper and draw out your desired application, you don't have to get fancy here, put some sort of wireframe or prototype would be helpful. This would prevent you coding something out and then later deciding to change it. It's much easier to erase on paper than refactor code. Call it storyboarding, wireframing, or what have you, but putting it down on paper will definitely help.

          If I more parties were involved and you had stakeholders the approach would be a bit more involved but I won't get into that....

          • 2. Re: Just starting a new project
            John Hall Level 4
            I understand the point at which you find yourself. It seems like every step you take forward just creates more questions, each of which takes you on a detour for a day or two. As long as you've got time, it's fun. If you don't, it's frustrating. There are several overall topics that are probably worth becoming familiar with before you get too deep in (as if I'm an expert). One of them is the whole concept of data binding, which will come up again and again. For instance, on your authorization approach, it seems like there's an opportunity (really depends on other things that come up) to bind the visible property of buttons to the authorization level. For instance, in a button control, you might have something like <mx:Button id="createHavoc" visible="{isManager}" ....

            that way, you're not always having to think about catching all instances of script changes throughout an application.

            As far as frameworks go, they probably are helpful (I like Mate) but I speak from experience that it's probably worth getting down the basics of the Flex framework first, unless you enjoy taking on a couple of projects simultaneously.

            That's my deflated buck two-eighty worth of opinion.
            • 3. Re: Just starting a new project
              Alce Alvarez Level 1
              Thanks guys.

              @WestSide: I did look into some frameworks (PureMVC, Mate, Cairngorm and a couple others less known alternatives) and I will definitely will be using one, just not sure which one yet.

              I do have all the application sketched out in paper (more or less) and a few documents where I wrote down functionality, relationships between data models and some informal use cases. In fact I already implemented a watered-down version of the application a couple of years ago with a pure html/css front-end.

              I totally agree about the importance of having a prototype but it's easier for me to do it directly in Flex, and slowly build up on that .

              @John: You are exactly right. Very often it takes me 1 or 2 days to understand and implement something that only takes 10 minutes to do. But that's the way it is when you're learning by yourself I guess, I'm used to it and I can take my time with this application. I could just do it all in HTML/CSS/JavaScript and be done with it but this particular project lends itself perfectly for a Flex application, so it's a perfect opportunity for me to lean it.

              My first take on hiding components was exactly what you suggest, just setting the visibility to false via variable binding but it doesn't seem to work for a ToogleButtonBar or a TabNavigator (or I'm not doing it right).

              Thanks again and happy holidays.

              • 4. Re: Just starting a new project
                John Hall Level 4
                And the same to you. Regarding different views with different auth levels, I guess the next suggestion is looking at views where some objects are visible and some not, all based on a parent view. I'd hate to think of having to hard-wire all the controls in case you decide to change or add some later.
                • 5. Just starting a new project
                  *gsb* Level 1
                  You may also want to consider modules. Totally separate swf's loaded based on authorization.

                  With this type of control and even modules, you might have a second look at Mate. It's concept of "wiring" with event maps and data injection (IOC) may be a good concept for your project. It does not impose or force a program design but rather enables the application of most any including MVC or MVP. You may find a Presentation Model (or Document Model) appropriate to your project. They have a good example of that by Theo on the Mate site. Check it out, maybe.

                  • 6. Re: Just starting a new project
                    What does presentation model mean?
                    • 7. Re: Just starting a new project
                      Alce Alvarez Level 1
                      @Greg: I had a quick look at modules and they seem to be the way to go for this application. Thanks for pointing them out. A modular approach might improve my design far beyond the authorization mechanism that I need.

                      The main concerns I have right now are to have all independent swf's talk to each other and to the shell application easily and have all modules pulling and pushing data from/to a central location. To be more specific I would like to have a Cairngorm-like architecture with a modular application.

                      I will take a closer look into Mate and the example you mention and see if I can pull it off.


                      • 8. Re: Just starting a new project
                        *gsb* Level 1
                        In this case, each module can have a "local event map" wiring the module itself. You can also use "injectors" to include in each module a reference to the "main event map dispatcher." This should give you simple, flexible event management across the entire application including all of it's modules.

                        Specific Mate questions should be posted in their forums for best resolution.

                        The Presentation or Document model is simply an application design pattern as is MVC and many others. Martin Fowler has some good information on that and many other design patterns (google for links.) The use of a design pattern imposes a discipline on the application development to make it easier to test, better consistency in coding methods, more easily managed throughout it's life-cycle, etc. The issue is that the application's needs dictate what is and is not an appropriate design pattern to apply; not just using a design pattern because it is currently popular or that you know a little about it. Such use is like "a solution looking for a problem."

                        Mate is not itself a design pattern but rather a "framework" ...a tag-based MXML framework that extends the Flex framework with additional capabilities like Event Maps and Dependency Injection. These enable more design choices in application development although many Flex application will never need these extensions at all.

                        • 9. Re: Just starting a new project
                          Alce Alvarez Level 1
                          Thank you all for your suggestions, they're all really helpful.


                          • 10. Re: Just starting a new project
                            ntsiii Level 3
                            I use the "singleton" pattern for my data model. It is quite easy to implement and very convenient to use. It provides a central location for data and simplifies synchronizing data and UI.

                            I "bind" ui elements directly to the model properties when i want simple updates, and I use ChangeWatchers when I want a component to do some logic when a data model property value changes.

                            I control functionality access in a couple ways. Primarily I do the authorization on the back-end, and on login, I send xml containing the authorized applications menu structure to the client. Usually this is simply a top-level list of applications, each containing the available sub applications or submenu items.

                            This authorization structure is abastract. It can result in a actual top-level menu and submenus but can produce any style of navigation I need. And of course it can have more than two levels if needed.

                            i got started using SWFLoader to load full applications on demand, and have not yer done an app using modules as the primary architecture, but have used Modules enought to know that the basic process would be the same.

                            Good luck, and we'll be watching for specific questions and ready to help.

                            • 11. Re: Just starting a new project
                              *gsb* Level 1
                              U R welcome Juan.
                              • 12. Re: Just starting a new project
                                Alce Alvarez Level 1
                                Thank you Tracy.


                                Originally posted by: ntsiii
                                I send xml containing the authorized applications menu structure to the client.

                                That's a great idea. It's clearly a step forward from my original approach outlined in the original post.
                                However, instead of sending the xml structure, I would just send a small token
                                representing the logged in users' authorization level. I would then have the client pick the appropriate data
                                structure to use as a data provider for the navigation widget(s) from there. What do you think?


                                Originally posted by: ntsiii
                                I use the "singleton" pattern for my data model

                                I first encountered this approach while looking at Cairngorm's Model Locator. Investigating a bit further
                                into this implementation I found that it makes unit testing difficult, which is a total show stopper for me
                                (global variables and philosophical discussions aside). I'm not religious about testing but I do find it very
                                helpful, particularly when getting acquainted with a new environment.

                                All this is still a bit fuzzy to me though. I need to see a lot more examles and perhaps write a
                                dummy application to test different approaches, but I think I lean more towards a different solution
                                (dependency injection maybe).

                                Thanks again for your suggestions.

                                • 13. Re: Just starting a new project
                                  ntsiii Level 3
                                  You will have to have your menu structure's defined *somehwhere*. You can hard code all the possible menu options and versions on the client side, then choose/filter the structure based on the returned authorization level.

                                  But then to add an application, you will need to modify, re-compile and redeploy the client application.

                                  Building and sending the menu structure dynamically allows you to put a new Flex module in the app folder, update the menu configuration xml file on the server and you have updated the app.

                                  I am not sure what difficulties you forsee testing with a singleton data model, but if you have looked into it and prefer something else, go for it.