<?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/">
<channel>
	<title>Comments on: Annoying Patterns: The Hidden &#8216;On&#8217; Switch</title>
	<link>http://squadlimber.com/chris/2007/03/15/anti-patterns-the-hidden-on-switch/</link>
	<description>software development that works...or something</description>
	<pubDate>Fri, 21 Nov 2008 09:04:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>

	<item>
		<title>by: Duncan Pierce</title>
		<link>http://squadlimber.com/chris/2007/03/15/anti-patterns-the-hidden-on-switch/#comment-6</link>
		<pubDate>Fri, 06 Apr 2007 13:42:24 +0000</pubDate>
		<guid>http://squadlimber.com/chris/2007/03/15/anti-patterns-the-hidden-on-switch/#comment-6</guid>
					<description>Yep, this kind of thing is really irritating. Sometimes you feel like there's a whole hidden state machine in there.

&lt;code&gt;
api.doStuff(1);
api.doStuff(2);

Exception: doStuff(1) called without init()

api.init();
api.doStuff(1);
api.doStuff(2);

Exception: doStuff(2) called without finish()

api.init();
api.doStuff(1);
api.finish();
api.doStuff(2);
// aargh - should there be a finish() here?
}
&lt;/code&gt;

If the code is able to validate its own state it ought to be able to manage it for you too. The fact that it can't is usually down to poor API design: they often carry too much state.</description>
		<content:encoded><![CDATA[<p>Yep, this kind of thing is really irritating. Sometimes you feel like there&#8217;s a whole hidden state machine in there.</p>
<p><code><br />
api.doStuff(1);<br />
api.doStuff(2);</p>
<p>Exception: doStuff(1) called without init()</p>
<p>api.init();<br />
api.doStuff(1);<br />
api.doStuff(2);</p>
<p>Exception: doStuff(2) called without finish()</p>
<p>api.init();<br />
api.doStuff(1);<br />
api.finish();<br />
api.doStuff(2);<br />
// aargh - should there be a finish() here?<br />
}<br />
</code></p>
<p>If the code is able to validate its own state it ought to be able to manage it for you too. The fact that it can&#8217;t is usually down to poor API design: they often carry too much state.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
