RogerV, great, maybe we should learn flex/actionscript also. I haven't
done a lot of action-script so won't pretend to know how the flex/
flash VM works. What I am interested to know though is how all that is
handled inside the flex VM.

With C#, when you write code agains a field and compile that code you
end up with a field pointer, but when you compile against a property
you get a property pointer. These `look' identical from client code,
but are completely different when compiled. Consider the following:

    // This is a field.
    public String Name;

.. and then compile against the field, then later decide that I want
to control the field by changing it to a property wrapping the field:

    // Field `Name' turned into a property (intention
    // is to replace the previous `field' called `Name'
    public String Name { get; private set; }

... anything previously compiled against the field but not recompiled
against the new library will be broken. This is due to the first being
a field pointer while the latter is a property pointer.

Think of this from a VM perspective, I can traverse the object graph
to locate it's properties and determin metadata of the properties
(permissions, bindability). From reflection the property and fields
are very different.

What I'm getting at in the end is, the syntax you've put forward looks
more like a field, but then you add accessors to the field and it gets
turned into a property; so, how is the VM handling this, if it's now a
property pointer you could be in trouble if you aren't compiling
everything against that code.

Let me ask this, with java properties and reflection, what would you
expect to see?

String.class.getDeclaredFields();
or
String.class.getDeclaredProperties();

We would also need a corresponding java.lang.reflect.Property class,
or with your suggestion would this mean that java.lang.reflect.Field
would be extended to support property specific metadata?

-Brett.

On Nov 3, 3:51 pm, RogerV <[EMAIL PROTECTED]> wrote:
> My current pain point is properties. Am working with Spring and iBATIS
> and iBATIS wants to map to Java classes that follow JavaBean
> properties convention of getters/setters.
>
> It gets so old and tedious - and clutters up the code readability - to
> toss all that getter/setter boilerplate in.
>
> But I really prefer ActionScript3 properties over C#.
>
> I can do data binding to these class properties (just use Bindable
> annotation - no need to introduce explicit getter/setter syntax in
> order to get databinding capability):
>
> public class RestaurantProduct {
>   [Bindable]
>   public var idNo:int;
>   public var prodName:String;
>   [Bindable]
>   public var desc:String;
>
> }
>
> From some MXML code I'd just use declarative binding, like so:
>
> <mx:Label text="{garlic.idNo}"/>
> <mx:Label text="{garlic.desc}"/>
>
> Or make all properties of the class bindable at once:
>
> [Bindable]
> public class RestaurantProduct {
>   public var idNo:int;
>   public var prodName:String;
>   public var desc:String;
>
> }
>
> <mx:Label text="{garlic.idNo}"/>
> <mx:Label text="{garlic.prodName}"/>
> <mx:Label text="{garlic.desc}"/>
>
> But if I want to have explicit getter/setters, then ActionScript3 has
> that too:
>
> public class RestaurantProduct {
>   private var _idNo:int;
>   // constructor - property idNo can only be set at construction time
>   public function RestaurantProduct(idno:int) { _idNo = idno; }
>   [Bindable]
>   public function get idNo():int { return _idNo; } // getter for
> property idNo
>   [Bindable]
>   public var prodName:String;
>   private var _desc:String;
>   [Bindable]
>   public function set desc(value:String):void { _desc = value; }
>   public function get desc():String { return _desc; }
>
> }
>
> The explicit getter/setters are useful when I want to have special
> behavior or fine-grained control over bindable events:
>
> public class RestaurantProduct {
>   [Bindable]
>   public var idNo:int;
>   [Bindable]
>   public var prodName:String;
>   private var _desc:String;
>   [Bindable(event="changeDescription")]
>   public function set description(value:String):void {
>     if (....) { // do something to see if should really change the
> property
>       _desc = value;
>       dispatchEvent(new Event("changeDescription"));
>     }
>   }
>   public function get description():String { return _desc; }
>
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to