4 Replies Latest reply on Jun 27, 2010 5:55 AM by pauland

    MVC in Flex

    quebequiano

      Hi!

       

      I want to know exaclty how to describe the architecture of my Web.

       

      I'm developing a Flex/Java/BlazeDS/mySql application.

       

      This is a real OOP application, so I only have objects in Java with their methods and attributes.

       

      So I can say that I have a Server side: Java remote Objects and Client Side: Flex and AS.... that's clear

       

      But what about the MVC?? How it works in Flex?? I tried to understand it but it's complicated in the beggining:

       

      The view is : Flex components.

       

      The controller is: AS functions?

       

      The model is: AS objects???

       

      Am I right???

       

      Thanks a lot

        • 1. Re: MVC in Flex
          John Hall Level 4

          MVC is a design pattern that describes more about the way you're separating functionality within your application and is not specifically associated with whether something is created in ActionScript or MXML markup.  It just suggests that you're going to use some techniques that have the model (the data part of your application) stored in one area, that there's some sort of manager/controller that takes care of communicating with the data and presenting it to the views (maybe the forms or something) so that you don't have data values hard-wired to the forms displaying the data. So, the short answer is that there is no good answer that I know of to the question the way you phrased it.

          1 person found this helpful
          • 2. Re: MVC in Flex
            rootsounds Level 4

            This is exactly why I hate all of the simplistic MXML samples that make up the bulk of the tutorials and sample code out there. Yes, they make for easy copy-and-paste testing, but they teach bad style/design.

             

            The Adobe tutorials do eventually start to touch on how you can accomplish this using "code-behind" development:

            http://learn.adobe.com/wiki/display/Flex/Code+Behind

            There are certainly some more examples that you can find with a search.

             

            Essentially, the way I approach MVC in Flex is the following:

            • Use MXML strictly for your View layout.
            • You main View MXML should have at its root a custom class that you have made. This custom class should extend Application.
            • The custom Application class serves as the Controller. Here you wire everything together.
            • The data Model is probably self-explanatory if you know the MVC pattern.

             

            I suggest rewriting some single-MXML file examples that you know work in this manor to help you learn it.

            1 person found this helpful
            • 3. Re: MVC in Flex
              quebequiano Level 1

              Ok, so i'll try to explain myself a little bit better.

               

              My web is part of a project of a course at University. I have a chapter called "System Architecture", and i'm quite confused on this part.

               

              I wanted to talk about the Client/Server separation and the MVC pattern.

               

              For the Client I was going to say that I use the MVC pattern, with a view: MXML file, some controllers: AS scripts with functions calling the remoteObjects, and the model: AS objects and functions serving the date to the view.

               

              For the Server part my Web uses J2EE object, controlling the client part and negotiating with the database (in mysql).

               

              I saw other ways to define it: use the MVC in the client and the server too. But I can't distinguish the view the model and the controller in the server part, maybe the model are the functions with the SQL calls... but what about the rest.

               

              Thanks a lot!

              • 4. Re: MVC in Flex
                pauland Level 4

                quebequiano wrote:

                 

                I can't distinguish the view the model and the controller in the server part, maybe the model are the functions with the SQL calls... but what about the rest.

                 

                Thanks a lot!

                 

                 

                There is no view on the server side.  Most Flex applications handle MVC completely on the client and use the server-side interaction for implementing persistence of data, security and inter-client communication. That distinction may be blurred when people use server-side frameworks originally intended for html-based applications.

                 

                This should help:

                 

                http://www.amazon.com/Advanced-ActionScript-3-Design-Patterns/dp/0321426568/ref=sr_1_3?ie= UTF8&s=books&qid=1277643230&sr=8-3

                 

                or

                 

                http://www.amazon.com/ActionScript-3-0-Design-Patterns-Programming/dp/0596528469/ref=sr_1_ 1?ie=UTF8&s=books&qid=1277643230&sr=8-1

                 

                Paul