<?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: final &#8211; just say no?</title>
	<atom:link href="http://www.magpiebrain.com/2004/06/13/final-just-say-no/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.magpiebrain.com/2004/06/13/final-just-say-no/</link>
	<description>The blog of Sam Newman</description>
	<lastBuildDate>Tue, 17 Aug 2010 11:10:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: R.J.</title>
		<link>http://www.magpiebrain.com/2004/06/13/final-just-say-no/comment-page-1/#comment-2201</link>
		<dc:creator>R.J.</dc:creator>
		<pubDate>Tue, 15 Jun 2004 19:25:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.magpiebrain.com/2004/06/13/final-just-say-no/#comment-2201</guid>
		<description>I definitely agree that over-use of the final keyword can cause problems. However, that&#039;s a product of bad design decisions, not the feature itself. The same could be said for use of the public keyword to continue that thread.

The reason I brought up data encapsulation (and really, this wasn&#039;t the best choice of words because encapsulation implies protecting data from OUTSIDE influences, and an inherited member is not truly outside...) is because all too often the situations which elicit the use of the final keyword are situations where an algorithm must perform a certain way for preconditions and postconditions to be ensured safely (often in conjunction with the template method pattern, or something of the sort). I can certainly see a possibility where a method being overriden that was never intended to be swapped out could cause data corruption, therefore producing similar effects to an API that can produce corrupt data.

I don&#039;t see the final keyword as being the issue; more-so bad uses of the keyword.

Also, I&#039;ve always found it to be a tenuous line to walk when balancing ease of testing and confidence of design.  It seems like often times the two conflict (primarily because testing requires some degree of visibility to data).</description>
		<content:encoded><![CDATA[<p>I definitely agree that over-use of the final keyword can cause problems. However, that&#8217;s a product of bad design decisions, not the feature itself. The same could be said for use of the public keyword to continue that thread.</p>
<p>The reason I brought up data encapsulation (and really, this wasn&#8217;t the best choice of words because encapsulation implies protecting data from OUTSIDE influences, and an inherited member is not truly outside&#8230;) is because all too often the situations which elicit the use of the final keyword are situations where an algorithm must perform a certain way for preconditions and postconditions to be ensured safely (often in conjunction with the template method pattern, or something of the sort). I can certainly see a possibility where a method being overriden that was never intended to be swapped out could cause data corruption, therefore producing similar effects to an API that can produce corrupt data.</p>
<p>I don&#8217;t see the final keyword as being the issue; more-so bad uses of the keyword.</p>
<p>Also, I&#8217;ve always found it to be a tenuous line to walk when balancing ease of testing and confidence of design.  It seems like often times the two conflict (primarily because testing requires some degree of visibility to data).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam Newman</title>
		<link>http://www.magpiebrain.com/2004/06/13/final-just-say-no/comment-page-1/#comment-2200</link>
		<dc:creator>Sam Newman</dc:creator>
		<pubDate>Mon, 14 Jun 2004 19:58:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.magpiebrain.com/2004/06/13/final-just-say-no/#comment-2200</guid>
		<description>This is certainly not an argument against data encapsulation - in fact I find it hard to see how Data Encapsulation can be helped by final (if you don&#039;t want data/methods accessed via a subclass or proxy, then make them private!). API formality is a concept I admit I know little about, unless you are talking about creation of well defined API&#039;s - again I don&#039;t see how final applies to this, except in a situation where you are using it to enforce an API invariants.

Some would argue that everything _should_ be public - I would not go as far, however you are being incredibly restrictive if you don&#039;t use final carefully. The fact that String is final has never been a problem - however my problems with NakedClass being final have been made worse by virtue of the problems associated with creating instances of this class.</description>
		<content:encoded><![CDATA[<p>This is certainly not an argument against data encapsulation &#8211; in fact I find it hard to see how Data Encapsulation can be helped by final (if you don&#8217;t want data/methods accessed via a subclass or proxy, then make them private!). API formality is a concept I admit I know little about, unless you are talking about creation of well defined API&#8217;s &#8211; again I don&#8217;t see how final applies to this, except in a situation where you are using it to enforce an API invariants.</p>
<p>Some would argue that everything _should_ be public &#8211; I would not go as far, however you are being incredibly restrictive if you don&#8217;t use final carefully. The fact that String is final has never been a problem &#8211; however my problems with NakedClass being final have been made worse by virtue of the problems associated with creating instances of this class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: R.J.</title>
		<link>http://www.magpiebrain.com/2004/06/13/final-just-say-no/comment-page-1/#comment-2199</link>
		<dc:creator>R.J.</dc:creator>
		<pubDate>Mon, 14 Jun 2004 19:41:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.magpiebrain.com/2004/06/13/final-just-say-no/#comment-2199</guid>
		<description>This almost sounds vaguely like an argument against encapsulation and API formality. Although using final is, indeed, a way to restrict the behavior of an individual who is extending your component, I don&#039;t see how that is any different really that restricting an individual who is using your component (as, for example, composition is very similar to inheritance).
Inheritance is just another tool in the OO developers toolbag, and final is just another way to ensure that behavior from point a to point b is correct. All things considered, Can&#039;t the same be said for private variables, constructor initialized arguments, and whatever else? Why use anything but &#039;public&#039; for that matter? I personally rarely use the &#039;final&#039; keyword in regards to anything but variables; there aren&#039;t a lot of cases in the software I develop where it is completely relevant. However, I do recognize its value in ensuring the correctness of operation in context to a framework.

In some ways it can be said that the essense of most of the architectual concepts we have in Java (and other languages) are to solve 1 of 2 problems. 1.) Complexity. 2.) External code intrusion.</description>
		<content:encoded><![CDATA[<p>This almost sounds vaguely like an argument against encapsulation and API formality. Although using final is, indeed, a way to restrict the behavior of an individual who is extending your component, I don&#8217;t see how that is any different really that restricting an individual who is using your component (as, for example, composition is very similar to inheritance).<br />
Inheritance is just another tool in the OO developers toolbag, and final is just another way to ensure that behavior from point a to point b is correct. All things considered, Can&#8217;t the same be said for private variables, constructor initialized arguments, and whatever else? Why use anything but &#8216;public&#8217; for that matter? I personally rarely use the &#8216;final&#8217; keyword in regards to anything but variables; there aren&#8217;t a lot of cases in the software I develop where it is completely relevant. However, I do recognize its value in ensuring the correctness of operation in context to a framework.</p>
<p>In some ways it can be said that the essense of most of the architectual concepts we have in Java (and other languages) are to solve 1 of 2 problems. 1.) Complexity. 2.) External code intrusion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://www.magpiebrain.com/2004/06/13/final-just-say-no/comment-page-1/#comment-2198</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Mon, 14 Jun 2004 17:08:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.magpiebrain.com/2004/06/13/final-just-say-no/#comment-2198</guid>
		<description>One place where final classes are needed is in creating immutable value types. If the class isn&#039;t final, someone can create a mutable subtype. This is why java.lang.String, for example, is final... it&#039;s the only way to put immutability into its contract.I do recommend, though, that any such value type implement an (immutable) interface so that the objects can be decorated. This should also allow mock objects to be substituted, although (at least offhand) it seems to me that mocking of value types would be rather unnecessary.</description>
		<content:encoded><![CDATA[<p>One place where final classes are needed is in creating immutable value types. If the class isn&#8217;t final, someone can create a mutable subtype. This is why java.lang.String, for example, is final&#8230; it&#8217;s the only way to put immutability into its contract.I do recommend, though, that any such value type implement an (immutable) interface so that the objects can be decorated. This should also allow mock objects to be substituted, although (at least offhand) it seems to me that mocking of value types would be rather unnecessary.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
