<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Getters, setters, and the difference between Java and AS</title>
	<atom:link href="http://kuwamoto.org/2006/01/09/getters-setters-and-the-difference-between-java-and-as/feed/" rel="self" type="application/rss+xml" />
	<link>http://kuwamoto.org/2006/01/09/getters-setters-and-the-difference-between-java-and-as/</link>
	<description>music, technology, interfaces, people</description>
	<lastBuildDate>Mon, 19 Oct 2009 16:37:14 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Sho</title>
		<link>http://kuwamoto.org/2006/01/09/getters-setters-and-the-difference-between-java-and-as/comment-page-1/#comment-276544</link>
		<dc:creator>Sho</dc:creator>
		<pubDate>Wed, 22 Apr 2009 23:18:54 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=40#comment-276544</guid>
		<description>Hi Benji. It&#039; snever too late. :-)

What I meant in my post (from 2 years ago? yikes!) is that I don&#039;t plan on using getters and setters unless they were needed for some reason (e.g., to make them read-only). I didn&#039;t mean to imply that I wasn&#039;t going to use properties at all!!

In a language like Java, you tend to use getters and setters defensively, just in case you may need them later. In a language like AS3, you don&#039;t have to do that.</description>
		<content:encoded><![CDATA[<p>Hi Benji. It&#8217; snever too late. :-)</p>
<p>What I meant in my post (from 2 years ago? yikes!) is that I don&#8217;t plan on using getters and setters unless they were needed for some reason (e.g., to make them read-only). I didn&#8217;t mean to imply that I wasn&#8217;t going to use properties at all!!</p>
<p>In a language like Java, you tend to use getters and setters defensively, just in case you may need them later. In a language like AS3, you don&#8217;t have to do that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benji Smith</title>
		<link>http://kuwamoto.org/2006/01/09/getters-setters-and-the-difference-between-java-and-as/comment-page-1/#comment-276531</link>
		<dc:creator>Benji Smith</dc:creator>
		<pubDate>Wed, 22 Apr 2009 21:58:58 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=40#comment-276531</guid>
		<description>I know I&#039;m replying waaaaaay late on this, but I have to disagree ever-so-slightly.

In the AS3 property implementation, it&#039;s easy to create read-only (or write-only!) public properties. But only if you use the property syntax. If you just declare public variables, then there&#039;s no way to mark them as read-only. So sometimes it makes sense to use the property syntax, even when you&#039;re just writing dumb behavior-less getters, so that you can enforce asymmetric read/write access.

Of course, the AS3 property implementation is a thousand times better than Java, where public members are a very bad idea and you&#039;re pretty much forced to write getters and setters. But the C# implementation is even better than AS3, because you can declare read-only member variables without having to use the property syntax. Very nice.

But even the C# implementation still has its flaws. For example, sometimes I&#039;d like to declare a member variable as public-read-only, but private-read-write. The only way to accomplish that is to use the property get/set functions.

I&#039;d love it if there was a way, purely using access modifiers on a member variable, to declare those kinds of asymmetric access modifiers.

In the mean time, though, I&#039;ll keep writing those damn properties :)</description>
		<content:encoded><![CDATA[<p>I know I&#8217;m replying waaaaaay late on this, but I have to disagree ever-so-slightly.</p>
<p>In the AS3 property implementation, it&#8217;s easy to create read-only (or write-only!) public properties. But only if you use the property syntax. If you just declare public variables, then there&#8217;s no way to mark them as read-only. So sometimes it makes sense to use the property syntax, even when you&#8217;re just writing dumb behavior-less getters, so that you can enforce asymmetric read/write access.</p>
<p>Of course, the AS3 property implementation is a thousand times better than Java, where public members are a very bad idea and you&#8217;re pretty much forced to write getters and setters. But the C# implementation is even better than AS3, because you can declare read-only member variables without having to use the property syntax. Very nice.</p>
<p>But even the C# implementation still has its flaws. For example, sometimes I&#8217;d like to declare a member variable as public-read-only, but private-read-write. The only way to accomplish that is to use the property get/set functions.</p>
<p>I&#8217;d love it if there was a way, purely using access modifiers on a member variable, to declare those kinds of asymmetric access modifiers.</p>
<p>In the mean time, though, I&#8217;ll keep writing those damn properties :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven Webster</title>
		<link>http://kuwamoto.org/2006/01/09/getters-setters-and-the-difference-between-java-and-as/comment-page-1/#comment-174</link>
		<dc:creator>Steven Webster</dc:creator>
		<pubDate>Mon, 16 Jan 2006 01:10:47 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=40#comment-174</guid>
		<description>I agree 
</description>
		<content:encoded><![CDATA[<p>I agree</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sho</title>
		<link>http://kuwamoto.org/2006/01/09/getters-setters-and-the-difference-between-java-and-as/comment-page-1/#comment-173</link>
		<dc:creator>Sho</dc:creator>
		<pubDate>Wed, 11 Jan 2006 07:55:01 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=40#comment-173</guid>
		<description>Steven: Great comments. Thanks. BTW, you and I know that we agree on things more than we disagree. :-)</description>
		<content:encoded><![CDATA[<p>Steven: Great comments. Thanks. BTW, you and I know that we agree on things more than we disagree. :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ilya Devèrs</title>
		<link>http://kuwamoto.org/2006/01/09/getters-setters-and-the-difference-between-java-and-as/comment-page-1/#comment-172</link>
		<dc:creator>ilya Devèrs</dc:creator>
		<pubDate>Tue, 10 Jan 2006 11:45:17 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=40#comment-172</guid>
		<description>hmm, the cfm seems to have a hard time handling unicode...</description>
		<content:encoded><![CDATA[<p>hmm, the cfm seems to have a hard time handling unicode&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven Webster</title>
		<link>http://kuwamoto.org/2006/01/09/getters-setters-and-the-difference-between-java-and-as/comment-page-1/#comment-171</link>
		<dc:creator>Steven Webster</dc:creator>
		<pubDate>Mon, 09 Jan 2006 23:18:54 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=40#comment-171</guid>
		<description>Sho ... I agree so much with you, I&#039;ll write that in a book 18 months ago :-)  Excerpted from the book:

Value Object Accessors

In J2EE, we would likely encapsulate our attributes as private attributes, with public getters and setters,
but in ActionScript, we recommend that you consider the following strategy that we adopt at
iteration::two.
In the simplest case in which we expect to be only getting or setting attributes, we choose to declare
the attributes as we’ve just shown, with public variables. Setting or getting attributes on a value
object is then as simple as this:
var account:AccountVO = new AccountVO();
account.accountNumber = “00310712”;
mx.core.Application.alert( “Account Number is “+account.accountNumber );
If the requirement on our value objects becomes more complex; perhaps we can do something a little
more clever in setting an attribute, for instance. Then we can encapsulate it by adding getter and
setter methods for the attribute.
5666 CH20 4/14/04 10:30 PM Page 23
24 Chapter 20 Flex Integration with J2EE
In ActionScript 2.0, we can use a feature known as implicit getters and setters and perform the following
refactoring:
public get accountNumber():String;
public set accountNumber( account:String )
{
this._accountNumber = “RN/”+account;
}
private var _accountNumber:String;
In this refactoring, we change the access of our accountNumber attribute from public to private, and
rename the attribute. (At iteration::two, our convention is to prefix with an underscore, although
many Macromedia classes use underscores in their implementations—and the compiler might warn
you if you happen to clash.) We then use the notation for an implicit getter and setter function, with
our function containing the same name we had for our public attribute. This then ensures that the
following code calls our setter—the implicit getter and setter ensure that a function call is treated as
if it were an attribute:
account.accountNumber = “00310712”;
In the preceding example, our motivation for the refactoring is shown as a requirement that
account numbers be prefixed with the fixed length string “RN/”.
This refactoring allows us to migrate from public attributes to public implicit getters and setter,
without affecting any client code (code that performs gets or sets).
We recommend this strategy over coding your own Java Bean style getters and setters.


Glad to see us agreeing on something !</description>
		<content:encoded><![CDATA[<p>Sho &#8230; I agree so much with you, I&#8217;ll write that in a book 18 months ago :-)  Excerpted from the book:</p>
<p>Value Object Accessors</p>
<p>In J2EE, we would likely encapsulate our attributes as private attributes, with public getters and setters,<br />
but in ActionScript, we recommend that you consider the following strategy that we adopt at<br />
iteration::two.<br />
In the simplest case in which we expect to be only getting or setting attributes, we choose to declare<br />
the attributes as we’ve just shown, with public variables. Setting or getting attributes on a value<br />
object is then as simple as this:<br />
var account:AccountVO = new AccountVO();<br />
account.accountNumber = “00310712”;<br />
mx.core.Application.alert( “Account Number is “+account.accountNumber );<br />
If the requirement on our value objects becomes more complex; perhaps we can do something a little<br />
more clever in setting an attribute, for instance. Then we can encapsulate it by adding getter and<br />
setter methods for the attribute.<br />
5666 CH20 4/14/04 10:30 PM Page 23<br />
24 Chapter 20 Flex Integration with J2EE<br />
In ActionScript 2.0, we can use a feature known as implicit getters and setters and perform the following<br />
refactoring:<br />
public get accountNumber():String;<br />
public set accountNumber( account:String )<br />
{<br />
this._accountNumber = “RN/”+account;<br />
}<br />
private var _accountNumber:String;<br />
In this refactoring, we change the access of our accountNumber attribute from public to private, and<br />
rename the attribute. (At iteration::two, our convention is to prefix with an underscore, although<br />
many Macromedia classes use underscores in their implementations—and the compiler might warn<br />
you if you happen to clash.) We then use the notation for an implicit getter and setter function, with<br />
our function containing the same name we had for our public attribute. This then ensures that the<br />
following code calls our setter—the implicit getter and setter ensure that a function call is treated as<br />
if it were an attribute:<br />
account.accountNumber = “00310712”;<br />
In the preceding example, our motivation for the refactoring is shown as a requirement that<br />
account numbers be prefixed with the fixed length string “RN/”.<br />
This refactoring allows us to migrate from public attributes to public implicit getters and setter,<br />
without affecting any client code (code that performs gets or sets).<br />
We recommend this strategy over coding your own Java Bean style getters and setters.</p>
<p>Glad to see us agreeing on something !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sho</title>
		<link>http://kuwamoto.org/2006/01/09/getters-setters-and-the-difference-between-java-and-as/comment-page-1/#comment-170</link>
		<dc:creator>Sho</dc:creator>
		<pubDate>Mon, 09 Jan 2006 22:53:12 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=40#comment-170</guid>
		<description>Totally agreed, Ilya, although it does depend on the size and nature of your project. For a one person Java project, refactoring is not a problem. For a project with lots of team members, or with an interface that may be used by other people, refactoring is sometimes not practical. 

It never occured to me that Ruby&#039;s optional parentheses amount to the same kind of freedom. (I&#039;ve never actually written a program in Ruby) Thanks for that insight.</description>
		<content:encoded><![CDATA[<p>Totally agreed, Ilya, although it does depend on the size and nature of your project. For a one person Java project, refactoring is not a problem. For a project with lots of team members, or with an interface that may be used by other people, refactoring is sometimes not practical. </p>
<p>It never occured to me that Ruby&#8217;s optional parentheses amount to the same kind of freedom. (I&#8217;ve never actually written a program in Ruby) Thanks for that insight.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ilya Devèrs</title>
		<link>http://kuwamoto.org/2006/01/09/getters-setters-and-the-difference-between-java-and-as/comment-page-1/#comment-169</link>
		<dc:creator>ilya Devèrs</dc:creator>
		<pubDate>Mon, 09 Jan 2006 22:48:02 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=40#comment-169</guid>
		<description>That is what is cool about AS. In Java classes i started doing it also, for quick value transfer objects and internal classes that shuttle data back and forth between requests and such.
Too bad the style checker on the project forced me to rewrite it...

I am doing a lot of Ruby now as well, and there it is the same (as you can leave off the ( ) in a method call. so one also have the benefit that later on one can change it without refactoring a lot of code.

But honestely, with eclipse and intelliJ, what is wrong with some refactoring. As long you know you are not working on a API or some infrastructural part, how big is the chance, really, that later on you decide to hide a public member and instead handle it with a getter... and what is so bad in refactoring then...

really, i tend to become more and more pragmatic about this kind of thing...</description>
		<content:encoded><![CDATA[<p>That is what is cool about AS. In Java classes i started doing it also, for quick value transfer objects and internal classes that shuttle data back and forth between requests and such.<br />
Too bad the style checker on the project forced me to rewrite it&#8230;</p>
<p>I am doing a lot of Ruby now as well, and there it is the same (as you can leave off the ( ) in a method call. so one also have the benefit that later on one can change it without refactoring a lot of code.</p>
<p>But honestely, with eclipse and intelliJ, what is wrong with some refactoring. As long you know you are not working on a API or some infrastructural part, how big is the chance, really, that later on you decide to hide a public member and instead handle it with a getter&#8230; and what is so bad in refactoring then&#8230;</p>
<p>really, i tend to become more and more pragmatic about this kind of thing&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sho</title>
		<link>http://kuwamoto.org/2006/01/09/getters-setters-and-the-difference-between-java-and-as/comment-page-1/#comment-168</link>
		<dc:creator>Sho</dc:creator>
		<pubDate>Mon, 09 Jan 2006 22:23:56 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=40#comment-168</guid>
		<description>Great article, Darron, and thanks for the link, Tiago.</description>
		<content:encoded><![CDATA[<p>Great article, Darron, and thanks for the link, Tiago.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tiago Simoes</title>
		<link>http://kuwamoto.org/2006/01/09/getters-setters-and-the-difference-between-java-and-as/comment-page-1/#comment-167</link>
		<dc:creator>Tiago Simoes</dc:creator>
		<pubDate>Mon, 09 Jan 2006 21:58:39 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=40#comment-167</guid>
		<description>Dido

&lt;a href=&quot;http://softwareaddiction.blogspot.com/2005/10/public-property-keep-out.html&quot; rel=&quot;nofollow&quot;&gt;http://softwareaddiction.blogspot.com/2005/10/public-property-keep-out.html&lt;/a&gt;

The problem with Java is that you have to write over-engineered code</description>
		<content:encoded><![CDATA[<p>Dido</p>
<p><a href="http://softwareaddiction.blogspot.com/2005/10/public-property-keep-out.html" rel="nofollow">http://softwareaddiction.blogspot.com/2005/10/public-property-keep-out.html</a></p>
<p>The problem with Java is that you have to write over-engineered code</p>
]]></content:encoded>
	</item>
</channel>
</rss>
