<?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: OO: Micro Types</title>
	<atom:link href="http://www.markhneedham.com/blog/2009/03/10/oo-micro-types/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2009/03/10/oo-micro-types/</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: C# Object Initializer: More thoughts at Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/03/10/oo-micro-types/comment-page-1/#comment-30051</link>
		<dc:creator>C# Object Initializer: More thoughts at Mark Needham</dc:creator>
		<pubDate>Sun, 10 Jan 2010 22:59:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1017#comment-30051</guid>
		<description>[...] way to solve this is to make use of tiny types so that the API is still expressive even though what we want to pass in is a string. That takes [...]</description>
		<content:encoded><![CDATA[<p>[...] way to solve this is to make use of tiny types so that the API is still expressive even though what we want to pass in is a string. That takes [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Coding Dojo #13: TDD as if you meant it at Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/03/10/oo-micro-types/comment-page-1/#comment-15654</link>
		<dc:creator>Coding Dojo #13: TDD as if you meant it at Mark Needham</dc:creator>
		<pubDate>Wed, 29 Apr 2009 20:15:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1017#comment-15654</guid>
		<description>[...] seemed like following these rules guided us towards tiny/micro types in our code and the methods we extracted were really small compared to the ones we would have [...]</description>
		<content:encoded><![CDATA[<p>[...] seemed like following these rules guided us towards tiny/micro types in our code and the methods we extracted were really small compared to the ones we would have [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: QCon London 2009: Rebuilding guardian.co.uk with DDD - Phil Wills at Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/03/10/oo-micro-types/comment-page-1/#comment-12288</link>
		<dc:creator>QCon London 2009: Rebuilding guardian.co.uk with DDD - Phil Wills at Mark Needham</dc:creator>
		<pubDate>Sat, 14 Mar 2009 04:25:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1017#comment-12288</guid>
		<description>[...] by introducing value objects. Every time I heard value objects being mentioned it reminded me of micro/tiny types which are not exactly the same but seem to be fairly similar in their intent of improving [...]</description>
		<content:encoded><![CDATA[<p>[...] by introducing value objects. Every time I heard value objects being mentioned it reminded me of micro/tiny types which are not exactly the same but seem to be fairly similar in their intent of improving [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dew Drop - March 11, 2009 &#124; Alvin Ashcraft's Morning Dew</title>
		<link>http://www.markhneedham.com/blog/2009/03/10/oo-micro-types/comment-page-1/#comment-12140</link>
		<dc:creator>Dew Drop - March 11, 2009 &#124; Alvin Ashcraft's Morning Dew</dc:creator>
		<pubDate>Wed, 11 Mar 2009 13:27:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1017#comment-12140</guid>
		<description>[...] OO: Micro Types (Mark Needham) [...]</description>
		<content:encoded><![CDATA[<p>[...] OO: Micro Types (Mark Needham) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Needham</title>
		<link>http://www.markhneedham.com/blog/2009/03/10/oo-micro-types/comment-page-1/#comment-12131</link>
		<dc:creator>Mark Needham</dc:creator>
		<pubDate>Wed, 11 Mar 2009 10:00:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1017#comment-12131</guid>
		<description>@Carlo - I&#039;ve not done any Smalltalk but I think I can just about follow the example you give!

You&#039;re write the example I&#039;ve given probably is a bit simplistic and certainly it would be possible to pass in the wrong account to the constructor. Nothing immediately comes to mind with respect to how we can avoid that though.

@anon - If I follow your example correctly then I guess the question would become where would the Transfer method be called from - it feels to me like it doesn&#039;t really belong on either the DebitAccount or CreditAccount objects since it affects both of them?

Maybe it should go on a Transfer object which they can both interact with. 

@Mark - nothing to stop you, you&#039;re right! Can&#039;t immediately think of a way to get around that.

Strict types sounds interesting - I wonder if the code contract stuff from Microsoft would be able to help us here - http://richardsbraindump.blogspot.com/2009/02/code-contracts.html</description>
		<content:encoded><![CDATA[<p>@Carlo &#8211; I&#8217;ve not done any Smalltalk but I think I can just about follow the example you give!</p>
<p>You&#8217;re write the example I&#8217;ve given probably is a bit simplistic and certainly it would be possible to pass in the wrong account to the constructor. Nothing immediately comes to mind with respect to how we can avoid that though.</p>
<p>@anon &#8211; If I follow your example correctly then I guess the question would become where would the Transfer method be called from &#8211; it feels to me like it doesn&#8217;t really belong on either the DebitAccount or CreditAccount objects since it affects both of them?</p>
<p>Maybe it should go on a Transfer object which they can both interact with. </p>
<p>@Mark &#8211; nothing to stop you, you&#8217;re right! Can&#8217;t immediately think of a way to get around that.</p>
<p>Strict types sounds interesting &#8211; I wonder if the code contract stuff from Microsoft would be able to help us here &#8211; <a href="http://richardsbraindump.blogspot.com/2009/02/code-contracts.html" rel="nofollow">http://richardsbraindump.blogspot.com/2009/02/code-contracts.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Hitchman</title>
		<link>http://www.markhneedham.com/blog/2009/03/10/oo-micro-types/comment-page-1/#comment-12129</link>
		<dc:creator>Andy Hitchman</dc:creator>
		<pubDate>Wed, 11 Mar 2009 09:50:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1017#comment-12129</guid>
		<description>For the specific example of simplifying parameter list, I recommend immutable Command objects.

public void do(TransferMoney cmd) {...}</description>
		<content:encoded><![CDATA[<p>For the specific example of simplifying parameter list, I recommend immutable Command objects.</p>
<p>public void do(TransferMoney cmd) {&#8230;}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Smth</title>
		<link>http://www.markhneedham.com/blog/2009/03/10/oo-micro-types/comment-page-1/#comment-12125</link>
		<dc:creator>Mark Smth</dc:creator>
		<pubDate>Wed, 11 Mar 2009 08:29:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1017#comment-12125</guid>
		<description>Thanks for sharing your experiences with this approach. What&#039;s to stop you passing the wrong kind of account to the DebitAccount constructor?

Like Carlo, my Account class would have a TransferTo(amount, targetAccount) method, thus removing the confusion.

The micro-types I *do* miss, in C# are the strict types you could create in Pascal and Ada. eg To define a type as being a limited range of numbers. Any thoughts on implementing this kind of thing?

[I haven&#039;t done any Smalltalk for a decade. Thanks for reminding me how cool it is, Carlo!]</description>
		<content:encoded><![CDATA[<p>Thanks for sharing your experiences with this approach. What&#8217;s to stop you passing the wrong kind of account to the DebitAccount constructor?</p>
<p>Like Carlo, my Account class would have a TransferTo(amount, targetAccount) method, thus removing the confusion.</p>
<p>The micro-types I *do* miss, in C# are the strict types you could create in Pascal and Ada. eg To define a type as being a limited range of numbers. Any thoughts on implementing this kind of thing?</p>
<p>[I haven't done any Smalltalk for a decade. Thanks for reminding me how cool it is, Carlo!]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anon</title>
		<link>http://www.markhneedham.com/blog/2009/03/10/oo-micro-types/comment-page-1/#comment-12123</link>
		<dc:creator>anon</dc:creator>
		<pubDate>Wed, 11 Mar 2009 07:16:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1017#comment-12123</guid>
		<description>Could you use a more OO approach?

public interface IAccount
{
    // return the IAccount interface for method chaining
    IAccount Transfer(IAccount creditAccount, decimal amount);
}

public class Account : IAccount
{
    IAccount Transfer(IAccount creditAccount, decimal amount) 
    {
        ...
    }

    public static IAccount Load(int accountId)
    {
        ...
    }

}

IAccount debitAccount = Account.Load();
debitAccount.Transfer(Account.Load(), 100);</description>
		<content:encoded><![CDATA[<p>Could you use a more OO approach?</p>
<p>public interface IAccount<br />
{<br />
    // return the IAccount interface for method chaining<br />
    IAccount Transfer(IAccount creditAccount, decimal amount);<br />
}</p>
<p>public class Account : IAccount<br />
{<br />
    IAccount Transfer(IAccount creditAccount, decimal amount)<br />
    {<br />
        &#8230;<br />
    }</p>
<p>    public static IAccount Load(int accountId)<br />
    {<br />
        &#8230;<br />
    }</p>
<p>}</p>
<p>IAccount debitAccount = Account.Load();<br />
debitAccount.Transfer(Account.Load(), 100);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reflective Perspective - Chris Alcock &#187; The Morning Brew #304</title>
		<link>http://www.markhneedham.com/blog/2009/03/10/oo-micro-types/comment-page-1/#comment-12122</link>
		<dc:creator>Reflective Perspective - Chris Alcock &#187; The Morning Brew #304</dc:creator>
		<pubDate>Wed, 11 Mar 2009 06:59:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1017#comment-12122</guid>
		<description>[...] OO: Micro Types - Mark Needham shares the idea of Micro Types, creating additional types to allow your methods to have more meaningful signatures with a higher degree of safety. [...]</description>
		<content:encoded><![CDATA[<p>[...] OO: Micro Types &#8211; Mark Needham shares the idea of Micro Types, creating additional types to allow your methods to have more meaningful signatures with a higher degree of safety. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carlo</title>
		<link>http://www.markhneedham.com/blog/2009/03/10/oo-micro-types/comment-page-1/#comment-12099</link>
		<dc:creator>Carlo</dc:creator>
		<pubDate>Tue, 10 Mar 2009 22:28:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=1017#comment-12099</guid>
		<description>Generally I agree with micro-typing but I think the example maybe was a bit simple and therefore missed the mark. The transferMoney() behaviour should probably be moved closer to the Account class or a &#039;Transfer Transaction Command&#039; or simply have a better variable naming scheme to avoid confusion.

In Smalltalk (I&#039;m a Java developer by trade though) I&#039;d write something like:

debitAccount transfer: 25 dollars to: creditAccount. 
Or 
transaction:=AccountTransaction transfer: 25 dollars from: debitAccount to: creditAccount.
transaction transact.
transaction rollback.
OR best of both worlds
transaction:=debitAccount transfer: 25 dollars to: creditAccount. 
transaction transact.
transaction rollback.

I guess this comes down to Rebecca Wirfs Brock&#039;s Responsibility Driven Design and Ward Cunninghams Whole Value pattern (== Eric Evans Value Object); where should this behaviour sit and what best describes my intent.

Personally thats why I like Smalltalk, it&#039;s all objects and messages; and has a higher potential to describe my intent. 

Creating specific account types as you suggest has made the code more specialised and less general; Is it unreasonable to transfer money between any 2 accounts?
Thinking about this again I&#039;d say the issue is variable naming as the micro-typing gives you a false sense of security as somewhere in the code you&#039;d still need to make the decision to wrap each account to classify it as either debit or credit.

Obviously there are many more factors to be aware of in the designs above depending on what we&#039;re asked to do.


Keep up the great blogging...</description>
		<content:encoded><![CDATA[<p>Generally I agree with micro-typing but I think the example maybe was a bit simple and therefore missed the mark. The transferMoney() behaviour should probably be moved closer to the Account class or a &#8216;Transfer Transaction Command&#8217; or simply have a better variable naming scheme to avoid confusion.</p>
<p>In Smalltalk (I&#8217;m a Java developer by trade though) I&#8217;d write something like:</p>
<p>debitAccount transfer: 25 dollars to: creditAccount.<br />
Or<br />
transaction:=AccountTransaction transfer: 25 dollars from: debitAccount to: creditAccount.<br />
transaction transact.<br />
transaction rollback.<br />
OR best of both worlds<br />
transaction:=debitAccount transfer: 25 dollars to: creditAccount.<br />
transaction transact.<br />
transaction rollback.</p>
<p>I guess this comes down to Rebecca Wirfs Brock&#8217;s Responsibility Driven Design and Ward Cunninghams Whole Value pattern (== Eric Evans Value Object); where should this behaviour sit and what best describes my intent.</p>
<p>Personally thats why I like Smalltalk, it&#8217;s all objects and messages; and has a higher potential to describe my intent. </p>
<p>Creating specific account types as you suggest has made the code more specialised and less general; Is it unreasonable to transfer money between any 2 accounts?<br />
Thinking about this again I&#8217;d say the issue is variable naming as the micro-typing gives you a false sense of security as somewhere in the code you&#8217;d still need to make the decision to wrap each account to classify it as either debit or credit.</p>
<p>Obviously there are many more factors to be aware of in the designs above depending on what we&#8217;re asked to do.</p>
<p>Keep up the great blogging&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

