<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wrong.net &#187; Uncategorized</title>
	<atom:link href="http://www.wrong.net/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wrong.net</link>
	<description>Game development done right</description>
	<lastBuildDate>Sun, 14 Mar 2010 07:32:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Levels of Developers</title>
		<link>http://www.wrong.net/2010/03/14/levels-of-developers/</link>
		<comments>http://www.wrong.net/2010/03/14/levels-of-developers/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 07:32:25 +0000</pubDate>
		<dc:creator>Kyoryu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.wrong.net/?p=112</guid>
		<description><![CDATA[Jeff Atwood asks why programmers can&#8217;t, well, program.
I wrote that article in 2007, and I am stunned, but not entirely surprised, to hear that three years later &#8220;the vast majority&#8221; of so-called programmers who apply for a programming job interview are unable to write the smallest of programs.
To some extent, I think he&#8217;s being unfair, [...]]]></description>
			<content:encoded><![CDATA[<p>Jeff Atwood asks why programmers <a href="http://www.codinghorror.com/blog/2010/02/the-nonprogramming-programmer.html" target="_blank">can&#8217;t, well, program</a>.</p>
<blockquote><p>I wrote that article in 2007, and I am stunned, but not entirely surprised, to hear that three years later &#8220;the vast majority&#8221; of so-called programmers who apply for a programming job interview are unable to write the smallest of programs.</p></blockquote>
<p>To some extent, I think he&#8217;s being unfair, although I actually agree with him completely.  One thing I&#8217;ve noticed recently is that there seems to be a bit of a step function in developer ability.  Below this demarcation, developers seem to think of the value of their code entirely in terms of what they can get some library or another to do.  Their programming is almost entirely <em>manipulating</em> objects written by others.  Above this line, developers start thinking of the value of their code primarily being in what they write &#8211; and the code written by others that they have to deal with is, at best, an annoyance.</p>
<p>It&#8217;s not even entirely based on programmer ability.  There can be very good developers capable of doing a lot of things by that kind of manipulation.  There can also be developers that focus on their own code that are very much in the learning stages.  It almost seems to be more about scope, or level of abstraction, than it seems to be about effectiveness or experience.</p>
<p>Taking it a bit further, there seems to be at least 4 of these developmental &#8220;jumps&#8221; that I&#8217;ve recognized.  There&#8217;s probably more &#8211; and the fact that I can&#8217;t see them probably means that I haven&#8217;t achieved them myself, yet.</p>
<ol>
<li>Manipulation of code created by others.  Typified by &#8220;call this library, put the results into this other library.&#8221;</li>
<li>Algorithmic ability &#8211; primarily defines programs by the data transformations done.  Library manipulation is assumed.</li>
<li>Structural ability &#8211; primarily defines work done by the internal structure of the program developed.  Algorithmic ability assumed.</li>
<li>Systems design &#8211; primarily defines value by the overall design of the system, spanning multiple programs.  Structural ability assumed.</li>
</ol>
<p>So the problem with things like the FizzBuzz test, and the number of developers that can&#8217;t hack it, is that FizzBuzz is a &#8220;level 2 developer&#8221; problem.  Developers at the first level, why they might be great at a huge number of tasks, simply don&#8217;t have the tools to solve it, and don&#8217;t usually think it&#8217;s worth solving.  They also tend to think that problems like &#8220;find the least common multiple&#8221; are obscure math problems, and don&#8217;t get that it&#8217;s a test of algorithmic thinking.</p>
<p>A similar problem exists with design patterns.  These operate at the third level or higher.  A developer at the first or second level really has no use for them, or even really the capability to understand them.  Telling a developer at one of those levels that design patterns are &#8220;good&#8221; is just asking for trouble &#8211; without the required understanding, they&#8217;ll try to apply patterns to the wrong problems.</p>
<p>Again, this is not really a value judgement.  There&#8217;s  alot of value in experienced devs who are at that first level &#8211; since they value libraries written by others, they&#8217;ll tend to know the ins and outs of them very well, will know which ones are useful, and will be able to pull things together to make something blindingly fast.  If you want someone to develop a pretty typical CRUD app, that&#8217;s probably what you need.  Guys at the &#8220;higher&#8221; levels probably aren&#8217;t what you want &#8211; since they don&#8217;t care as much about other peoples code, they won&#8217;t be as up on the intricacies or latest libraries.  But, once you get off into areas that aren&#8217;t well-tread, that&#8217;s where you&#8217;ll start to need them.</p>
<p>So are things like FizzBuzz good tests for developers?  Depends.  If you really need a guy to tie some libraries together in a useful way, well, probably not.  You&#8217;re applying a second-level test when you need a first-level developer &#8211; you&#8217;re testing the wrong thing.  But at least it explains how so many programmers &#8220;can&#8217;t program.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrong.net/2010/03/14/levels-of-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why Use Cases Rock</title>
		<link>http://www.wrong.net/2010/02/08/why-use-cases-rock/</link>
		<comments>http://www.wrong.net/2010/02/08/why-use-cases-rock/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 09:02:33 +0000</pubDate>
		<dc:creator>Kyoryu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.wrong.net/?p=102</guid>
		<description><![CDATA[Typical agile-style use cases rock.  Really.
There&#8217;s a pretty common pattern for them, so common that it&#8217;s a part of the whole Behavior-Driven Development idea.  It&#8217;s just:  &#8220;As &#60;role&#62;, I want &#60;feature&#62; so that &#60;benefit&#62;.&#8221;
A lot of people seem to think that this is overly simplistic.  I respectfully disagree.  What this simple format does is tell [...]]]></description>
			<content:encoded><![CDATA[<p>Typical agile-style use cases rock.  Really.</p>
<p>There&#8217;s a pretty common pattern for them, so common that it&#8217;s a part of the whole Behavior-Driven Development idea.  It&#8217;s just:  &#8220;As &lt;role&gt;, I want &lt;feature&gt; so that &lt;benefit&gt;.&#8221;</p>
<p>A lot of people seem to think that this is overly simplistic.  I respectfully disagree.  What this simple format does is tell us the most important things about anything we do, in a way that pages of details about the implementation don&#8217;t.</p>
<p>As &lt;role&gt;:  Tells me who the customer is.  And who the customer is tells me a lot about how I need to expose functionality.</p>
<p>I want to &lt;feature&gt;:  describes what the customer wants.  This is typically where we spend the most effort.</p>
<p>so that &lt;benefit&gt;:  The business value of what we&#8217;re doing &#8211; why it&#8217;s important.</p>
<p>Simplistic?  Maybe, but it does a much better job of reminding us of who our customers are, and what the business value that we&#8217;re trying to produce is, than any other format I&#8217;ve seen.</p>
<p>And, frankly, forgetting who our customers are, and not focusing on business value seems to be a far more frequent problem than not spec-ing features sufficiently up front.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrong.net/2010/02/08/why-use-cases-rock/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ranking vs. Prioritizing</title>
		<link>http://www.wrong.net/2009/07/16/ranking-vs-prioritizing/</link>
		<comments>http://www.wrong.net/2009/07/16/ranking-vs-prioritizing/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 18:44:26 +0000</pubDate>
		<dc:creator>Kyoryu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.wrong.net/?p=94</guid>
		<description><![CDATA[Just finished writing up a list of some &#8217;stuff&#8217; for work (what it was is totally unimportant).  Part of this list included prioritization of the items, and for a first pass I went for three priorities, P1, P2, P3.
After writing the list, I noticed that, as typical for prioritization systems, I ended up with a [...]]]></description>
			<content:encoded><![CDATA[<p>Just finished writing up a list of some &#8217;stuff&#8217; for work (what it was is totally unimportant).  Part of this list included prioritization of the items, and for a first pass I went for three priorities, P1, P2, P3.</p>
<p>After writing the list, I noticed that, as typical for prioritization systems, I ended up with a bunch of stuff in P1, some stuff in P2, and almost nothing in P3.  Since I&#8217;ve seen this anti-pattern before, I decided that I would split them up into groups of equal size.</p>
<p>Boy, was that hard.  Even without complete stack-ranking, coming up with equally-sized groups forced me to think about which of the items were important, and why, in a way that just arbitrarily assigning priorities did not.</p>
<p>After doing this, I&#8217;ve become even more convinced that prioritizing is a waste of time, and that stack ranking in some form is, really, what is needed.  Prioritization alone does not force you to really think about your requirements and what is really important, and seems to inevitably end up with a &#8220;top priority is everything we think we&#8217;ll do, second priority is everything we&#8217;ll do if we have time, and third priority won&#8217;t get done&#8221; schema.</p>
<p>I don&#8217;t know if total stack ranking of every possible feature or work item is necessary, but I think that, at the minimum, you need to have small groups of equal size (probably no more than 5-10 items), and those need to be ranked.  This gives some flexibility in terms of not overly worrying about whether items 1 and 2 should swap (since they&#8217;re both likely to get done), but still acts as a forcing function in that you&#8217;re limited to &#8216;n&#8217; top-priority items.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrong.net/2009/07/16/ranking-vs-prioritizing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How difficult is it to change your code?</title>
		<link>http://www.wrong.net/2009/06/12/how-difficult-is-it-to-change-your-code/</link>
		<comments>http://www.wrong.net/2009/06/12/how-difficult-is-it-to-change-your-code/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 19:43:18 +0000</pubDate>
		<dc:creator>Kyoryu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.wrong.net/2009/06/12/how-difficult-is-it-to-change-your-code/</guid>
		<description><![CDATA[Change happens.&#160; We’re not perfect.&#160; We don’t know everything.&#160; We invariably learn something about the project we’re doing while we’re doing it.
So, code that can easily be changed is better than code that can’t be changed.&#160; But how do we know how easy it is to change code?

Difficulty of changing code is best measured at [...]]]></description>
			<content:encoded><![CDATA[<p>Change happens.&#160; We’re not perfect.&#160; We don’t know everything.&#160; We invariably learn something about the project we’re doing while we’re doing it.</p>
<p>So, code that can easily be changed is better than code that can’t be changed.&#160; But how do we know how easy it is to change code?</p>
<h2></h2>
<h2>Difficulty of changing code is best measured at the class/interface level.</h2>
<p>If you have a lot of classes that are each easily changed, you will be able to change your code easily.&#160; If you have a few classes that are each difficult to change, it will be difficult to change your code.&#160; Even if the total work done is the same.</p>
<h2>The primary measure of difficulty of changing code is the number of consumers it has.</h2>
<p>The more things that know about your code, the harder it is to change.&#160; This is a reason why the universally-loved concept of “the one place that does all X’ almost always fails.</p>
<p>It is easier to change an interface that has one consumer than one with three consumers.&#160; It is easier to change an interface with three consumers than one with twenty consumers.&#160; And if you have one hundred consumers, forget about it.</p>
<p>By consumers, I do not necessarily refer to applications or individuals, rather I refer to classes that refer to any individual class.</p>
<h2>It’s easier to change internal code than public-facing code.</h2>
<p>This is a restatement of the first point.&#160; Published, public-facing code has an infinite number of consumers, making it nearly impossible to change.</p>
<h2>The more implementation details you expose, the harder it is to change your code.</h2>
<p>Public-facing code should, as much as possible, not leak implementation details.&#160; It should reflect the user-facing concepts that are being exposed, and not the implementation details of those concepts.</p>
<p>Not exposing raw types is a good way to do this as well.&#160; If you have a user ID that’s an int right now, it may be somewhat painful to change it to a long later.&#160; However, if you wrap the int in a UserID class, changing it to use a long or even a GUID will become much, much easier.</p>
<h2>The more scenarios you support, the harder it is to change</h2>
<p>If you support a large number of scenarios, it is almost inevitable that assumptions needed for one will spill over into others.</p>
<h2>The more well-defined your code is, the easier it is to change</h2>
<p>If your code has well-defined inputs and outputs, and doesn’t have side effects, it is much easier to change.&#160; While the public entry points may remain difficult to change if they have many consumers, any internal details can be changed arbitrarily, and the correctness of the final code can be verified.</p>
<p>On the other hand, if the behavior of the code is not well-defined, then changing it can become extremely difficult, as consumers may be relying upon existing behavior that is either in error, undocumented (and so likely to change if you touch the implementation), or simply a side effect of the “real” work being done.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrong.net/2009/06/12/how-difficult-is-it-to-change-your-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Checked Exceptions</title>
		<link>http://www.wrong.net/2009/06/09/checked-exceptions/</link>
		<comments>http://www.wrong.net/2009/06/09/checked-exceptions/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 04:57:01 +0000</pubDate>
		<dc:creator>Kyoryu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.wrong.net/2009/06/09/checked-exceptions/</guid>
		<description><![CDATA[Interview with Anders Hejlsberg
This seems to be somewhat of a controversial subject.
On the one hand, we have Java, which forces exceptions to be caught and potentially rethrown.&#160; This is, certainly, something of a pain.
On the other hand, C# doesn’t require anything, and any method can potentially throw any kind of exception.
I can see the points [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.bing.com/search?q=checked+exceptions+c%23&amp;form=MS8TDF&amp;pc=MS8TDF&amp;src=IE-SearchBox" target="_blank">Interview with Anders Hejlsberg</a></p>
<p>This seems to be somewhat of a controversial subject.</p>
<p>On the one hand, we have Java, which forces exceptions to be caught and potentially rethrown.&#160; This is, certainly, something of a pain.</p>
<p>On the other hand, C# doesn’t require <em>anything</em>, and any method can potentially throw any kind of exception.</p>
<p>I can see the points on both sides.&#160; Nothing is&#160; uglier than a bunch of arbitrary try/catch statements in code that do nothing more than rethrow exceptions.&#160; And just blindly swallowing exceptions is even worse.</p>
<p>On the other hand, not really knowing what a method might throw in C# can be really, really annoying at times.</p>
<blockquote><p>Let&#8217;s start with versioning, because the issues are pretty easy to see there. Let&#8217;s say I create a method <code>foo</code> that declares it throws exceptions <code>A</code>, <code>B</code>, and <code>C</code>. In version two of <code>foo</code>, I want to add a bunch of features, and now <code>foo</code> might throw exception <code>D</code>. It is a breaking change for me to add <code>D</code> to the throws clause of that method, because existing caller of that method will almost certainly not handle that exception.</p>
</blockquote>
<p>Well, that’s certainly reasonable.&#160; But, I have to wonder if it’s the right answer?&#160; If you add a bunch of functionality to a class, is it perhaps better to make some new ReallySpiffyFoo class that contains the new functionality, and leave the existing class as it is?</p>
<p>Then again, I’m not a huge fan of growing classes over time – in most cases, I believe you’re better off leaving a well-defined class as-is except for bug fixes, and putting new functionality into a new class (which might internally use the old one).</p>
<blockquote><p>Now, each time you walk up the ladder of aggregation, you have this exponential hierarchy below you of exceptions you have to deal with. You end up having to declare 40 exceptions that you might throw. And once you aggregate that with another subsystem you&#8217;ve got 80 exceptions in your throws clause. It just balloons out of control.</p>
</blockquote>
<p>Another reasonable point.&#160; However, I’d tend to believe that in a case like that, you’ve got a bigger design issue at play.&#160; Why in the world would a business object throw a FileNotFoundException or the like?&#160; At most, it should throw something like a CouldNotLoadDataException.&#160; The fact that the data was to be loaded from a file is completely irrelevant at that level.</p>
<p>I also suspect that Anders is looking at this mostly from the viewpoint of a language and framework developer.&#160; As a framework developer, he expects code he writes to be called by other people, and they can certainly look up what exceptions are being thrown.&#160; That’s reasonable.</p>
<p>However, if I’m using an interface as an extensibility point, it’s a slightly different story.&#160; Now I’m importing someone else’s code into my application, and I have <em>no idea</em> of what it might throw when I call it.&#160; If that&#8217; doesn’t sound scary, I don’t know what would.&#160; At this point my options are either let my app crash when I make any arbitrary call, or catch Exception directly.&#160; Neither of those are, in my mind, really good solutions.</p>
<p>What I’d <em>like</em> to see is defined exceptions, but not necessarily checked exceptions.&#160; I’d like to know what exceptions a method may throw, but I don’t want to necessarily be forced to catch them.&#160; In my mind, the exceptions you throw are effectively part of your API, especially when looked at from role-based interfaces for extensibility rather than header-style interfaces.</p>
<p>If I define an operation in an interface, I’m basically saying that I expect to be able to make this call, with certain parameters, and get a certain type of result back.&#160; As part of that, saying that I expect to throw (or will throw) certain exceptions is part of the definition of my API.</p>
<p>What I don’t see much value in is checked exceptions as in Java.&#160; To me, there is absolutely no value in putting in boilerplate code to just rethrow exceptions that I’ve caught just to satisfy a compiler restriction.&#160; But, knowing what exceptions can be thrown is, to me, extremely valuable.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrong.net/2009/06/09/checked-exceptions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Can you know this?</title>
		<link>http://www.wrong.net/2009/01/29/can-you-know-this/</link>
		<comments>http://www.wrong.net/2009/01/29/can-you-know-this/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 19:10:05 +0000</pubDate>
		<dc:creator>Kyoryu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.wrong.net/?p=55</guid>
		<description><![CDATA[One of the questions I like to ask when designing software is simple &#8211; &#8220;can I know this?&#8221;
For instance, when dealing with data across a network, you might decide that you need to know that your local copy of the data is up-to-date before you reduce a particular value by 5.  So the question, in [...]]]></description>
			<content:encoded><![CDATA[<p>One of the questions I like to ask when designing software is simple &#8211; &#8220;can I know this?&#8221;</p>
<p>For instance, when dealing with data across a network, you might decide that you need to know that your local copy of the data is up-to-date before you reduce a particular value by 5.  So the question, in this case, is &#8220;can I know that my data is up to date?&#8221;</p>
<p>And the answer for that is, generally, no.  To do so requires implementing some sort of locking mechanism, and ask the database folks how easy that is.  Hint:  It&#8217;s easy in the trivial case, but quickly becomes difficult.  Another hint:  Two words &#8211; &#8216;deadlock&#8217; and &#8216;livelock.&#8217;</p>
<p>As developers, we tend to believe that we can know everything about a system.  We tend to believe that every problem is, essentially, solvable.  We <em>hate</em> admitting that we can&#8217;t get the answer to something.</p>
<p>But sometimes, we just can&#8217;t.  Sometimes, the answer to something is dependent on so many other factors that are outside of our control, and that we can&#8217;t measure, that there is no way to answer the question with 100% accuracy.</p>
<p>When faced with problems like this, I try to follow up the initial question of &#8220;can we know this&#8221; with another couple of questisons:  &#8220;What do we know,&#8221; &#8220;what don&#8217;t we know,&#8221; &#8221;who knows this,&#8221; and &#8220;what is it we really want to know or do?&#8221; This will often suggest a better solution to the problem than one which requires unknowable information.</p>
<p>For instance, in our initial example, we don&#8217;t know if our data is up to date, because we don&#8217;t know if someone else has updated the data since our last refresh.  And we can&#8217;t know that, because it will take an amount of time for any updates to reach us &#8211; the best we can ever do is say that we know what the data looked like at some point in the past.</p>
<p>But, what we <em>do</em> know is different.  We <em>do</em> know that we want to decrease the value by 5.  And we know that in most cases, there&#8217;s an authoritative data source somewhere.  This suggests a solution &#8211; instead of us modifying the data locally, send a request to the source of the data not to set the value to a specific amount (what we believe the current value is, minus 5), but rather to decrease the amount by 5.  Because the data source should always have the current value, it will know what to do to decrease the current value by 5.</p>
<p>If we don&#8217;t ask these questions, we can easily start down the road of trying to know the unknowable &#8211; being so set that we&#8217;re going to have our local machine get the latest value and set the new value to that minus 5 that we do all sorts of crazy research into synchronization and locking mechanisms.  Generally, this results in madness.  Every solution that covers some percentage of cases leaves others broken, and you can end up chasing your tail trying to patch the corner cases, or dealing with issues that are only there in the first place because of how you&#8217;re dealing with the problem &#8211; for instance, locking issues like I discussed earlier.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrong.net/2009/01/29/can-you-know-this/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>These things are not the same</title>
		<link>http://www.wrong.net/2009/01/13/these-things-are-not-the-same/</link>
		<comments>http://www.wrong.net/2009/01/13/these-things-are-not-the-same/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 23:55:09 +0000</pubDate>
		<dc:creator>Kyoryu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.wrong.net/?p=54</guid>
		<description><![CDATA[&#8220;I can do X with Y.&#8221;
&#8220;X is Y.&#8221;
That&#8217;s all.
]]></description>
			<content:encoded><![CDATA[<p>&#8220;I can do X with Y.&#8221;</p>
<p>&#8220;X is Y.&#8221;</p>
<p>That&#8217;s all.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrong.net/2009/01/13/these-things-are-not-the-same/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interfaces vs. Classes</title>
		<link>http://www.wrong.net/2008/12/03/interfaces-vs-classes/</link>
		<comments>http://www.wrong.net/2008/12/03/interfaces-vs-classes/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 01:01:06 +0000</pubDate>
		<dc:creator>Kyoryu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.wrong.net/?p=50</guid>
		<description><![CDATA[As a follow-up to the last post, consider this:
Classes map to nouns.  They say what something is (a Person, for instance).
Interfaces map more closely to adjectives &#8211; they describe the noun (specifically, what the noun can do).
So, you wouldn&#8217;t have the class Person implement IPerson.  That&#8217;s basically saying that a person is person-y, which doesn&#8217;t make a [...]]]></description>
			<content:encoded><![CDATA[<p>As a follow-up to the last post, consider this:</p>
<p>Classes map to nouns.  They say what something is (a Person, for instance).</p>
<p>Interfaces map more closely to adjectives &#8211; they <em>describe</em> the noun (specifically, what the noun can do).</p>
<p>So, you wouldn&#8217;t have the class Person implement IPerson.  That&#8217;s basically saying that a person is person-y, which doesn&#8217;t make a lot of sense.</p>
<p>A person might implement IFeedable, IHirable, etc.</p>
<p>One thing that occurs to me as I write this post is that interfaces don&#8217;t describe what their nouns can do so much as they describe what can be <em>done</em> to the nouns.  This gets into the idea I have that most languages are very good at describing <em>incoming</em> messages to an object, but don&#8217;t do a very good job at describing <em>outgoing</em> messages.  But, that&#8217;s a topic for another day.</p>
<p>If this is true, then interfaces and classes serve very different purposes.  An interface shouldn&#8217;t be simply seen as the ultimate abstract base class.</p>
<p>If an interface is used to describe what can be done to a class (a Person might be IHirable), then in many cases, a class may implement multiple interfaces.  If that&#8217;s the case, then each interface should consist only of the actions that are atomic with that concept.  Actions that only make sense together, and don&#8217;t ever make sense without each other.</p>
<p>For instance, IHirable obviously needs some sort of Hire() method.  And, it might make sense for it to have a Fire() method.  It doesn&#8217;t make sense (legal reasons and internal politics aside) to be able to hire someone without being able to fire them.  And, similarly, you can&#8217;t fire someone that wasn&#8217;t able to be hired in the first place.  So, Fire() should go in IHirable, as it&#8217;s tightly coupled to Hire().</p>
<p>What about Pay()?  It doesn&#8217;t make sense that you can hire someone and not pay them, so it might make sense to put it in IHirable.  But, there are a lot of people that you pay that you don&#8217;t hire, and in fact, can&#8217;t hire.  The pizza delivery guy, the water company, etc.  So, maybe Pay just belongs in IPayable, which IHirable can extend.</p>
<p>Here&#8217;s a statement I&#8217;ll put forth, but I&#8217;m not backing 100% yet:</p>
<p><strong>Having an interface with the same name as a class is a design smell.</strong></p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrong.net/2008/12/03/interfaces-vs-classes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Defining Value Types</title>
		<link>http://www.wrong.net/2008/05/14/defining-value-types/</link>
		<comments>http://www.wrong.net/2008/05/14/defining-value-types/#comments</comments>
		<pubDate>Wed, 14 May 2008 18:04:19 +0000</pubDate>
		<dc:creator>Kyoryu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.wrong.net/?p=45</guid>
		<description><![CDATA[One of the things that&#8217;s been floating around in my mind is the difference between object types and value types.  Conceptually, it&#8217;s the difference between a dialog and an integer or string.  In my mind, I understand the intent, but I dislike categorizing by intent, as that leads to fuzzy definitions that eventually become meaningless.
The [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things that&#8217;s been floating around in my mind is the difference between object types and value types.  Conceptually, it&#8217;s the difference between a dialog and an integer or string.  In my mind, I understand the intent, but I dislike categorizing by intent, as that leads to fuzzy definitions that eventually become meaningless.</p>
<p>The other way to define value types is by storage &#8211; stack vs. heap.  I really don&#8217;t like this, though, as one of the advantages of value types is that it&#8217;s safe to pass them by reference.  I would say a string in C# is a value type, even though it&#8217;s a class (and therefore passed by reference).</p>
<p>So, here&#8217;s a set of criteria to determine if something is a value type or not.  These criteria don&#8217;t specify whether a particular type <strong>could</strong> be implemented as a value type, only whether or not they <strong>are</strong> a value type as implemented.</p>
<ol>
<li>The type must be immutable.  Any methods called on the type cannot change its members.  If a modification is desired, the method should create a new object of the same type, and return that object.</li>
<li>The type must only reference other value types.</li>
</ol>
<p>If your type follows these two rules, it is guaranteed to be side-effect free.</p>
<p>Rule #2 might be relaxed, if the reference type that the type holds is guaranteed to never be exposed (so nothing can ever modify it), and the object never modifies it itself.</p>
<p>Edit a year later:  Another exemption is that a type can be a value type if it never acts upon any reference types that it contains.  A list can be a value tpe, then, as it doesn&#8217;t actually act on any of its contents.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrong.net/2008/05/14/defining-value-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A common unit testing pattern, part 3</title>
		<link>http://www.wrong.net/2008/03/19/a-common-unit-testing-pattern-part-3/</link>
		<comments>http://www.wrong.net/2008/03/19/a-common-unit-testing-pattern-part-3/#comments</comments>
		<pubDate>Thu, 20 Mar 2008 04:55:02 +0000</pubDate>
		<dc:creator>Kyoryu</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.wrong.net/2008/03/19/a-common-unit-testing-pattern-part-3/</guid>
		<description><![CDATA[And this time I&#8217;m going to drift into theory-land for a bit, and I&#8217;m not particularly fond of theory-land.&#160; I prefer &#34;getting-stuff-done-land,&#34; which is quite often located on another continent.
Conceptually, objects are these things that sit in space and receive and spit out messages.&#160; And if we look at our User class in that way, [...]]]></description>
			<content:encoded><![CDATA[<p>And this time I&#8217;m going to drift into theory-land for a bit, and I&#8217;m not particularly fond of theory-land.&#160; I prefer &quot;getting-stuff-done-land,&quot; which is quite often located on another continent.</p>
<p>Conceptually, objects are these things that sit in space and receive and spit out messages.&#160; And if we look at our User class in that way, it kind of makes sense.&#160; We define the behavior of the User object as receiving a message to set its name, and when it does so, it should then emit a message that it should be saved.</p>
<p>And this is a pretty convenient way to think of objects.&#160; It also isn&#8217;t modeled well by most object-oriented languages.</p>
<p>C++-derived languages handle relationships of &quot;is-a&quot; and &quot;has-a&quot; types very well.&#160; But, what we really want here is a &quot;talks-to-a&quot; relationship.&#160; There&#8217;s no real first-class way to do that.</p>
<p>Also, they handle incoming messages very well, by means of the public interface of an object.&#160; But, outgoing messages are a little tougher.&#160; Sure, you can do all sorts of things with message receivers and emitters, but realistically, people are going to use the built-in constructs of the language.&#160; So, if we want to model objects as message receivers (easy) and emitters (not easy), we should do it in as basic a way as possible.</p>
<p>And now we get back to &quot;getting-stuff-done-land.&quot;&#160; Looking at our User class from the past two entries, we can look at the interface we define as the outgoing messages that the object can emit.&#160; Viewed in that way, it makes sense that the object would own that interface &#8211; who else would?&#160; And why would an outgoing message from a user know anything about a database?</p>
<p>There&#8217;s other ways to model an outgoing message, and they all pretty much boil down to function pointers.</p>
<p>First, you can use virtual protected methods to define messages, and then override them in derived classes to translate them to the incoming messages that are desired by another component/object.&#160; This method has the advantages of looking more traditional, but the disadvantage of not being able to mix-and-match receivers at runtime.</p>
<p>Secondly, you can use events and delegates.&#160; Combined with lambda expressions in C# 3, this can be an effective way to define outgoing messages.&#160; It has the advantage of not requiring additional classes, but the disadvantage is that you have to hook up each event individually.&#160; Also, events can provide multiple dispatch, but that can become wonky if you want to remove individual anonymous delegates, so I&#8217;m counting that as a neutral.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrong.net/2008/03/19/a-common-unit-testing-pattern-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
