1 Reply Latest reply on Dec 1, 2011 10:06 AM by Flex harUI

    Using predefined data objects classes.

    wmkolcz Level 1

      I am always trying to be a better, more efficient Flex developer and I was looking at a project by Christophe Coenraets where he created collaberative forms using Flex/BlazeDS. I saw in his application that he was using multidirectional binding to a Class Object for each form in the application. For example, this is the MortgageApplication.as

       

      package

      {

          import mx.collections.ArrayCollection;

       

          [Bindable]

          public class MortgageApplication

          {

              public var firstName:String;

              public var lastName:String;

              public var ssn:String;

              public var phone:String;

              public var mobilePhone:String;

              public var email:String;

              public var notify:Boolean;

              public var usCitizen:Boolean;

       

              public var address:String

              public var city:String

              public var state:String

              public var zip:String

              public var singleFamily:Boolean;

       

              public var salePrice:Number = 500000;

              public var downPayment:Number = 100000;

              public var closingDate:Date;

             

              public var jobList:ArrayCollection = new ArrayCollection();

       

          }

      }

       

      I have an application that I use multiple forms to input information into the database and then I use Objects (actually ObjectProxys) and ArrayCollections to store information to display. I use the Mate Framework and have manager classes that store predefined bindable variables (empty)  that are injected into the view as needed or requested. In the manager class I just create a new ObjectProxy (or ArrayCollection) and use the information passed in (an ArrayCollection from ColdFusion) and create/modify the ObjectProxy/ArrayCollection before having it injected.

       

      Is it better practice or more efficent to predefine object classes (such as above from the example) then just populate them in the manager class before the injection or just create an new blank Object or ArrayCollection on the fly. Is there any difference?

       

       

      Set up a seperate Class:

      package

      {

       

          [Bindable]

          public class Person

          {

              public var firstName:String;

              public var lastName:String;

              public var phone:String;

       

          }

      }

       

      and do this in the Manager:

       

      public function setPerson():void {

           var person = new Person();

           person.firstName = "Steve";

           person.lastName = "Smith";

           person.phone = "555.555.1212";

      }

       

      OR just have this declaired in the Manager as

       

      [Bindable] public var person:ObjectProxy;

       

      public function setPerson():void {

           person = new ObjectProxy();

           person.firstName = "Steve";

           person.lastName = "Smith";

           person.phone = "555.555.1212";

      }

       

      Thanks to anyone who wants to help me become a better developer!