View unanswered posts | View active topics


Reply to topic  [ 12 posts ] 
Tool to generate Value Object classes 
Author Message
Admin

Joined: Wed Aug 31, 2005 7:27 am
Posts: 10740
Location: Paris, France
Post Tool to generate Value Object classes
A very nice tool :)
http://blog.stroep.nl/2009/04/as3-value ... ator-beta/


Sat Apr 18, 2009 4:20 pm
Profile WWW
Member

Joined: Wed Apr 16, 2008 9:42 am
Posts: 63
Post Re: Tool to generate Value Object classes
Thanks Philippe :wink:

Check out this little instruction video too:
http://www.flickr.com/photos/markknol/3451978609/
EDIT: sorry .. deprecated

_________________
blog.stroep.nl
http://projects.stroep.nl/flashdevelop/


Last edited by mknol on Mon May 18, 2009 5:59 pm, edited 1 time in total.



Mon Apr 20, 2009 6:41 pm
Profile WWW
Member

Joined: Wed Apr 16, 2008 9:42 am
Posts: 63
Post Re: Tool to generate Value Object classes
Update
- simple autocompletion for types
- added function for getters/setters
- added function to pass variable in constructor
- some performance tweaks

http://projects.stroep.nl/ValueObjectGenerator/

_________________
blog.stroep.nl
http://projects.stroep.nl/flashdevelop/


Fri May 15, 2009 8:02 am
Profile WWW
Member

Joined: Mon Jan 21, 2008 6:58 pm
Posts: 45
Post Re: Tool to generate Value Object classes
Wow that seems incredibly lazy. The amount of work typing into the fields is almost exactly the same as just writing it by hand. I don't get it.


Fri May 15, 2009 1:18 pm
Profile
Member

Joined: Thu Feb 09, 2006 10:58 am
Posts: 943
Location: Israel
Post Re: Tool to generate Value Object classes
This tool can be handy. However something bugs me:
Code:
public class
   {
      private var _test:String;
      public var :;
      
      public function ( test:String, : ):void
      {
         >>>  _test = test;
         this. = ;
      }

      public function get test():String { return _test; }

   }


in the marked line, there can be a confusion between calling the getter and the constructor argument.

_________________
MovieClipCommander


Fri May 15, 2009 2:47 pm
Profile
Member

Joined: Wed Apr 16, 2008 9:42 am
Posts: 63
Post Re: Tool to generate Value Object classes
@CourseVector: Yes, It is for lazy people, but moslty its for people who doesnt want to type multiple times the same things. ;) I created the tool to create fast this kind of class:
Code:
package nl.stroep.vo
{
   public class valueObject extends Sprite
   {
      public var index:int;
      public var price:uint;
      public var content:String;
      public var title:String;
      public var ratio:Number;
      
      public function valueObject( index:int, price:uint, content:String, title:String, ratio:Number ):void
      {
         this.index = index;
         this.price = price;
         this.content = content;
         this.title = title;
         this.ratio = ratio;
      }

   }
}
You see? 5 variables and 5 types and they appear 4 times in the class. If you use a lot of VO's, this should be a little bit fast (I hope) :)

@IAP: What do you mean? Do you have conflicts with it? Any ideas for this?

_________________
blog.stroep.nl
http://projects.stroep.nl/flashdevelop/


Fri May 15, 2009 5:31 pm
Profile WWW
Member

Joined: Mon Jan 21, 2008 6:58 pm
Posts: 45
Post Re: Tool to generate Value Object classes
Out of curiosity, why does it extend Sprite? If it's purely a value object wouldn't you want it extending nothing?


Fri May 15, 2009 6:03 pm
Profile
Member

Joined: Wed Apr 16, 2008 9:42 am
Posts: 63
Post Re: Tool to generate Value Object classes
CourseVector wrote:
Out of curiosity, why does it extend Sprite? If it's purely a value object wouldn't you want it extending nothing?

I don't want to extend a sprite, it was just for the example. In most cases I mostly don't want too extend something with a value object (maybe a ValueObject class with a toString or clone function). Anyway you could use this tool for multiple purposes, so an extend function could be handy.

_________________
blog.stroep.nl
http://projects.stroep.nl/flashdevelop/


Fri May 15, 2009 7:07 pm
Profile WWW
Member

Joined: Thu Feb 09, 2006 10:58 am
Posts: 943
Location: Israel
Post Re: Tool to generate Value Object classes
I generally hate to use same names for class properties and function arguments. I know that scoping issues will eventually use the argument and not the class var, so from the compiler point of view it would be correct. But from the developer point of view it could be confusing.

By the way, It happened to me an infinite loop of calling getter instead of local var that eventually called the same getter....

_________________
MovieClipCommander


Sat May 16, 2009 8:33 am
Profile
Member

Joined: Wed Apr 16, 2008 9:42 am
Posts: 63
Post Re: Tool to generate Value Object classes
updates
- automatic imports
- save function (to .as-file)
- inputfield for constructor parameters prefix. Thanks for the tip IAP, now we have the option to fix it. At some case (like; no getters/setters) I dislike to use the prefix, so that's why it is optional. I don't know if there is a code-standard definition for this?

_________________
blog.stroep.nl
http://projects.stroep.nl/flashdevelop/


Mon May 18, 2009 5:54 pm
Profile WWW
Member

Joined: Wed Aug 01, 2007 3:37 pm
Posts: 1220
Location: Grizzly Flats, CA
Post Re: Tool to generate Value Object classes
Everyone has their own particular way of distinguishing when two variables would otherwise share the same name. In many cases I prefer to use "variable" and "this.variable" to distinguish them, but others certainly prefer to use casing or characters like underscores to make the delineation.

However, the language supports namespaces, which is what I use when distinguishing between an internal value and a public getter and setter. While logical names like "private" and "internal" are already reserved, I use the word "local" for my internal namespace. So here's an example of what that looks like:

Code:
package com.test {
   
   
   public class TestClass {
      
      
      namespace local;
      local var testVariable:Object;
      
      
      public function TestClass () {
         
      }
      
      
      // Get & Set Methods
      
      
      public function get testVariable ():Object {
         
         return local::testVariable;
         
      }
      
      public function set testVariable (value:Object):void {
         
         local::testVariable = value;
         
      }
      
      
   }
   
   
}


Tue May 19, 2009 1:57 am
Profile WWW
Member

Joined: Wed Apr 16, 2008 9:42 am
Posts: 63
Post Re: Tool to generate Value Object classes
Tool is updated again;

- better autocompletion
- improved interface

_________________
blog.stroep.nl
http://projects.stroep.nl/flashdevelop/


Thu Aug 27, 2009 3:24 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 12 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.