<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.5" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>chris clarke</title>
	<link>http://squadlimber.com/chris</link>
	<description>software development that works...or something</description>
	<pubDate>Mon, 07 Apr 2008 23:14:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>
	<language>en</language>
			<item>
		<title>Annoying Patterns: Setter Injection</title>
		<link>http://squadlimber.com/chris/2007/05/02/annoying-patterns-setter-injection/</link>
		<comments>http://squadlimber.com/chris/2007/05/02/annoying-patterns-setter-injection/#comments</comments>
		<pubDate>Wed, 02 May 2007 20:45:11 +0000</pubDate>
		<dc:creator>chris.probably</dc:creator>
		
		<category>Annoying Patterns</category>

		<guid isPermaLink="false">http://squadlimber.com/chris/2007/05/02/annoying-patterns-setter-injection/</guid>
		<description><![CDATA[What do I have to do to get this object to work in the way I want?
Does setting some things rely on having set something else?
With all these public setter methods the objects state can change throughout it&#8217;s life.  If I have to pass references to this object around maybe I don&#8217;t want people [...]]]></description>
			<content:encoded><![CDATA[<p>What do I have to do to get this object to work in the way I want?</p>
<p>Does setting some things rely on having set something else?</p>
<p>With all these public setter methods the objects state can change throughout it&#8217;s life.  If I have to pass references to this object around maybe I don&#8217;t want people changing it&#8217;s state.</p>
]]></content:encoded>
			<wfw:commentRss>http://squadlimber.com/chris/2007/05/02/annoying-patterns-setter-injection/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Annoying Patterns: Saying what you&#8217;re about to do</title>
		<link>http://squadlimber.com/chris/2007/04/18/annoying-patterns-saying-what-youre-about-to-do/</link>
		<comments>http://squadlimber.com/chris/2007/04/18/annoying-patterns-saying-what-youre-about-to-do/#comments</comments>
		<pubDate>Wed, 18 Apr 2007 17:47:11 +0000</pubDate>
		<dc:creator>chris.probably</dc:creator>
		
		<category>Annoying Patterns</category>

		<guid isPermaLink="false">http://squadlimber.com/chris/2007/04/18/annoying-patterns-saying-what-youre-about-to-do/</guid>
		<description><![CDATA[This pattern is best demonstrated with a few examples:

// Get a connection
Connection connection = ConnectionFactory.getConnection&#40;&#41;;
&#160;

// Send the message
connection.send&#40;&#41;;
&#160;

// Start all the servers
for &#40;Server server : serverList&#41; &#123;
&#160; &#160; server.start&#40;&#41;;
&#125;
&#160;
Basically, the comment is describing what you are doing on the next line, and is just not needed.
Sometimes the comments are telling you something, for example:

// Send [...]]]></description>
			<content:encoded><![CDATA[<p>This pattern is best demonstrated with a few examples:</p>
<div class="java" style="margin: 35px; border: 1px dashed #eee; font-family: Arial, Monaco, Verdana, monospace; padding: 1em; color: black; background: #fcfcfc; overflow: auto;"><br />
<span style="color: #808080; font-style: italic;">// Get a connection</span><br />
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AConnection+java.sun.com&amp;bntI=I%27m%20Feeling%20Lucky"><span style="color: #000080;">Connection</span></a> connection = ConnectionFactory.<span style="color: #000000;">getConnection</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp;</div>
<div class="java" style="margin: 35px; border: 1px dashed #eee; font-family: Arial, Monaco, Verdana, monospace; padding: 1em; color: black; background: #fcfcfc; overflow: auto;"><br />
<span style="color: #808080; font-style: italic;">// Send the message</span><br />
connection.<span style="color: #000000;">send</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp;</div>
<div class="java" style="margin: 35px; border: 1px dashed #eee; font-family: Arial, Monaco, Verdana, monospace; padding: 1em; color: black; background: #fcfcfc; overflow: auto;"><br />
<span style="color: #808080; font-style: italic;">// Start all the servers</span><br />
<span style="color: #000080;">for</span> <span style="color: #000000;">&#40;</span>Server server : serverList<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; server.<span style="color: #000000;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
<span style="color: #000000;">&#125;</span><br />
&nbsp;</div>
<p>Basically, the comment is describing what you are doing on the next line, and is just not needed.<br />
Sometimes the comments are telling you something, for example:</p>
<div class="java" style="margin: 35px; border: 1px dashed #eee; font-family: Arial, Monaco, Verdana, monospace; padding: 1em; color: black; background: #fcfcfc; overflow: auto;"><br />
<span style="color: #808080; font-style: italic;">// Send the message to everyone</span><br />
connection.<span style="color: #000000;">send</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp;</div>
<p>Could perhaps be telling you that a method needs to be renamed:</p>
<div class="java" style="margin: 35px; border: 1px dashed #eee; font-family: Arial, Monaco, Verdana, monospace; padding: 1em; color: black; background: #fcfcfc; overflow: auto;"><br />
connection.<span style="color: #000000;">sendTheMessageToEveryone</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp;</div>
<p>Then the comment can be removed and it is clear what the code is doing.
</p>
]]></content:encoded>
			<wfw:commentRss>http://squadlimber.com/chris/2007/04/18/annoying-patterns-saying-what-youre-about-to-do/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Annoying Patterns: The Hidden &#8216;On&#8217; Switch</title>
		<link>http://squadlimber.com/chris/2007/03/15/anti-patterns-the-hidden-on-switch/</link>
		<comments>http://squadlimber.com/chris/2007/03/15/anti-patterns-the-hidden-on-switch/#comments</comments>
		<pubDate>Thu, 15 Mar 2007 23:12:26 +0000</pubDate>
		<dc:creator>chris.probably</dc:creator>
		
		<category>Annoying Patterns</category>

		<guid isPermaLink="false">http://squadlimber.com/chris/2007/03/15/anti-patterns-the-hidden-on-switch/</guid>
		<description><![CDATA[The hidden &#8216;on&#8217; switch is a method that you need to call on an object before it starts actually working.  Specifically, the object does not make it clear that you need to flick the &#8216;on&#8217; switch when you start calling methods before turning it &#8216;on&#8217;.
A couple of examples:
javax.jms.Connection:
connection.start&#40;&#41;
If you don&#8217;t call start() it will [...]]]></description>
			<content:encoded><![CDATA[<p>The hidden &#8216;on&#8217; switch is a method that you need to call on an object before it starts actually working.  Specifically, the object does not make it clear that you need to flick the &#8216;on&#8217; switch when you start calling methods before turning it &#8216;on&#8217;.</p>
<p>A couple of examples:</p>
<p><em>javax.jms.Connection:</em></p>
<div class="java" style="margin: 35px; border: 1px dashed #eee; font-family: Arial, Monaco, Verdana, monospace; padding: 1em; color: black; background: #fcfcfc; overflow: auto;">connection.<span style="color: #000000;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div>
<p>If you don&#8217;t call <em>start()</em> it will appear to be perfectly happy but nothing will happen.</p>
<p><em>org.apache.tools.ant.Project:</em></p>
<div class="java" style="margin: 35px; border: 1px dashed #eee; font-family: Arial, Monaco, Verdana, monospace; padding: 1em; color: black; background: #fcfcfc; overflow: auto;">project.<span style="color: #000000;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div>
<p>If you don&#8217;t call <em>init()</em> it won&#8217;t tell you that <em>init()</em> needs to be called, instead it will say something like &#8220;Could not create task or type of type: property.&#8221;</p>
<h3>Possible Solutions?</h3>
<p>The JMS one is quite tricky because you want set up all your listeners before you start the connection - dunno.  With the ant one, you could put <i>init()</i> code in the <i>Project</i> constructor (duh) or use a flag:</p>
<div class="java" style="margin: 35px; border: 1px dashed #eee; font-family: Arial, Monaco, Verdana, monospace; padding: 1em; color: black; background: #fcfcfc; overflow: auto;"><br />
<span style="color: #000080;">if</span> <span style="color: #000000;">&#40;</span>! initCalled<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000080;">throw</span> <span style="color: #000080;">new</span> YouForgotToCallInitYouMoronException<span style="color: #000000;">&#40;</span><span style="color: #008000;">&quot;call init() first&quot;</span><span style="color: #000000;">&#41;</span>;<br />
<span style="color: #000000;">&#125;</span><br />
&nbsp;</div>
]]></content:encoded>
			<wfw:commentRss>http://squadlimber.com/chris/2007/03/15/anti-patterns-the-hidden-on-switch/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
