Re: Accessing property via "Unary Accessor"

Keats Kirsch <[email protected]> Thu, 09 Mar 2006 11:10:40 -0500
Newsgroups gmane.comp.java.webmacro.user
Message-ID <[email protected]>
Actually you're not completely correct.  A public variable name "title" 
would be referred to as $obj.title.  This is the point Eric was trying 
to make; WM allows you to be completely unambiguous about the property 
you are referring to.  You can have a fields called "title", "Title", 
"TITLE", or accessors called "gettitle", "getTitle", getTITLE".  So the 
reason you refer to a property as "Title" is that you are generally 
referring to the "getTitle" accessor, not the non-public "title" member 
variable.

It's also worthwhile to note that WM pre-dates JSP, so the property 
naming conventions for Java scripting were not well established at that 
time.  Personally I prefer the WM approach, for the reasons mentioned, 
and also aesthetically, but it's basically just a religious preference.  
Just be glad you're not using C# which got it all mixed up. ;-}

Keats

Marc Palmer wrote:

>
> On 8 Mar 2006, at 00:38, Sven Schliesing wrote:
>
>> Ok, that makes sense. Many Thanks for your quick and comprehensive  
>> answer!
>>
>
> Well, what doesn't quite make sense (but I like it anyway) is that  
> WebMacro assumes the first letter of properties should be capitalized  
> - I think that is your real problem.
>
> i.e. in any code that uses introspection and the java bean  
> specification, a property called "title" is accessed as "title" -  
> this is true of languages such as Groovy also.
>
> However WM, for some reason - I imagine aesthetics - requires you to  
> access a property  like this as "Title". As far as I recall it  
> doesn't matter whether you have a getTitle() or a public "title"  
> field, it must always be accessed as "Title".
>
> This has always jarred slightly in terms of my 'Java programmer'  
> expectations, but of course to non-Java end-users of WM this may not  
> be odd at all.
>
> Cheers
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting 
> language
> that extends applications into web and mobile media. Attend the live 
> webcast
> and join the prime developer group breaking into this new coding 
> territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Webmacro-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/webmacro-user
>




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642