5 Replies Latest reply on Jun 8, 2009 6:50 AM by simenlf

    How to order the code so that it is manageble.

    simenlf

      Hello.

      Let me start with saying that I am very new to flex.

       

      I have a very basic question that I hope will be very easy for you to answer:

       

      I want to create a quite big application in flex, and am unsure how to order the code so that it is seperated into blocks of code. I want a tool like the include function of php or at least be able toseperate the code so that it will not end up as a big chunck of code on one page.

       

      What do you think is the best way to do this?

       

      Thank you for your time.

        • 1. Re: How to order the code so that it is manageble.
          BennyBeta Level 4

          This might be contrary to a lot of wisdom, but if you're new to Flex I would concentrate on how to get a working application first, then how to better organize/optimize it as you go along.

           

          That being said, you can use ActionScript classes and MXML components for separating your code.  ActionScript classes are best used for your "business logic" and MXML components best used for custom, reusable interface components.

           

          Let me know if that helps or if you have more specific questions...


          Ben Edwards

          1 person found this helpful
          • 2. Re: How to order the code so that it is manageble.
            simenlf Level 1

            Thank you for your answer. I will look into this further.

             

            PS: I have an application working allready. I want to extend on it creating other functionality in the same package.

             

            Cheers.

            • 3. Re: How to order the code so that it is manageble.
              dzeikei Level 2

              If you are creating a large project, a framework will help immensly in managing your code.

              There are quite a few out there: Cairngorm, PureMVC, Mate, Swiz and more...

               

              If you just want something like include function in PHP, use OOP principles to separate code into objects, and use 'import' instead of include.

              Perhaps you need to learn more about OOP in general, which is not limited to Flex but also present in PHP 5 as well.

              1 person found this helpful
              • 4. Re: How to order the code so that it is manageble.
                thebouv Level 2

                You're new to Flex, but if you're not new to programming in general, you've probably heard of the MVC design pattern.  In regards to Flex and MVC, check out Mate, PureMVC and of course Adobe's Cairngorm.  In my opinion though, MVC is overkill in lots of situations, even large apps (unless they're multi-developer projects).

                 

                You can also look into code-behind, a design pattern often seen in C# work, though I've not used it myself.

                 

                Do as the second poster mentioned and break your app into MXML and Actionscript sections, but go further and break your app into multiple custom components.  Each component can have it's own MXML and Actionscript file.  I've found this to be the quickest and easiest way to organize even large applications.

                 

                Programming Flex 3 from Oreilly publishing has a great section on how to break your app down into multiple, manageable components.  And there's probably a chapter like it in most Flex books.

                • 5. Re: How to order the code so that it is manageble.
                  simenlf Level 1

                  Thank all of you for fast and great help.

                   

                  Have a nice day everyone.