<?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: What Properties in Java Should Have Looked Like</title>
	<atom:link href="http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/feed/" rel="self" type="application/rss+xml" />
	<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/</link>
	<description>Longer than a blog; shorter than a book</description>
	<lastBuildDate>Wed, 08 Feb 2012 21:45:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: When the community kills innovation &#124; ICaffeine</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/comment-page-1/#comment-939630</link>
		<dc:creator>When the community kills innovation &#124; ICaffeine</dc:creator>
		<pubDate>Sun, 22 Jan 2012 13:15:38 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-939630</guid>
		<description>[...] Once again, I&#8217;m impressed. The above is from a comment in this blog post. I remember admiring java for what it offered back then: innovation, garbage collection to the [...]</description>
		<content:encoded><![CDATA[<p>[...] Once again, I&#8217;m impressed. The above is from a comment in this blog post. I remember admiring java for what it offered back then: innovation, garbage collection to the [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Önder Teker</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/comment-page-1/#comment-558226</link>
		<dc:creator>Önder Teker</dc:creator>
		<pubDate>Tue, 21 Dec 2010 20:45:17 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-558226</guid>
		<description>I think there may be a way to support properties in the simplest form, that&#039;s using &#039;.&#039; instead of &#039;set&#039; or &#039;get&#039;. There may be an annotation such as &#039;@PropertySupported&#039; and if a class has this annotation it&#039;s properties could be called in the simple form. An alternative to this is to support properties by default and mark old classes with problems such as java.awt.Point with an annotation such as &#039;@PropertyUnsupported&#039;. In general, I support every feature simplifying the syntax because I believe the only reason for the other languages to exist is simplicity in their syntax. If Java had a simpler syntax, nobody would care about the other languages, especially scripting ones. All of their white paper or documentation talks about simple their syntax.</description>
		<content:encoded><![CDATA[<p>I think there may be a way to support properties in the simplest form, that&#8217;s using &#8216;.&#8217; instead of &#8216;set&#8217; or &#8216;get&#8217;. There may be an annotation such as &#8216;@PropertySupported&#8217; and if a class has this annotation it&#8217;s properties could be called in the simple form. An alternative to this is to support properties by default and mark old classes with problems such as java.awt.Point with an annotation such as &#8216;@PropertyUnsupported&#8217;. In general, I support every feature simplifying the syntax because I believe the only reason for the other languages to exist is simplicity in their syntax. If Java had a simpler syntax, nobody would care about the other languages, especially scripting ones. All of their white paper or documentation talks about simple their syntax.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean Noble</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/comment-page-1/#comment-441597</link>
		<dc:creator>Sean Noble</dc:creator>
		<pubDate>Wed, 21 Oct 2009 18:48:34 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-441597</guid>
		<description>Based on blog post &lt;a href=&quot;http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/&quot; rel=&quot;nofollow&quot;&gt;http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/&lt;/a&gt;:

&quot;Properties are bad and should not be allowed in Java&quot; - LOL no properties (have to laugh)

&quot;Public field access is mostly understood as a fast, failsafe operation but “property access” is NOT&quot; - I&#039;m afraid I have to be the one to tell you that&#039;s the whole point (abstraction at the cost of performance - let the developers decide the intended use) LOL

&quot;I like this syntax to disappear anyway&quot; - So why you bringing it up as a point? LOL

&quot;It’s next to impossible to get this right in the compiler&quot; - Really? Heard of .NET? LOL

&quot;Look at how badly it’s broken in C#&quot; - Um, reflection works like a charm - we emit code and properties at runtime.  More than 10 people seem to be ok with the system, so I&#039;d say that it&#039;s not really broken LOL

&quot;More and more C# programmers are warning adepts *not to use* properties and to write explicit accessors instead&quot; Yeah right! LOL



... Thanks very much for providing my entertainment for the day (this post and the comments).  Ah man, I couldn&#039;t stop laughing.  I have to give them props, if Java &quot;programmers&quot; do have one useful skill, if nothing else, it&#039;s that they sure are funny.  Next thing you know they&#039;ll be recommending to not JIT anything and go backwards by always compiling at runtime.



-Sean Noble

-----------
This blog post comment is designed offer humorous reflection upon why in the world Java 7 still doesn&#039;t have properties.  Shows why Java&#039;s not nearly as popular as it could be.  Seriously though, good luck getting intelligent people in place as the decision makers.  Seems like yall have your work cut out for you.  Best wishes.

 </description>
		<content:encoded><![CDATA[<p>Based on blog post <a href="http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/" rel="nofollow">http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/</a>:</p>
<p>&#8220;Properties are bad and should not be allowed in Java&#8221; &#8211; LOL no properties (have to laugh)</p>
<p>&#8220;Public field access is mostly understood as a fast, failsafe operation but “property access” is NOT&#8221; &#8211; I&#8217;m afraid I have to be the one to tell you that&#8217;s the whole point (abstraction at the cost of performance &#8211; let the developers decide the intended use) LOL</p>
<p>&#8220;I like this syntax to disappear anyway&#8221; &#8211; So why you bringing it up as a point? LOL</p>
<p>&#8220;It’s next to impossible to get this right in the compiler&#8221; &#8211; Really? Heard of .NET? LOL</p>
<p>&#8220;Look at how badly it’s broken in C#&#8221; &#8211; Um, reflection works like a charm &#8211; we emit code and properties at runtime.  More than 10 people seem to be ok with the system, so I&#8217;d say that it&#8217;s not really broken LOL</p>
<p>&#8220;More and more C# programmers are warning adepts *not to use* properties and to write explicit accessors instead&#8221; Yeah right! LOL</p>
<p>&#8230; Thanks very much for providing my entertainment for the day (this post and the comments).  Ah man, I couldn&#8217;t stop laughing.  I have to give them props, if Java &#8220;programmers&#8221; do have one useful skill, if nothing else, it&#8217;s that they sure are funny.  Next thing you know they&#8217;ll be recommending to not JIT anything and go backwards by always compiling at runtime.</p>
<p>-Sean Noble</p>
<p>&#8212;&#8212;&#8212;&#8211;<br />
This blog post comment is designed offer humorous reflection upon why in the world Java 7 still doesn&#8217;t have properties.  Shows why Java&#8217;s not nearly as popular as it could be.  Seriously though, good luck getting intelligent people in place as the decision makers.  Seems like yall have your work cut out for you.  Best wishes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chad Grant</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/comment-page-1/#comment-194397</link>
		<dc:creator>Chad Grant</dc:creator>
		<pubDate>Fri, 22 Feb 2008 09:00:21 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-194397</guid>
		<description>&quot;More and more C# programmers are warning adepts *not to use* properties and to write explicit accessors instead. Come to think of it, this was meant to be a real advantage and boost over Java and now most experienced C# programmers prefer and evangelize the Java way in C#.&quot;

That&#039;s just a flat out lie. There are no c# programmers evangelizing properties as Java does, and if you find one, they&#039;re a moron. Properties are a very important part of the whole .net framework. C# coders live in that framework and to code in the backassward way as the framework would be ignorant.</description>
		<content:encoded><![CDATA[<p>&#8220;More and more C# programmers are warning adepts *not to use* properties and to write explicit accessors instead. Come to think of it, this was meant to be a real advantage and boost over Java and now most experienced C# programmers prefer and evangelize the Java way in C#.&#8221;</p>
<p>That&#8217;s just a flat out lie. There are no c# programmers evangelizing properties as Java does, and if you find one, they&#8217;re a moron. Properties are a very important part of the whole .net framework. C# coders live in that framework and to code in the backassward way as the framework would be ignorant.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JavaSPEKTRUM BlogosphÃ¤re &#187; Blog Archiv &#187; BlogosphÃ¤re (aus JavaSPEKTRUM 02/07)</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/comment-page-1/#comment-62357</link>
		<dc:creator>JavaSPEKTRUM BlogosphÃ¤re &#187; Blog Archiv &#187; BlogosphÃ¤re (aus JavaSPEKTRUM 02/07)</dc:creator>
		<pubDate>Tue, 06 Mar 2007 07:01:38 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-62357</guid>
		<description>[...] Eine gewaltige Debatte hat JavaSE-Plattform-Chef Danny Corward mit seinem Vorschlag angestoÃŸen, Java um das Konzept von Eigenschaften (Properties) zu erweitern, den Zugriff auf &#8220;Ã¶ffentliche&#8221; Attribute also nicht Ã¼ber die JavaBean-Konvention von get- und set-Methoden, sondern Ã¼ber eine spezielle Syntax zu kapseln. Vielfach wird die konkret vorgeschlagene Syntax - ein Pfeil (&#8221;-&gt;&#8221;) wie beim Zeigerzugriff in C++ - kritisiert, so z.B. von Kirk Pepperdine. Weniger syntaktisch, sondern inhaltlich betrachtet Cay Horstmann das Thema. Er zeigt, wie sich 64 Zeilen Code auf 12 zusammenschrumpfen lassen und versucht, die typischen Gegenargumente (&#8221;meine IDE generiert die Bean-Methoden fÃ¼r mich&#8221;, &#8220;Getter und Setter sind sowieso schlechtes Design&#8221;) zu entkrÃ¤ften. Elliotte Rusty Harold beschreibt, wie Java Properties aussehen sollten &#8212; aber auch, warum man sie seiner Meinung nach gar nicht braucht: Seiner Meinung nach reichen die bestehenden Sprachmittel vÃ¶llig aus. Zustimmung dazu gibt es von Dave Megginson (Achtung Schockgefahr: Er vergleicht den Vorschlag mit einer kosmetischen Operation und illustriert die Analogie mit einem Bild eines Popstars, das man MinderjÃ¤hrigen lieber ersparen sollte.) Megginsons und Harolds Ansicht nach sollte man aufhÃ¶ren, Java um immer neue Elemente zu erweitern. Wer andere Konzepte will, mÃ¶ge doch einfach eine andere Sprache verwenden. Mike Champion, bei Microsoft fÃ¼r XML-Standards verantwortlich, verweist in einem Kommentar auf die Analogie zu C#: VÃ¶llig unwichtig, welche Merkmale Microsoft zu Visual Basic hinzufÃ¼gt, C#-Entwickler fragen immer nur danach, wann sie diese auch in ihrer Umgebung nutzen kÃ¶nnen. Wer all den Links gefolgt ist, die unzÃ¤hligen Kommentare gelesen hat und immer noch nicht befriedigt ist, dem seien die Diskussionen bei InfoQ und JavaLobby empfohlen. [...]</description>
		<content:encoded><![CDATA[<p>[...] Eine gewaltige Debatte hat JavaSE-Plattform-Chef Danny Corward mit seinem Vorschlag angestoÃŸen, Java um das Konzept von Eigenschaften (Properties) zu erweitern, den Zugriff auf &#8220;Ã¶ffentliche&#8221; Attribute also nicht Ã¼ber die JavaBean-Konvention von get- und set-Methoden, sondern Ã¼ber eine spezielle Syntax zu kapseln. Vielfach wird die konkret vorgeschlagene Syntax &#8211; ein Pfeil (&#8221;-&gt;&#8221;) wie beim Zeigerzugriff in C++ &#8211; kritisiert, so z.B. von Kirk Pepperdine. Weniger syntaktisch, sondern inhaltlich betrachtet Cay Horstmann das Thema. Er zeigt, wie sich 64 Zeilen Code auf 12 zusammenschrumpfen lassen und versucht, die typischen Gegenargumente (&#8221;meine IDE generiert die Bean-Methoden fÃ¼r mich&#8221;, &#8220;Getter und Setter sind sowieso schlechtes Design&#8221;) zu entkrÃ¤ften. Elliotte Rusty Harold beschreibt, wie Java Properties aussehen sollten &#8212; aber auch, warum man sie seiner Meinung nach gar nicht braucht: Seiner Meinung nach reichen die bestehenden Sprachmittel vÃ¶llig aus. Zustimmung dazu gibt es von Dave Megginson (Achtung Schockgefahr: Er vergleicht den Vorschlag mit einer kosmetischen Operation und illustriert die Analogie mit einem Bild eines Popstars, das man MinderjÃ¤hrigen lieber ersparen sollte.) Megginsons und Harolds Ansicht nach sollte man aufhÃ¶ren, Java um immer neue Elemente zu erweitern. Wer andere Konzepte will, mÃ¶ge doch einfach eine andere Sprache verwenden. Mike Champion, bei Microsoft fÃ¼r XML-Standards verantwortlich, verweist in einem Kommentar auf die Analogie zu C#: VÃ¶llig unwichtig, welche Merkmale Microsoft zu Visual Basic hinzufÃ¼gt, C#-Entwickler fragen immer nur danach, wann sie diese auch in ihrer Umgebung nutzen kÃ¶nnen. Wer all den Links gefolgt ist, die unzÃ¤hligen Kommentare gelesen hat und immer noch nicht befriedigt ist, dem seien die Diskussionen bei InfoQ und JavaLobby empfohlen. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: albert bulawa</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/comment-page-1/#comment-59940</link>
		<dc:creator>albert bulawa</dc:creator>
		<pubDate>Sat, 24 Feb 2007 22:10:37 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-59940</guid>
		<description>Properties are bad and should not be allowed in Java. Of course, it *looks* nice to be able to say foo.x = 4 instead of foo.setX(4) but it&#039;s all there is. All other things being downsides.

1. Public field access is mostly understood as a fast, failsafe operation but &quot;property access&quot; is NOT. With such a syntax you have to prepare yourselves for a = operator (or, in case of the getter, worse still, the . &quot;operator&quot;) throwing at least runtime exceptions. But why disallow checked exceptions on accessors? And the fast bit: property access may use a database ot a webservice or whatever gizmo you can imagine and it may last seconds, not nanoseconds as we are mentally prepared with public fields.
2. What about x = y = z? Setters are void, and for a good reason, but you can&#039;t have x = y = z without breaking this. It is a minor issue, though... and I like this syntax to disappear anyway
3. It&#039;s next to impossible to get this right in the compiler. You should be able to replace the class with properties (a version using simple passthrough or plain public fields to a version using accessors or the other way around) without breaking its clients&#039; binary or source code. That means the compiler has to use indirection anyway because it cannot know whether or when you&#039;re going to replace that library JAR.
4. This must be transparent as well to the Reflection API, and consistently with the source code. Look at how badly it&#039;s broken in C#.

More and more C# programmers are warning adepts *not to use* properties and to write explicit accessors instead. Come to think of it, this was meant to be a real advantage and boost over Java and now most experienced C# programmers prefer and evangelize the Java way in C#. 

So please leave the properties where their place is: in the &quot;failed experiments&quot; drawer.</description>
		<content:encoded><![CDATA[<p>Properties are bad and should not be allowed in Java. Of course, it *looks* nice to be able to say foo.x = 4 instead of foo.setX(4) but it&#8217;s all there is. All other things being downsides.</p>
<p>1. Public field access is mostly understood as a fast, failsafe operation but &#8220;property access&#8221; is NOT. With such a syntax you have to prepare yourselves for a = operator (or, in case of the getter, worse still, the . &#8220;operator&#8221;) throwing at least runtime exceptions. But why disallow checked exceptions on accessors? And the fast bit: property access may use a database ot a webservice or whatever gizmo you can imagine and it may last seconds, not nanoseconds as we are mentally prepared with public fields.<br />
2. What about x = y = z? Setters are void, and for a good reason, but you can&#8217;t have x = y = z without breaking this. It is a minor issue, though&#8230; and I like this syntax to disappear anyway<br />
3. It&#8217;s next to impossible to get this right in the compiler. You should be able to replace the class with properties (a version using simple passthrough or plain public fields to a version using accessors or the other way around) without breaking its clients&#8217; binary or source code. That means the compiler has to use indirection anyway because it cannot know whether or when you&#8217;re going to replace that library JAR.<br />
4. This must be transparent as well to the Reflection API, and consistently with the source code. Look at how badly it&#8217;s broken in C#.</p>
<p>More and more C# programmers are warning adepts *not to use* properties and to write explicit accessors instead. Come to think of it, this was meant to be a real advantage and boost over Java and now most experienced C# programmers prefer and evangelize the Java way in C#. </p>
<p>So please leave the properties where their place is: in the &#8220;failed experiments&#8221; drawer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eamonn McManus</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/comment-page-1/#comment-58037</link>
		<dc:creator>Eamonn McManus</dc:creator>
		<pubDate>Mon, 19 Feb 2007 14:27:33 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-58037</guid>
		<description>This is just a nitpick, but the Java compiler does allow an identifier to begin with $, and always has.</description>
		<content:encoded><![CDATA[<p>This is just a nitpick, but the Java compiler does allow an identifier to begin with $, and always has.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frits Jalvingh</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/comment-page-1/#comment-55603</link>
		<dc:creator>Frits Jalvingh</dc:creator>
		<pubDate>Sun, 11 Feb 2007 14:33:32 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-55603</guid>
		<description>Thanks for so far the best observation on how properties should work in Java! The current proposals using &quot;-&gt;&quot; and such are all crap, and muck up the language. I like your variant using the &#039;property&#039; keyword best; the &#039;$&#039; names look like a kludge.

I agree that it would be a really good idea to reduce the importance of &quot;backwards compatibility&quot; in these discussions. The need for it is often only perceived and not really needed. Take the &quot;Generics&quot; implementations for instance: lots of older code does not compile with -source 1.5. Which is no problem _at all_ because we _have_ -source 1.4! You can easily compile &quot;legacy&quot; code with a legacy version of the language; the only thing you need to keep &quot;backwards compatibility&quot; is to maintain the ability within the JVM to handle the generated code. This is how most &quot;older&quot; code is compiled nowadays anyway.

A good way to see how perceived &quot;backwards compatibility&quot; can really hurt is the Generics implementation. The moronic braindead idiot that allowed for type erasure should be shot! It has reduced the Generics system to a barely functional syntactic layer only, with really stupid limitations (why on EARTH would anyone in his right mind accept a generics implementation which is unable to do class ... new T()&quot; ) AND huge reduced functionality around Reflection and metaprogramming. And the reason for this enormous crappy cludge: they wanted to be backwards compatible with JVM 1.4... Which they aren&#039;t anyway. Horror.

I would also make another point for all the people that do not want to extend the language because they think there are already other (usually more verbose ways) of doing whatever needs to be done. Think for instance about the &quot;enum&quot; functionality introduced in 1.5. A computer language is a way to express a problem solution. How effective you can be in expressing such a solution is a direct advantage: if you have to write &quot;boilerplate&quot; for very common solutions this is a problem of the language! It reduces the visibility of the &quot;real&quot; problem *and* it often reduces the knowledge that the compiler has about the actual thing being done - leading to lousy (or no) error messages or reduced code quality.
To me the plethora of stupid &quot;getXxx&quot; and &quot;setXxx&quot; methods is an indication of a blunder in language design. Saying I can do something in a language does not make it the right way because a good language is supposed to make common things easy.

I would advice people to look at C# for some examples of good language design, not only wrt to the language but also wrt the process: don&#039;t be too afraid for changes.</description>
		<content:encoded><![CDATA[<p>Thanks for so far the best observation on how properties should work in Java! The current proposals using &#8220;-&gt;&#8221; and such are all crap, and muck up the language. I like your variant using the &#8216;property&#8217; keyword best; the &#8216;$&#8217; names look like a kludge.</p>
<p>I agree that it would be a really good idea to reduce the importance of &#8220;backwards compatibility&#8221; in these discussions. The need for it is often only perceived and not really needed. Take the &#8220;Generics&#8221; implementations for instance: lots of older code does not compile with -source 1.5. Which is no problem _at all_ because we _have_ -source 1.4! You can easily compile &#8220;legacy&#8221; code with a legacy version of the language; the only thing you need to keep &#8220;backwards compatibility&#8221; is to maintain the ability within the JVM to handle the generated code. This is how most &#8220;older&#8221; code is compiled nowadays anyway.</p>
<p>A good way to see how perceived &#8220;backwards compatibility&#8221; can really hurt is the Generics implementation. The moronic braindead idiot that allowed for type erasure should be shot! It has reduced the Generics system to a barely functional syntactic layer only, with really stupid limitations (why on EARTH would anyone in his right mind accept a generics implementation which is unable to do class &#8230; new T()&#8221; ) AND huge reduced functionality around Reflection and metaprogramming. And the reason for this enormous crappy cludge: they wanted to be backwards compatible with JVM 1.4&#8230; Which they aren&#8217;t anyway. Horror.</p>
<p>I would also make another point for all the people that do not want to extend the language because they think there are already other (usually more verbose ways) of doing whatever needs to be done. Think for instance about the &#8220;enum&#8221; functionality introduced in 1.5. A computer language is a way to express a problem solution. How effective you can be in expressing such a solution is a direct advantage: if you have to write &#8220;boilerplate&#8221; for very common solutions this is a problem of the language! It reduces the visibility of the &#8220;real&#8221; problem *and* it often reduces the knowledge that the compiler has about the actual thing being done &#8211; leading to lousy (or no) error messages or reduced code quality.<br />
To me the plethora of stupid &#8220;getXxx&#8221; and &#8220;setXxx&#8221; methods is an indication of a blunder in language design. Saying I can do something in a language does not make it the right way because a good language is supposed to make common things easy.</p>
<p>I would advice people to look at C# for some examples of good language design, not only wrt to the language but also wrt the process: don&#8217;t be too afraid for changes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Masklinn</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/comment-page-1/#comment-54023</link>
		<dc:creator>Masklinn</dc:creator>
		<pubDate>Mon, 05 Feb 2007 16:31:09 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-54023</guid>
		<description>&gt; Thatâ€™s why â€˜the first reason doesnâ€™t apply to regular getters/settersâ€™, but does apply to properties. Or am I missing something here?

Yes you are, because a property is not a public field, it doesn&#039;t even have to _back_ a public field.

Let&#039;s give a trivial and non-existent example: you&#039;ve got a property a on your object A.

This means that you can, of course, call A.a and have a result back. Your property is a simple pass-through (ie you could&#039;ve made your `a` field a public field and it would be the same. It _should_ be the same, in fact).

Now you realize that you should change your implementation, and that your private field `a` should really be replaced by a computation based on `b` and `c`, because your `a` private field really doesn&#039;t pull its weight. Are you locked? Nope, just replace your passthrough interface by a computing one: instead of `return a` write `return compute(b, c)` and instead of `a=value` write `b, c = someInverseComputation(value)`. Boom, you&#039;re done. And it&#039;s very often what&#039;s done in Python or Ruby. The _point_  of interface is that they _look_ like public fields (I like to call them &quot;virtual public fields&quot;) but they&#039;re not. This really means that your interface is independent from the implementation, and the only reason why you use a property or a method is whether or not it makes sense.

And if properties and public fields behave the same at the interface-level (meaning that you can declare a public field in an interface, or a property, and they&#039;re declared the same way, as long as there&#039;s either a public field or a property that satisfies the contract everything&#039;s ok) then you don&#039;t have to wrap everything in getters and setters &quot;just in case&quot;, uselessly boosting the number of indirections and making the code less clear: you use public fields, and if you need to &quot;hide&quot; them or change your implementation, just swap them with properties.</description>
		<content:encoded><![CDATA[<p>&gt; Thatâ€™s why â€˜the first reason doesnâ€™t apply to regular getters/settersâ€™, but does apply to properties. Or am I missing something here?</p>
<p>Yes you are, because a property is not a public field, it doesn&#8217;t even have to _back_ a public field.</p>
<p>Let&#8217;s give a trivial and non-existent example: you&#8217;ve got a property a on your object A.</p>
<p>This means that you can, of course, call A.a and have a result back. Your property is a simple pass-through (ie you could&#8217;ve made your `a` field a public field and it would be the same. It _should_ be the same, in fact).</p>
<p>Now you realize that you should change your implementation, and that your private field `a` should really be replaced by a computation based on `b` and `c`, because your `a` private field really doesn&#8217;t pull its weight. Are you locked? Nope, just replace your passthrough interface by a computing one: instead of `return a` write `return compute(b, c)` and instead of `a=value` write `b, c = someInverseComputation(value)`. Boom, you&#8217;re done. And it&#8217;s very often what&#8217;s done in Python or Ruby. The _point_  of interface is that they _look_ like public fields (I like to call them &#8220;virtual public fields&#8221;) but they&#8217;re not. This really means that your interface is independent from the implementation, and the only reason why you use a property or a method is whether or not it makes sense.</p>
<p>And if properties and public fields behave the same at the interface-level (meaning that you can declare a public field in an interface, or a property, and they&#8217;re declared the same way, as long as there&#8217;s either a public field or a property that satisfies the contract everything&#8217;s ok) then you don&#8217;t have to wrap everything in getters and setters &#8220;just in case&#8221;, uselessly boosting the number of indirections and making the code less clear: you use public fields, and if you need to &#8220;hide&#8221; them or change your implementation, just swap them with properties.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johann Thomas</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/comment-page-1/#comment-53952</link>
		<dc:creator>Johann Thomas</dc:creator>
		<pubDate>Mon, 05 Feb 2007 09:00:57 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-53952</guid>
		<description>just another style of property syntax:

Borland Delphi Pascal also has properties (wasn&#039;t it, that the one how developed this language also was the creator of C#) and you can define the names of the getter and setter methods. These will be called, even if you access the property field directly:

[tt]
mybook.count = 3 ; // still calls setCount(...)
 // for following declaration

type
  Book = class
  private
    // User defined attributes
    title: Char;
    FCount: Integer;
    // User defined methods
    procedure setCount(cnt: Integer); virtual;
    ...
  public
    ...
    // Access methods
    function getTitle: Char;
    procedure setTitle(newTitle: Char);
    // Properties
    property count: Integer read FCount write setCount;
  ...
implementation
  ...
[/tt]</description>
		<content:encoded><![CDATA[<p>just another style of property syntax:</p>
<p>Borland Delphi Pascal also has properties (wasn&#8217;t it, that the one how developed this language also was the creator of C#) and you can define the names of the getter and setter methods. These will be called, even if you access the property field directly:</p>
<p>[tt]<br />
mybook.count = 3 ; // still calls setCount(&#8230;)<br />
 // for following declaration</p>
<p>type<br />
  Book = class<br />
  private<br />
    // User defined attributes<br />
    title: Char;<br />
    FCount: Integer;<br />
    // User defined methods<br />
    procedure setCount(cnt: Integer); virtual;<br />
    &#8230;<br />
  public<br />
    &#8230;<br />
    // Access methods<br />
    function getTitle: Char;<br />
    procedure setTitle(newTitle: Char);<br />
    // Properties<br />
    property count: Integer read FCount write setCount;<br />
  &#8230;<br />
implementation<br />
  &#8230;<br />
[/tt]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

