<?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: Coding: The agent noun class</title>
	<atom:link href="http://www.markhneedham.com/blog/2009/11/08/coding-the-agent-noun-class/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2009/11/08/coding-the-agent-noun-class/</link>
	<description>Thoughts on Software Development</description>
	<lastBuildDate>Sat, 11 Feb 2012 23:17:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Links, news, Resources: Object Oriented Programming (1) &#171; Angel &#8220;Java&#8221; Lopez on Blog</title>
		<link>http://www.markhneedham.com/blog/2009/11/08/coding-the-agent-noun-class/comment-page-1/#comment-98486</link>
		<dc:creator>Links, news, Resources: Object Oriented Programming (1) &#171; Angel &#8220;Java&#8221; Lopez on Blog</dc:creator>
		<pubDate>Sat, 19 Feb 2011 10:38:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1803#comment-98486</guid>
		<description>[...] Coding: The agent noun class Mark Needham response to the above post. [...]</description>
		<content:encoded><![CDATA[<p>[...] Coding: The agent noun class Mark Needham response to the above post. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Rendle</title>
		<link>http://www.markhneedham.com/blog/2009/11/08/coding-the-agent-noun-class/comment-page-1/#comment-26571</link>
		<dc:creator>Mark Rendle</dc:creator>
		<pubDate>Tue, 10 Nov 2009 19:32:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1803#comment-26571</guid>
		<description>This is one of those time when you can drive yourself nuts trying to satisfy contradictory pronouncements on patterns, principles and smells. In the end you have to decide what is important to you, or what makes the code cleaner and easier to read.

For my part, I make a lot of use of agent-noun classes: my most recent code includes StringTokenizer, BindVariableExtractor, BindVariableResolver, FieldValueGetter (which implements IValueGetter), FieldValueSetter (IValueSetter), and others. To me, this is correct, as these classes have no dependencies and can be rewritten, replaced, mocked and tested without impacting the rest of the system. That is what is important to me, and it makes my code easy to read for me and those who come after me.

So I&#039;d stick with AgeCalculator and call it from a getAge method.</description>
		<content:encoded><![CDATA[<p>This is one of those time when you can drive yourself nuts trying to satisfy contradictory pronouncements on patterns, principles and smells. In the end you have to decide what is important to you, or what makes the code cleaner and easier to read.</p>
<p>For my part, I make a lot of use of agent-noun classes: my most recent code includes StringTokenizer, BindVariableExtractor, BindVariableResolver, FieldValueGetter (which implements IValueGetter), FieldValueSetter (IValueSetter), and others. To me, this is correct, as these classes have no dependencies and can be rewritten, replaced, mocked and tested without impacting the rest of the system. That is what is important to me, and it makes my code easy to read for me and those who come after me.</p>
<p>So I&#8217;d stick with AgeCalculator and call it from a getAge method.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Uladzimir Liashkevich</title>
		<link>http://www.markhneedham.com/blog/2009/11/08/coding-the-agent-noun-class/comment-page-1/#comment-26539</link>
		<dc:creator>Uladzimir Liashkevich</dc:creator>
		<pubDate>Tue, 10 Nov 2009 11:39:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1803#comment-26539</guid>
		<description>Mark,

Let me remind you that Type + Contstraint = New Type.
So,  +  = Age type.

This transformation also falls nicely into Wrap Primitive with Object refactoring, which attacks Primitive Obsession anti-pattern.

Therefore your Customer class may have a method like

Age getAge() { return new Age(this.dateOfBirth); }


Uladzimir.</description>
		<content:encoded><![CDATA[<p>Mark,</p>
<p>Let me remind you that Type + Contstraint = New Type.<br />
So,  +  = Age type.</p>
<p>This transformation also falls nicely into Wrap Primitive with Object refactoring, which attacks Primitive Obsession anti-pattern.</p>
<p>Therefore your Customer class may have a method like</p>
<p>Age getAge() { return new Age(this.dateOfBirth); }</p>
<p>Uladzimir.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Esko Luontola</title>
		<link>http://www.markhneedham.com/blog/2009/11/08/coding-the-agent-noun-class/comment-page-1/#comment-26537</link>
		<dc:creator>Esko Luontola</dc:creator>
		<pubDate>Tue, 10 Nov 2009 11:18:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1803#comment-26537</guid>
		<description>@Mark - In a functional language some of them might be functions, but even then they would not really fit into a larger class. Based on Single Responsibility Principle and Open Closed Principle each of those classes does one thing (SRP) and they extend the behaviour of some other class without modifying it (OCP).

For example the last two classes that I mentioned hook into Java&#039;s serialization process. In this system, when objects are serialized, there are about five things that need to be checked about every object. Each of those things is implemented as one SerializationListener or SerializationReplacer (similar to the Visitor pattern) and verb names felt natural because each of them does one action, similar to how a method does one action. They are used like this:

http://github.com/orfjackal/dimdwarf/blob/master/dimdwarf-core/src/main/java/net/orfjackal/dimdwarf/serial/ObjectSerializerImpl.java</description>
		<content:encoded><![CDATA[<p>@Mark &#8211; In a functional language some of them might be functions, but even then they would not really fit into a larger class. Based on Single Responsibility Principle and Open Closed Principle each of those classes does one thing (SRP) and they extend the behaviour of some other class without modifying it (OCP).</p>
<p>For example the last two classes that I mentioned hook into Java&#8217;s serialization process. In this system, when objects are serialized, there are about five things that need to be checked about every object. Each of those things is implemented as one SerializationListener or SerializationReplacer (similar to the Visitor pattern) and verb names felt natural because each of them does one action, similar to how a method does one action. They are used like this:</p>
<p><a href="http://github.com/orfjackal/dimdwarf/blob/master/dimdwarf-core/src/main/java/net/orfjackal/dimdwarf/serial/ObjectSerializerImpl.java" rel="nofollow">http://github.com/orfjackal/dimdwarf/blob/master/dimdwarf-core/src/main/java/net/orfjackal/dimdwarf/serial/ObjectSerializerImpl.java</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Campbell</title>
		<link>http://www.markhneedham.com/blog/2009/11/08/coding-the-agent-noun-class/comment-page-1/#comment-26484</link>
		<dc:creator>Steve Campbell</dc:creator>
		<pubDate>Mon, 09 Nov 2009 18:24:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1803#comment-26484</guid>
		<description>To me it looks like a strategy pattern, i.e. IAgeCalculationStrategy, of which your implementation is just one possibility (for example, you might have another strategy that works on the planet Saturn).  

It is probably overkill to break out the interface in this scenario, so AgeCalculator is a fine &quot;generic&quot; strategy for calculating ages.  

(I wouldn&#039;t change a thing).</description>
		<content:encoded><![CDATA[<p>To me it looks like a strategy pattern, i.e. IAgeCalculationStrategy, of which your implementation is just one possibility (for example, you might have another strategy that works on the planet Saturn).  </p>
<p>It is probably overkill to break out the interface in this scenario, so AgeCalculator is a fine &#8220;generic&#8221; strategy for calculating ages.  </p>
<p>(I wouldn&#8217;t change a thing).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Gillard-Moss</title>
		<link>http://www.markhneedham.com/blog/2009/11/08/coding-the-agent-noun-class/comment-page-1/#comment-26470</link>
		<dc:creator>Peter Gillard-Moss</dc:creator>
		<pubDate>Mon, 09 Nov 2009 11:59:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1803#comment-26470</guid>
		<description>Thanks for the link btw!

I&#039;ve also hit this problem before.  Like many posts I try and create a class which represents the result (e.g. Age).

So I would do something like: dateOfBirth.AgeOn(Clock.Now)</description>
		<content:encoded><![CDATA[<p>Thanks for the link btw!</p>
<p>I&#8217;ve also hit this problem before.  Like many posts I try and create a class which represents the result (e.g. Age).</p>
<p>So I would do something like: dateOfBirth.AgeOn(Clock.Now)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/11/08/coding-the-agent-noun-class/comment-page-1/#comment-26468</link>
		<dc:creator>Mark Needham</dc:creator>
		<pubDate>Mon, 09 Nov 2009 11:30:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1803#comment-26468</guid>
		<description>@Esko - I reckon if you were in a language other than Java then those examples that you describe would probably be functions that you would look to add to the appropriate classes?

In which case the names would stay the same and we wouldn&#039;t need to find a new class name! I&#039;m not sure what the best thing would be to do in Java though maybe those names are fine in that case.</description>
		<content:encoded><![CDATA[<p>@Esko &#8211; I reckon if you were in a language other than Java then those examples that you describe would probably be functions that you would look to add to the appropriate classes?</p>
<p>In which case the names would stay the same and we wouldn&#8217;t need to find a new class name! I&#8217;m not sure what the best thing would be to do in Java though maybe those names are fine in that case.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pablo</title>
		<link>http://www.markhneedham.com/blog/2009/11/08/coding-the-agent-noun-class/comment-page-1/#comment-26465</link>
		<dc:creator>pablo</dc:creator>
		<pubDate>Mon, 09 Nov 2009 10:55:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1803#comment-26465</guid>
		<description>I forgot to mention one thing in my comment above. 

When I actually come across a situation like this *AgeCalculator* I would usually name it *CalculateAgeCommand*. 

I am not sure whether it makes it smell less, but all my commands have a common interface:

interface ICommand  {
    //constructor gets all dependencies
    T Execute();
}

So, I know when an operation is complex enough to deserve its own tests, I promote it from a private method to a class that implements my ICommand interface.</description>
		<content:encoded><![CDATA[<p>I forgot to mention one thing in my comment above. </p>
<p>When I actually come across a situation like this *AgeCalculator* I would usually name it *CalculateAgeCommand*. </p>
<p>I am not sure whether it makes it smell less, but all my commands have a common interface:</p>
<p>interface ICommand  {<br />
    //constructor gets all dependencies<br />
    T Execute();<br />
}</p>
<p>So, I know when an operation is complex enough to deserve its own tests, I promote it from a private method to a class that implements my ICommand interface.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jayesh</title>
		<link>http://www.markhneedham.com/blog/2009/11/08/coding-the-agent-noun-class/comment-page-1/#comment-26457</link>
		<dc:creator>Jayesh</dc:creator>
		<pubDate>Mon, 09 Nov 2009 10:08:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1803#comment-26457</guid>
		<description>The key difference in my above comment being that Age is a domain class itself and not an agent noun. Age will contain the date of birth property.</description>
		<content:encoded><![CDATA[<p>The key difference in my above comment being that Age is a domain class itself and not an agent noun. Age will contain the date of birth property.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jayesh</title>
		<link>http://www.markhneedham.com/blog/2009/11/08/coding-the-agent-noun-class/comment-page-1/#comment-26456</link>
		<dc:creator>Jayesh</dc:creator>
		<pubDate>Mon, 09 Nov 2009 10:06:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1803#comment-26456</guid>
		<description>The way I would do it is to have a method on Customer called calculateAge inside which the dateOfBirth will be used to calculate the age. This also fits in with the concept of not exposing privates as far as possible.
Now if the Customer class is bloating up too much, then thats a different problem which can be solved by extracting another domain class from within the Customer. For example, as pointed out by others, an Age object where the logic can be moved. The Customer class&#039; calculateAge can then delegate to the Age class...</description>
		<content:encoded><![CDATA[<p>The way I would do it is to have a method on Customer called calculateAge inside which the dateOfBirth will be used to calculate the age. This also fits in with the concept of not exposing privates as far as possible.<br />
Now if the Customer class is bloating up too much, then thats a different problem which can be solved by extracting another domain class from within the Customer. For example, as pointed out by others, an Age object where the logic can be moved. The Customer class&#8217; calculateAge can then delegate to the Age class&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

