<?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: Pushing the logic back</title>
	<atom:link href="http://www.markhneedham.com/blog/2009/11/11/coding-pushing-the-logic-back/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2009/11/11/coding-pushing-the-logic-back/</link>
	<description>Thoughts on Software Development</description>
	<lastBuildDate>Tue, 16 Mar 2010 16:49:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: C#: A functional solutional to a modeling problem at Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/11/11/coding-pushing-the-logic-back/comment-page-1/#comment-30337</link>
		<dc:creator>C#: A functional solutional to a modeling problem at Mark Needham</dc:creator>
		<pubDate>Fri, 15 Jan 2010 23:25:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1813#comment-30337</guid>
		<description>[...] were working on some refactoring today where we pushed some logic back from a service and onto a domain object and I noticed that we were able to use functions quite [...]</description>
		<content:encoded><![CDATA[<p>[...] were working on some refactoring today where we pushed some logic back from a service and onto a domain object and I noticed that we were able to use functions quite [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: freddy rios</title>
		<link>http://www.markhneedham.com/blog/2009/11/11/coding-pushing-the-logic-back/comment-page-1/#comment-26678</link>
		<dc:creator>freddy rios</dc:creator>
		<pubDate>Thu, 12 Nov 2009 15:30:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1813#comment-26678</guid>
		<description>@Mark: I know its asking instead of telling, but I find it much more natural to change from the initial code to:

public BusinessSummary buildSummaryObject() {
	BusinessSummary businessSummary = new BusinessSummary();
	for(BusinessObject businessObject : businessObjects) {
		State state = businessObject.getState();
                businessSummary.incrementState(state);
	}	
	return businessSummary;
}

or:

public BusinessSummary buildSummaryObject() {
	BusinessSummary businessSummary = new BusinessSummary();
	for(BusinessObject businessObject : businessObjects) {
		businessSummary.add(businessObject);
	}	
	return businessSummary;
}

maybe even:

public BusinessSummary buildSummaryObject() {
	BusinessSummary businessSummary = new BusinessSummary();
        businessSummary.add(businessObjects);
}

Consider this is similar to @Moandji approach, but isn&#039;t a chatty comm i.e.

BusinessSummary.add(List objs) {
for(BusinessObject businessObject : objs){
   businessObject.writeTo(businessSummary); // tell bo to write to self, so then bo tells self to increment ... instead of just telling self to increment based on businessObject.getState()
 }
}

For me its the business summary that should we caring about what information we are using for the summary, so I don&#039;t see why BusinessObject needs to be tied back to BusinessSummary.</description>
		<content:encoded><![CDATA[<p>@Mark: I know its asking instead of telling, but I find it much more natural to change from the initial code to:</p>
<p>public BusinessSummary buildSummaryObject() {<br />
	BusinessSummary businessSummary = new BusinessSummary();<br />
	for(BusinessObject businessObject : businessObjects) {<br />
		State state = businessObject.getState();<br />
                businessSummary.incrementState(state);<br />
	}<br />
	return businessSummary;<br />
}</p>
<p>or:</p>
<p>public BusinessSummary buildSummaryObject() {<br />
	BusinessSummary businessSummary = new BusinessSummary();<br />
	for(BusinessObject businessObject : businessObjects) {<br />
		businessSummary.add(businessObject);<br />
	}<br />
	return businessSummary;<br />
}</p>
<p>maybe even:</p>
<p>public BusinessSummary buildSummaryObject() {<br />
	BusinessSummary businessSummary = new BusinessSummary();<br />
        businessSummary.add(businessObjects);<br />
}</p>
<p>Consider this is similar to @Moandji approach, but isn't a chatty comm i.e.</p>
<p>BusinessSummary.add(List objs) {<br />
for(BusinessObject businessObject : objs){<br />
   businessObject.writeTo(businessSummary); // tell bo to write to self, so then bo tells self to increment &#8230; instead of just telling self to increment based on businessObject.getState()<br />
 }<br />
}</p>
<p>For me its the business summary that should we caring about what information we are using for the summary, so I don't see why BusinessObject needs to be tied back to BusinessSummary.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/11/11/coding-pushing-the-logic-back/comment-page-1/#comment-26673</link>
		<dc:creator>Mark Needham</dc:creator>
		<pubDate>Thu, 12 Nov 2009 13:24:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1813#comment-26673</guid>
		<description>@Moandji - that might actually be even better, I like that. Neat.</description>
		<content:encoded><![CDATA[<p>@Moandji &#8211; that might actually be even better, I like that. Neat.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reflective Perspective - Chris Alcock &#187; The Morning Brew #475</title>
		<link>http://www.markhneedham.com/blog/2009/11/11/coding-pushing-the-logic-back/comment-page-1/#comment-26657</link>
		<dc:creator>Reflective Perspective - Chris Alcock &#187; The Morning Brew #475</dc:creator>
		<pubDate>Thu, 12 Nov 2009 08:27:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1813#comment-26657</guid>
		<description>[...] Coding: Pushing the logic back - Mark Needham talks about refactoring business logic code back into business objects along with the tell don&#8217;t ask, single responsibility principle and law of demeter development principles [...]</description>
		<content:encoded><![CDATA[<p>[...] Coding: Pushing the logic back &#8211; Mark Needham talks about refactoring business logic code back into business objects along with the tell don't ask, single responsibility principle and law of demeter development principles [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Moandji Ezana</title>
		<link>http://www.markhneedham.com/blog/2009/11/11/coding-pushing-the-logic-back/comment-page-1/#comment-26636</link>
		<dc:creator>Moandji Ezana</dc:creator>
		<pubDate>Wed, 11 Nov 2009 23:17:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1813#comment-26636</guid>
		<description>Why not have BusinessSummary.increment(State) ?

Then, your interaction is more like the two classes passing requests and bits of information back-and-forth and BusinessSummary&#039;s API is less coupled to the various State instances. (excuse the short-hand pseudo-code below)

BusinessSummary.add(List objs) {
for(BusinessObject businessObject : objs){
 businessObject.writeTo(businessSummary);					}
}

BusinessObject.writeTo(BusinessSummary bs) {
 bs.increment(this.state);
}

BusinessSummary.increment(State state) {
 if (State.State1 == state) {etc...
}

I think the advantage here is that all the BusinessSummary really knows how to do is increment its State counter. All the rest is convenience methods.</description>
		<content:encoded><![CDATA[<p>Why not have BusinessSummary.increment(State) ?</p>
<p>Then, your interaction is more like the two classes passing requests and bits of information back-and-forth and BusinessSummary's API is less coupled to the various State instances. (excuse the short-hand pseudo-code below)</p>
<p>BusinessSummary.add(List objs) {<br />
for(BusinessObject businessObject : objs){<br />
 businessObject.writeTo(businessSummary);					}<br />
}</p>
<p>BusinessObject.writeTo(BusinessSummary bs) {<br />
 bs.increment(this.state);<br />
}</p>
<p>BusinessSummary.increment(State state) {<br />
 if (State.State1 == state) {etc&#8230;<br />
}</p>
<p>I think the advantage here is that all the BusinessSummary really knows how to do is increment its State counter. All the rest is convenience methods.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael L Perry</title>
		<link>http://www.markhneedham.com/blog/2009/11/11/coding-pushing-the-logic-back/comment-page-1/#comment-26610</link>
		<dc:creator>Michael L Perry</dc:creator>
		<pubDate>Wed, 11 Nov 2009 13:35:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1813#comment-26610</guid>
		<description>Who is responsible for summarizing, and how do they get the data? There is no one right answer. If it&#039;s the business object, then it&#039;s doing too much. If it&#039;s the business summary, then it has to ask and not tell. It&#039;s always a tradeoff.</description>
		<content:encoded><![CDATA[<p>Who is responsible for summarizing, and how do they get the data? There is no one right answer. If it's the business object, then it's doing too much. If it's the business summary, then it has to ask and not tell. It's always a tradeoff.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tweets that mention Coding: Pushing the logic back at Mark Needham -- Topsy.com</title>
		<link>http://www.markhneedham.com/blog/2009/11/11/coding-pushing-the-logic-back/comment-page-1/#comment-26609</link>
		<dc:creator>Tweets that mention Coding: Pushing the logic back at Mark Needham -- Topsy.com</dc:creator>
		<pubDate>Wed, 11 Nov 2009 13:03:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1813#comment-26609</guid>
		<description>[...] This post was mentioned on Twitter by Mark Needham, planettw. planettw said: Mark Needham: Coding: Pushing the logic back: I was reading a post on the law of demeter by Richard Hart recently an... http://bit.ly/3xkULf [...]</description>
		<content:encoded><![CDATA[<p>[...] This post was mentioned on Twitter by Mark Needham, planettw. planettw said: Mark Needham: Coding: Pushing the logic back: I was reading a post on the law of demeter by Richard Hart recently an&#8230; <a href="http://bit.ly/3xkULf" rel="nofollow">http://bit.ly/3xkULf</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens Himmelreich</title>
		<link>http://www.markhneedham.com/blog/2009/11/11/coding-pushing-the-logic-back/comment-page-1/#comment-26607</link>
		<dc:creator>Jens Himmelreich</dc:creator>
		<pubDate>Wed, 11 Nov 2009 12:47:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1813#comment-26607</guid>
		<description>There are other solutions. Having conditional logic is a smell. Having a state-object, which makes implicit classes of BusinessObjects may be a smell to use subclasses. If you want to count the states, you may use a hash with states as keys. The hash could be incremented inside the BusinessObjects or inside the summary. If the count is a domain-concept, you may use an own new class for the collection of BusinessObjects instead of the ArrayList.

ciao
jens

BTW: Your blog, your tactical insights are very inspiring!</description>
		<content:encoded><![CDATA[<p>There are other solutions. Having conditional logic is a smell. Having a state-object, which makes implicit classes of BusinessObjects may be a smell to use subclasses. If you want to count the states, you may use a hash with states as keys. The hash could be incremented inside the BusinessObjects or inside the summary. If the count is a domain-concept, you may use an own new class for the collection of BusinessObjects instead of the ArrayList.</p>
<p>ciao<br />
jens</p>
<p>BTW: Your blog, your tactical insights are very inspiring!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
