2 Replies Latest reply on Sep 24, 2010 4:33 AM by flex2008

    Correct approach for creating custom events

    flex2008 Level 3

      I have a form as a popup in my application.User enters a lot of information,around 15 of them.When i click save button,a custom event,with all the user entered details,is dispatched and it is handled in the controller.My question is, which of the following is the standard way of defining the properties in my custom event or any other approach is the correct one?


      1)Define read only properties for each of the details in the event class and set the properties through constructor.But then my constructor will have a lot of parameters,which i dont think is good from code readability and maintainablity point of view.


      2)Define public setters and getters for the properties in the event class and set them through the object of my custom event rather than through constructors.


      3)Define a VO class for all the properties and define a object of this VO class in the event class and set this property through event contructor.

        • 1. Re: Correct approach for creating custom events
          BhaskerChari Level 4

          Hi flex2008,


          The third option is the better option you can always use...Just create a VO class which include all your properties and also include once instance of this in your custom event class. When you click save button in your Form save all these details in an instance of your VO object and then dispatch your custom event by passing the VO object to the Event class.


          This approach is always the better approach I say you can use and you can increase the readability and compactness of the code and with with minimal effort you can make any changes if you wnat to add any other properties to the object or Form.


          Hope it clear for you now.




          • 2. Re: Correct approach for creating custom events
            flex2008 Level 3

            Correct.I was also thinking in the same lines.Just wanted to confirm it.. ..Thanks,,