<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;DkEMRHo6eCp7ImA9WhRaE0o.&quot;"><id>tag:blogger.com,1999:blog-3406666181435971572</id><updated>2012-02-16T00:44:45.410-06:00</updated><category term="var" /><category term="c#" /><category term="ruby" /><category term="C++" /><category term="lean" /><category term="RSpec" /><category term="context specification" /><category term="design" /><category term="behavior-driven development" /><category term="Austin Code Camp" /><category term="DDD" /><category term="elegance" /><category term="gotchas" /><category term="test-driven development" /><category term="philosophy" /><category term="conferences" /><category term="expressiveness" /><title>| michael brennan |</title><subtitle type="html">stop coding | start thinking</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://blog.michaelbrennan.net/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://blog.michaelbrennan.net/" /><author><name>Michael Brennan</name><uri>http://www.blogger.com/profile/09351708784127332440</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/_JW7gLMzR6nE/SvxkKuJiIkI/AAAAAAAAAgc/xXHC5leUnYI/S220/me4_left.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/MichaelBrennan" /><feedburner:info uri="michaelbrennan" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>MichaelBrennan</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;CUAAQHw6eyp7ImA9WhZSFkU.&quot;"><id>tag:blogger.com,1999:blog-3406666181435971572.post-5791062518584923092</id><published>2011-04-01T13:48:00.000-05:00</published><updated>2011-04-01T13:49:01.213-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-04-01T13:49:01.213-05:00</app:edited><title>New Blog</title><content type="html">My new blog is at &lt;a href="http://thoughts.michaelbrennan.net"&gt;http://thoughts.michaelbrennan.net&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3406666181435971572-5791062518584923092?l=blog.michaelbrennan.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=z_JLZzj-9s0:9o3zyccFzjw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=z_JLZzj-9s0:9o3zyccFzjw:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=z_JLZzj-9s0:9o3zyccFzjw:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?i=z_JLZzj-9s0:9o3zyccFzjw:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=z_JLZzj-9s0:9o3zyccFzjw:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MichaelBrennan/~4/z_JLZzj-9s0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.michaelbrennan.net/feeds/5791062518584923092/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.michaelbrennan.net/2011/04/new-blog.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/5791062518584923092?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/5791062518584923092?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MichaelBrennan/~3/z_JLZzj-9s0/new-blog.html" title="New Blog" /><author><name>Michael Brennan</name><uri>http://www.blogger.com/profile/09351708784127332440</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/_JW7gLMzR6nE/SvxkKuJiIkI/AAAAAAAAAgc/xXHC5leUnYI/S220/me4_left.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.michaelbrennan.net/2011/04/new-blog.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QNRnY9eip7ImA9WxFUGU8.&quot;"><id>tag:blogger.com,1999:blog-3406666181435971572.post-1642577393645093102</id><published>2010-06-30T15:23:00.000-05:00</published><updated>2010-06-30T15:23:17.862-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-06-30T15:23:17.862-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="expressiveness" /><category scheme="http://www.blogger.com/atom/ns#" term="elegance" /><category scheme="http://www.blogger.com/atom/ns#" term="philosophy" /><category scheme="http://www.blogger.com/atom/ns#" term="c#" /><category scheme="http://www.blogger.com/atom/ns#" term="var" /><title>Why You Should Always Use the ‘var’ Keyword in C#</title><content type="html">&lt;h4&gt;&lt;/h4&gt;  &lt;h4&gt;&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_JW7gLMzR6nE/TCum5JgrIfI/AAAAAAAAAmk/HM2oBwGGYdQ/s1600-h/iStock_000012751071XSmall%5B4%5D.jpg"&gt;&lt;img title="iStock_000012751071XSmall" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 0px 0px 20px; border-right-width: 0px" height="159" alt="iStock_000012751071XSmall" src="http://lh6.ggpht.com/_JW7gLMzR6nE/TCum5gAY_VI/AAAAAAAAAmo/FCFCa8ct9_Q/iStock_000012751071XSmall_thumb%5B2%5D.jpg?imgmax=800" width="240" align="right" border="0" /&gt;&lt;/a&gt;Using the ‘var’ keyword in C# has always spurred a hot debate among developers.&amp;#160; I believe ‘var’ should be used at all times.&amp;#160; I believe this not because I choose to be “lazy,” as those who argue against it frequently claim.&amp;#160; Of all the reasons I use ‘var’, laziness is not one of them.&lt;/p&gt;  &lt;p&gt;I’ve argued for the constant use of ‘var’ countless times; this blog post is a collection of thoughts that I have compiled resulting from my arguments.&amp;#160; Below are my reasons for using ‘var’ &lt;em&gt;all &lt;/em&gt;of the time.&lt;/p&gt;  &lt;h4&gt;It decreases code-coupling&lt;/h4&gt;  &lt;p&gt;Coupling between code and its dependent code can be reduced by using ‘var’.&amp;#160; I do not mean coupling from an architectural perspective nor at an IL-level (the type is inferred anyway), but simply at the code level. &lt;/p&gt;  &lt;h6&gt;Example:&lt;/h6&gt;  &lt;p&gt;Imagine there are 20 explicit type references spanning over twenty code files to&amp;#160; an object that returned an another object of type IFoo.&amp;#160; By explicit type references, I mean by prefacing each variable name with IFoo.&amp;#160; What happens if IFoo changes to IBar, but the interface’s methods are kept the same?&amp;#160; &lt;/p&gt;  &lt;p&gt;Wouldn’t you have to change it in 20 distinct places?&amp;#160; Doesn’t this increase coupling?&amp;#160; If ‘var’ was used, would you have to change anything?&amp;#160; Now, one could argue that it is trivial to change IFoo to IBar in a tool like ReSharper and have all of the references changed automatically.&amp;#160; However, what if IFoo is outside of our control?&amp;#160; It could live outside the solution or it could be a third-party library.&lt;/p&gt;  &lt;h4&gt;It is completely redundant with any expression involving the &amp;quot;new&amp;quot; operator&lt;/h4&gt;  &lt;p&gt;Especially with generics:&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;ICalculator&amp;lt;GBPCurrency, GBPTaxType&amp;gt; calculator = &lt;span class="kwrd"&gt;new&lt;/span&gt; GBPCalculator&amp;lt;GBPCurrency, GBPTaxType&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;








.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;can be shorted to: &lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;var&lt;/span&gt; calculator = &lt;span class="kwrd"&gt;new&lt;/span&gt; GBPCalculator&amp;lt;GBPCurrency, GBPTaxType&amp;gt; &lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;








.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Even if calculator is returned from a method (such as when implementing the repository pattern), if the method name is expressive enough it is obvious the object is a calculator.&amp;#160; The name of the variable should be expressive enough for you to know what the object it represents is.&amp;#160; &lt;strong&gt;This is important to realize:&lt;/strong&gt;&amp;#160; the variable expresses not what type it represents, but what the instance of that type actually is.&amp;#160; An instance of a type is truly an object, and should be treated as such.&lt;/p&gt;

&lt;p&gt;There is a distinction between an object and its type:&amp;#160; an object exists at runtime, it has properties and behaviors; types simply describe what an object &lt;em&gt;should be&lt;/em&gt;.&amp;#160; Knowing what type an object should be simply adds more noise to the source code, distracting the coder from what an object really &lt;em&gt;is&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;An object may be brought into this world by following the rules governed by a type, but this is only secondary information.&amp;#160; What the object actually &lt;em&gt;is &lt;/em&gt;and how it behaves is more important than its type.&amp;#160; When we use an object at runtime, we are dependent on its methods and properties, not its type.&amp;#160; These methods and properties are an object’s &lt;em&gt;behaviors&lt;/em&gt;, and it is behaviors we are dependent upon.&lt;/p&gt;

&lt;p&gt;The argument for knowing a variable's type has been brought up in the past.&amp;#160; The move from Hungarian notation in Microsoft-based C++ to non-Hungarian notation found in C# is a great example of this once hot topic.&amp;#160; Most Microsoft-based C++ developers at the time felt putting type identifiers in front of variable names was helpful, yet Microsoft published coding standards for C# that conflicted with these feelings.&lt;/p&gt;

&lt;p&gt;It was a major culture change and mind-shift to get developers to accept non-Hungarian notation.&amp;#160; I was among those who thought that non-Hungarian variable naming was downright wicked heresy and anyone following such a practice must be lazy and did not care about their profession.&amp;#160;&amp;#160; If knowing a variable’s type is so important, shouldn’t we then preface variable names in Hungarian style to know more information about an object's type?&lt;/p&gt;

&lt;h4&gt;You shouldn't have to care what the type of an object is&lt;/h4&gt;

&lt;p&gt;You should only care what you are trying do with an object, not what type an object may come from.&amp;#160; The methods you are attempting to call on an object &lt;em&gt;are &lt;/em&gt;its object contract, not the type.&amp;#160; If variable names, methods, and properties are named appropriately, then the type is simply redundant.&lt;/p&gt;

&lt;p&gt;In the previous example, the word &amp;quot;calculator&amp;quot; was repeated three times.&amp;#160; In that example, you only need to know that the instance of a type (the object) is a calculator, and it allows you to call a particular method or property.&lt;/p&gt;

&lt;p&gt;The only reason a calculator object was created was so that other code could interact with its object contract.&amp;#160; Other code needs the calculator’s methods and properties to get something done.&amp;#160; This need has no dependency on any type, only on an object’s behaviors..&lt;/p&gt;

&lt;p&gt;For example, as long as the object is a calculator, and the dependent code needs to call a method named “CalculateTax,” then the dependent code is coupled to an object with a method called “CalculateTax” and not a specific type.&amp;#160; This allows for much more flexibility, because now the variable can reference &lt;em&gt;any&lt;/em&gt; type as long as that type supports the “CalculateTax” method.&lt;/p&gt;

&lt;h4&gt;‘var’ is less noisy than explicitly referencing the type&lt;/h4&gt;

&lt;p&gt;As programming languages evolve, we spend less time telling the compiler and the computer what to do and more time expressing problems that exist in the specific domain we are working in. &lt;/p&gt;

&lt;p&gt;For example, there are a number of things in C++ that are very technical with respect to the machine, but have nothing to do with the domain.&amp;#160; If you are a customer of Quicken or Microsoft Money, all you really want to do is manage your finances better.&amp;#160; These software packages allow you to do that.&lt;/p&gt;

&lt;p&gt;The better a software package can do this for you, the more valuable it is to you.&amp;#160; Therefore, from a development perspective value is defined by how well a software package solves a user's problem.&amp;#160; When we set out to develop such software, the only code that is valuable is the code that contributes to solving a particular user’s problem.&amp;#160; The rest of the code is unfortunately a necessary waste, but is required due to limitations of technology.&lt;/p&gt;

&lt;p&gt;If we had infinite memory, we would not need to worry about deleting pointers in C++ or garbage collection in C#.&amp;#160; However, memory &lt;em&gt;is &lt;/em&gt;a limitation and therefore the technician in us has to find ways of coping with this limitation.&lt;/p&gt;

&lt;p&gt;The inclusion of ‘var’ into the C# language was done for a reason and bookmarks another iteration of C# (particularly C# 3.0).&amp;#160; It allows us to spend less time telling the compiler what to do and more time thinking about the problem we are trying to solve.&lt;/p&gt;

&lt;p&gt;Often I hear dogma like &amp;quot;use var only when using anonymous types.&amp;quot;&amp;#160; Why then should you use an anonymous type?&amp;#160; Under these conditions you usually do not have a choice, such as when assigning variables to the results of LINQ expressions.&amp;#160; Why do you not have a choice when using LINQ expressions?&amp;#160; It's because the expression is accomplishing something more functional and typing concerns are the least of your worries. &lt;/p&gt;

&lt;p&gt;In the ideal C# world, we would not have to put any words in front of a variable name at all.&amp;#160; In fact, prefacing a variable with anything just confuses the developer even further, and allows for poor variable names to become a standard whereby everyone is reliant upon explicit type references.&lt;/p&gt;

&lt;h4&gt;Arguments against using ‘var’&lt;/h4&gt;

&lt;p&gt;Some of the arguments I have heard against using ‘var’ and my responses to these are:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;em&gt;“It reduces clarity”&lt;/em&gt; – How?&amp;#160; By removing the noise in front of a variable name, your brain has only one thing to focus on:&amp;#160; the variable name.&amp;#160; It increases clarity. &lt;/li&gt;

  &lt;li&gt;&lt;em&gt;“It reduces readability and adds ambiguity”&lt;/em&gt; – This is similar to #1:&amp;#160; readability can be increased by removing words in front of the variable and by choosing appropriate variable names and method names.&amp;#160; Focusing on type distracts you from the real business problem you are trying to solve. &lt;/li&gt;

  &lt;li&gt;&lt;em&gt;“It litters the codebase”&lt;/em&gt; – This is usually an argument for consistency.&amp;#160; If your codebase uses explicit type references everywhere, then by all means do not use ‘var’.&amp;#160; Consistency is far more important.&amp;#160; Either change all explicit references in the codebase to ‘var’ or do not use ‘var’ at all.&amp;#160; This is a more general argument that applies to many more issues, such as naming conventions, physical organization policies, etc. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;As a final thought, why do we preface interface names with “I” but not class names with “C” as we did in the days when Microsoft-C++ was the popular kid in school?&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3406666181435971572-1642577393645093102?l=blog.michaelbrennan.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=HR8Qr_BqfH4:_q8kNJQ0XK4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=HR8Qr_BqfH4:_q8kNJQ0XK4:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=HR8Qr_BqfH4:_q8kNJQ0XK4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?i=HR8Qr_BqfH4:_q8kNJQ0XK4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=HR8Qr_BqfH4:_q8kNJQ0XK4:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MichaelBrennan/~4/HR8Qr_BqfH4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.michaelbrennan.net/feeds/1642577393645093102/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.michaelbrennan.net/2010/06/why-you-should-always-use-var-keyword.html#comment-form" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/1642577393645093102?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/1642577393645093102?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MichaelBrennan/~3/HR8Qr_BqfH4/why-you-should-always-use-var-keyword.html" title="Why You Should Always Use the ‘var’ Keyword in C#" /><author><name>Michael Brennan</name><uri>http://www.blogger.com/profile/09351708784127332440</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/_JW7gLMzR6nE/SvxkKuJiIkI/AAAAAAAAAgc/xXHC5leUnYI/S220/me4_left.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/_JW7gLMzR6nE/TCum5gAY_VI/AAAAAAAAAmo/FCFCa8ct9_Q/s72-c/iStock_000012751071XSmall_thumb%5B2%5D.jpg?imgmax=800" height="72" width="72" /><thr:total>5</thr:total><feedburner:origLink>http://blog.michaelbrennan.net/2010/06/why-you-should-always-use-var-keyword.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkMDR3k6eip7ImA9WxNQFk4.&quot;"><id>tag:blogger.com,1999:blog-3406666181435971572.post-8557564486890032025</id><published>2009-09-22T10:46:00.000-05:00</published><updated>2009-09-22T10:47:56.712-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-22T10:47:56.712-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="test-driven development" /><category scheme="http://www.blogger.com/atom/ns#" term="RSpec" /><category scheme="http://www.blogger.com/atom/ns#" term="philosophy" /><category scheme="http://www.blogger.com/atom/ns#" term="context specification" /><category scheme="http://www.blogger.com/atom/ns#" term="behavior-driven development" /><title>Introducing Context Specification</title><content type="html">&lt;h4&gt;&lt;a href="http://lh3.ggpht.com/_JW7gLMzR6nE/SjbONyfB3eI/AAAAAAAAAdE/hGhv6BGjxbE/s1600-h/iStock_000008633650Small%5B20%5D.jpg"&gt;&lt;img style="border-right-width: 0px; margin: 0px 0px 40px 40px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="iStock_000008633650Small" border="0" alt="iStock_000008633650Small" align="right" src="http://lh3.ggpht.com/_JW7gLMzR6nE/SjbOPND0TlI/AAAAAAAAAdI/Zk1soF3C_E0/iStock_000008633650Small_thumb%5B18%5D.jpg?imgmax=800" width="400" height="267" /&gt;&lt;/a&gt; Introduction&lt;/h4&gt;  &lt;p&gt;Context Specification is a lot more than merely a new way to write tests.&amp;#160; Although it was conceived around the same time as Behavior-Driven Development (BDD), and probably inspired by some of the BDD concepts, it is quite different.&lt;/p&gt;  &lt;p&gt;The difference between Context Specification and BDD lies in semantics and purpose.&amp;#160; Both are concerned about driving development through behaviors rather than implementation artifacts like classes or components.&lt;/p&gt;  &lt;p&gt;BDD frameworks are typically purposed to acceptance testing.&amp;#160; Recently, programmers encouraged customers to participate in requirements specification by writing the acceptance tests with tools like FIT.&amp;#160; Acceptance testing frameworks are built with the assumption that business experts will be writing tests.&lt;/p&gt;  &lt;p&gt;Acceptance testing frameworks often presume the user experience will be as rich as it is for the programmer.&amp;#160; However, a programmer’s notion of readability and elegance is usually quote different than a non-programmer’s notion of readability and elegance.&amp;#160; Often, programmers’ notions of readability and elegance will be different among themselves. &lt;/p&gt;  &lt;p&gt;The Given/When/Then grammar is a good example of programmer’s presumption of a good user experience.&amp;#160; We have to remember that when we create a tool to be used by non-programmers, we are designing user interaction and user experience.&amp;#160; Programmers are historically the least effective people in creating a good user experience.&lt;/p&gt;  &lt;p&gt;Given/When/Then grammar is good for capturing all of the details of a given scenario, but chooses to convey a lot of information in prose.&amp;#160; Using prose for this purpose often leads to run-on sentences that defeat effective communication.&lt;/p&gt;  &lt;p&gt;Specifications written with the Given/When/Then grammar are just as likely to be hard to read.&amp;#160; The grammar can be an obstruction to learning, communication, and understanding.&lt;/p&gt;  &lt;p&gt;Creating descriptions of specific uses of software is Context Specification’s primary concern.&amp;#160; As with BDD and Test-Driven Development, the descriptions are specifications that end up driving development, and leave behind an automated test suite.&lt;/p&gt;  &lt;h4&gt;Who Writes Specifications?&amp;#160; Who Writes Tests?&lt;/h4&gt;  &lt;p&gt;Programmer’s don’t like to write documentation, and business experts don’t like to write tests.&amp;#160; Context Specification is about creating a specifications document with code.&amp;#160; However, it doesn’t presume business experts will be writing the tests.&amp;#160; Programmer’s write the test; that’s what they’re good at; business experts are good at being business experts.&lt;/p&gt;  &lt;p&gt;Context Specification’s semantics focus on transforming traditional tests into specifications.&amp;#160; These specifications serve as descriptions and documentation for how a system &lt;em&gt;behaves&lt;/em&gt; under the various situations that the system is put into.&amp;#160; Context Specification grammar is designed to make specifications easy to read and understand.&lt;/p&gt;  &lt;p&gt;The goal is to create specifications that can be understood by anyone.&amp;#160; If defining specifications for business experts, the business experts should be able to understand the specifications that you are writing.&amp;#160; The implementation of the specifications in code should be easy to understand by programmers.&lt;/p&gt;  &lt;h4&gt;Context Awareness&lt;/h4&gt;  &lt;p&gt;&lt;em&gt;Context&lt;/em&gt; is a word used to describe the situations and conditions a system is put into by a user.&amp;#160; Context is often not fresh on the minds of programmers when writing tests because we’re often too caught up in thinking of the technical aspects of the problem.&lt;/p&gt;  &lt;p&gt;Focusing on the programming language and the tools around them can distract programmers from context.&amp;#160; &lt;a href="http://blog.scottbellware.com/"&gt;Scott Bellware&lt;/a&gt; has spoken several times about this concept, and his work is my motivation for this article.&lt;/p&gt;  &lt;p&gt;We need to do our best to be aware of context as we write tests, or &lt;em&gt;specifications&lt;/em&gt;.&amp;#160; We need to avoid thinking like programmers when writing and programming specifications.&amp;#160; Context Specification can help us with this thinking.&lt;/p&gt;  &lt;h4&gt;The Context Specification Mindset&lt;/h4&gt;  &lt;p&gt;&lt;a href="http://blog.scottbellware.com/" target="_blank"&gt;Scott Bellware&lt;/a&gt; describes the proper Context Specification mindset to have by stating, “Specify the experience, not the implementation.”&lt;/p&gt;  &lt;p&gt;Instead of thinking about technical terms and programming ideas like classes, methods, and modules when writing test, consider the &lt;em&gt;subject&lt;/em&gt; of the test in a particular &lt;em&gt;context&lt;/em&gt; that has a related set of side-effects that you can observe.&amp;#160; The observable side-effects are called &lt;em&gt;specifications&lt;/em&gt; in Context Specification grammar.&lt;/p&gt;  &lt;p&gt;The test suite isn’t really organized around specific abstractions in your system, unless the abstractions are organized around system behavior instead of data.&amp;#160; Subjects and context can describe one class or several classes.&amp;#160; Specifications reflect the observable effects of one method or several methods.&lt;/p&gt;  &lt;p&gt;Subjects, contexts, and specifications show the true value of the code you are creating from the perspective of business objectives rather than implementation details.&amp;#160; If you write specifications for subjects within a context, you end up writing code for what is truly important within your domain.&lt;/p&gt;  &lt;h4&gt;Example Context Specification Thought Process&lt;/h4&gt;  &lt;p&gt;There are a number of frameworks and methods to practice Context Specification with. In the .NET world, &lt;a href="http://code.google.com/p/specunit-net/"&gt;SpecUnit.NET&lt;/a&gt;, &lt;a href="http://code.google.com/p/specunit-net"&gt;MSpec&lt;/a&gt;, &lt;a href="http://specter.sourceforge.net/"&gt;Specter&lt;/a&gt;, or simply &lt;a href="http://www.nunit.org/index.php"&gt;NUnit&lt;/a&gt; with some syntactic sugar can be used to write specifications.&lt;/p&gt;  &lt;p&gt;While these are very functional frameworks, I believe the Ruby RSpec framework is the most elegant and easiest to use. Therefore, to make things simpler I will be writing all of my specifications using RSpec and all of my production code in Ruby.&lt;/p&gt;  &lt;p&gt;(I intend to write an article on how to use IronRuby with RSpec to test .NET code; stay tuned)&lt;/p&gt;  &lt;p&gt;Let’s use an iPod as an example since most people are familiar with how iPods function at a basic level.&amp;#160; While we write specifications we will remain aware of the context by not performing a technical dissection of the problem. &lt;/p&gt;  &lt;p&gt;Context Specification grammar requires a subject, context, and observable conditions.&amp;#160; In this example, the subject is an iPod.&amp;#160; One of the contexts could be, “when playing.”&lt;/p&gt;  &lt;p&gt;What conditions can you observe when an iPod is playing?&amp;#160; Without Context Specification, the answer depends on who is answering the question.&amp;#160; If a programmer is answering the question, you will get a very technical answer.&amp;#160; If a layman is answering the question, you will get a more general answer.&lt;/p&gt;  &lt;p&gt;The laymen might say, “when an iPod is playing, it should display the track name, artist, and album name; it should also play the track.”&lt;/p&gt;  &lt;p&gt;Conversely,&amp;#160; a programmer might say, “when an iPod is playing, it should find the audio file in the audio file database, load it into the audio player, and send a signal to the audio player to start playing the audio track, update the LCD to re-draw the screen with the appropriate information,” and this can go further into more technical dissection.&amp;#160; The programmer’s dialog is hyper-descriptive.&lt;/p&gt;  &lt;p&gt;However, with Context Specification, the specifications should be defined in a way so that almost anyone can understand them.&amp;#160; Because the layman understands the context in a more general circumstance, their specifications are more acceptable.&lt;/p&gt;  &lt;p&gt;Typically, the best person to work with when defining specifications is the person who knows the specifics of how a system should behave, without necessarily knowing how the technical aspects should be woven together.&amp;#160; A product owner is a good example of this.&lt;/p&gt;  &lt;p&gt;Product owners know how their product helps their business, and how it may help their customers.&amp;#160; However, they really don’t care about implementation details, such as the usage of a producer-consumer pattern to manage I/O requests, or adhering to SOLID principles.&lt;/p&gt;  &lt;h4&gt;Defining a Specification&lt;/h4&gt;  &lt;p&gt;Let’s start writing specifications for when an iPod is playing.&amp;#160; One of the more obvious specifications, as stated from the laymen’s quote above, is “it should display the track name.”&lt;/p&gt;  &lt;p&gt;Using RSpec, here is the code that defines this specification:&lt;/p&gt;  &lt;pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  1: &lt;span style="color: #00008b"&gt;require&lt;/span&gt; 'spec'
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  2: 
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  3: describe &amp;quot;&lt;span style="color: #8b0000"&gt;iPod&lt;/span&gt;&amp;quot;, &amp;quot;&lt;span style="color: #8b0000"&gt;when playing&lt;/span&gt;&amp;quot; &lt;span style="color: #0000ff"&gt;do&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  4:   it &amp;quot;&lt;span style="color: #8b0000"&gt;should display the track name&lt;/span&gt;&amp;quot;
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  5: &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Now let’s look at the RSpec output from this specification:&lt;/p&gt;

&lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;*
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;Pending:
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;iPod when playing should display the track name (Not Yet Implemented)
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;./ipod_spec_definition.rb:4
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;Finished in 0.015 seconds
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;1 example, 0 failures, 1 pending&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;RSpec informs us that there is 1 example and 1 pending, because we haven’t written the implementation of the specification yet.&amp;#160; Notice the readable output?&amp;#160; RSpec can generate a nifty HTML document with all of the specifications for reference.&amp;#160; This can be helpful to business experts for verifying the correctness of specifications.&lt;/p&gt;

&lt;p&gt;It is important to note that the context is typically in the &lt;a href="http://en.wikipedia.org/wiki/Gerund" target="_blank"&gt;gerund&lt;/a&gt; form of a verb (“ing” form, e.g “when running,” “when drinking,” etc.)&amp;#160; This eliminates accidental communication of timing or synchronization factors to the reader.&lt;/p&gt;

&lt;p&gt;For example, the context “when beginning to run” is irrelevant because it is inclusive in the context “when running.”&amp;#160; The same is true for “when finished running” because that statement occurs “when running” as well.&amp;#160; Programmers might not immediately understand this logic, but from a communication mindset and for the purposes of documentation it conveys the appropriate intent.&lt;/p&gt;

&lt;h4&gt;Implementing a Specification&lt;/h4&gt;

&lt;p&gt;Let’s start implementing the first specification:&amp;#160; “iPod when playing should display the track name.”&lt;/p&gt;

&lt;p&gt;Following traditional TDD practice, the implementation starts by building a skeleton of the code required for the compiler and with a failing test:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  1: &lt;span style="color: #00008b"&gt;require&lt;/span&gt; 'spec'
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  2: &lt;span style="color: #00008b"&gt;require&lt;/span&gt; 'not_a_mock'
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  3: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  4: &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Ipod
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  5:   &lt;span style="color: #0000ff"&gt;def&lt;/span&gt; play
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  6:   &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  7: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  8:   &lt;span style="color: #0000ff"&gt;def&lt;/span&gt; display_track_name
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  9:   &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 10: &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 11: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 12: describe Ipod, &amp;quot;&lt;span style="color: #8b0000"&gt;when playing&lt;/span&gt;&amp;quot; &lt;span style="color: #0000ff"&gt;do&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 13:   before :each &lt;span style="color: #0000ff"&gt;do&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 14:     @ipod = Ipod.new
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 15:     @ipod.track_methods
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 16:     @ipod.play
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 17:   &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 18: 
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 19:   it &amp;quot;&lt;span style="color: #8b0000"&gt;should display the track name&lt;/span&gt;&amp;quot; &lt;span style="color: #0000ff"&gt;do&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 20:     @ipod.should have_received(:display_track_name)
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 21:   &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 22: &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The implementation of the first specification is performed by providing a body to the specification we are trying to implement, asserting that the iPod should received the display_track_name method.&lt;/p&gt;

&lt;p&gt;Since the instance variable “ipod” does not exist, the “before” block is added to create a new instance of an “Ipod” class and assigns it to the instance variable needed.&amp;#160; The “before” block is run before each specification is run.&lt;/p&gt;

&lt;p&gt;Since all specifications will require an instance of an Ipod, this block makes writing future specifications convenient and further clarifies what subject the specifications are being written for (or more traditionally, the “system under test”).&lt;/p&gt;

&lt;p&gt;In order for the Ruby compiler to accept this code, we have to provide a skeleton Ipod class and define the methods that are being called within the specification and the “before” block (“play” and “display_track_name”).&lt;/p&gt;

&lt;p&gt;Note that I’ve elected to use a mocking framework called &lt;a href="http://notahat.com/not_a_mock"&gt;NotAMock&lt;/a&gt;.&amp;#160; NotAMock is an extension to RSpec that records all calls on an object in question.&amp;#160; I’ve further extended the framework so that you can call “track_methods” without specifying arguments to the method.&amp;#160; Previously, you would have to specify each method you wanted to track.&amp;#160; My change has been merged to the trunk and can be found &lt;a href="http://github.com/notahat/not_a_mock/commit/0a5ceac98c289df5f505db59191bb645e154443d"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After running the new changes in the RSpec runner, the output is:&lt;/p&gt;

&lt;pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;F
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;1)
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;'Ipod when playing should display the track name' FAILED
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;#&amp;lt;Ipod:0x2b90c24&amp;gt; didn't receive display_track_name
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;./ipod_spec_implementation_failing.rb:20:
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;Finished in 0.094 seconds
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;1 example, 1 failure&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Notice the test failed with the message “#&amp;lt;Ipod:0x2b90c24&amp;gt; didn't receive display_track_name&amp;quot;.&amp;#160; RSpec is reporting that the “display_track_name” method on the instance of the Ipod class was never called.&lt;/p&gt;

&lt;p&gt;Now it’s time to execute the next traditional step of TDD:&amp;#160; make the test pass with the least amount of work.&amp;#160; Adding a call to the display_track_name method inside the play method satisfies the RSpec test.&amp;#160; Re-running the RSpec runner will show that the test indeed passes without error.&lt;/p&gt;

&lt;p&gt;Now, obviously simply adding a call to the display_track_name method within the play method is an incorrect implementation.&amp;#160; Therefore, we are lead to the final phase of traditional TDD:&amp;#160; refactor:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  1: &lt;span style="color: #00008b"&gt;require&lt;/span&gt; 'spec'
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  2: &lt;span style="color: #00008b"&gt;require&lt;/span&gt; 'not_a_mock'
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  3: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  4: &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; TrackRepository
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  5:   &lt;span style="color: #0000ff"&gt;def&lt;/span&gt; &lt;span style="color: #0000ff"&gt;self&lt;/span&gt;.get_random_track_set
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  6:     &lt;span style="color: #008000"&gt;# query database to return random track set&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  7:     [ &amp;quot;&lt;span style="color: #8b0000"&gt;track1&lt;/span&gt;&amp;quot;, &amp;quot;&lt;span style="color: #8b0000"&gt;track2&lt;/span&gt;&amp;quot;, &amp;quot;&lt;span style="color: #8b0000"&gt;track3&lt;/span&gt;&amp;quot; ]
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  8:   &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  9: &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 10: 
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 11: &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Lcd
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 12:   &lt;span style="color: #0000ff"&gt;def&lt;/span&gt; display_track_name(track_name)
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 13:     &lt;span style="color: #008000"&gt;# interface with hardware to display track name&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 14:   &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 15: &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 16: 
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 17: &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Playset
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 18:   attr_reader :current_track_name
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 19: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 20:   &lt;span style="color: #0000ff"&gt;def&lt;/span&gt; &lt;span style="color: #0000ff"&gt;self&lt;/span&gt;.create_random_playset
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 21:     tracks = TrackRepository.get_random_track_set
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 22:     playset = Playset.new(tracks)
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 23:   &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 24: 
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 25:   &lt;span style="color: #0000ff"&gt;def&lt;/span&gt; initialize(tracks)
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 26:     @tracks = tracks
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 27:     @current_track_name = @tracks[0]
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 28:   &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 29: &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 30: 
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 31: &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Ipod
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 32:   &lt;span style="color: #0000ff"&gt;def&lt;/span&gt; initialize
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 33:     @lcd = Lcd.new
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 34:     @current_play_set = Playset.create_random_playset
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 35:   &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 36:   
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 37:   &lt;span style="color: #0000ff"&gt;def&lt;/span&gt; play
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 38:     display_track_name(@current_play_set.current_track_name)
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 39:   &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 40: 
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 41:   &lt;span style="color: #0000ff"&gt;def&lt;/span&gt; display_track_name(track_name)
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 42:     @lcd.display_track_name(track_name)
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 43:   &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 44: &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 45: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 46: describe Ipod, &amp;quot;&lt;span style="color: #8b0000"&gt;when playing&lt;/span&gt;&amp;quot; &lt;span style="color: #0000ff"&gt;do&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 47:   before :each &lt;span style="color: #0000ff"&gt;do&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 48:     @ipod = Ipod.new
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 49:     @ipod.track_methods
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 50:     @ipod.play
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 51:   &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 52: 
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 53:   it &amp;quot;&lt;span style="color: #8b0000"&gt;should display the track name&lt;/span&gt;&amp;quot; &lt;span style="color: #0000ff"&gt;do&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 54:     @ipod.should have_received(:display_track_name)
&lt;/pre&gt;&lt;pre style="background-color: #f2f2f2; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 55:   &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 56: &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The “play” method now asks the “current_play_set” instance variable what the current track name is and provides it to the “display_track_name” method.&amp;#160; This leads to creating the “current_play_set” instance variable, the “Playset” class, and a few other classes and methods. &lt;/p&gt;

&lt;p&gt;After running the RSpec test runner again, the above code satisfies the test without issues.&amp;#160; We know that we’ve safely refactored our code to a decent implementation without changing any behavior.&lt;/p&gt;

&lt;p&gt;It’s important to realize that one specification could drive out several methods and several classes.&amp;#160; It’s not necessary to pair subjects to classes, and specifications to methods.&amp;#160; Notice the specification we implemented lead to the creation of 4 classes and several methods.&lt;/p&gt;

&lt;p&gt;Once further specifications have been introduced at a more detailed level, it’s quite possible to switch contexts or subjects (or both) and further define specifications.&amp;#160; However, this is not a license to start specifying technical terms in our native programming mindset.&lt;/p&gt;

&lt;p&gt;Technical specifications should be reworded in less technical terms as much as possible.&amp;#160; Nonetheless, it’s still possible to run into scenarios where technical speech is unavoidable such as in describing state machines.&lt;/p&gt;

&lt;h4&gt;Summary&lt;/h4&gt;

&lt;p&gt;Context Specification’s focus is not about providing a new tool to write tests in an innovative way.&amp;#160; Programmers obsess over tools, and often the goal of Context Specification is eclipsed by programmer mentality to find new ways of doing things.&lt;/p&gt;

&lt;p&gt;While it does provide a much different way of writing tests, it requires a change in traditional programmer thinking.&amp;#160; A subject within a context must be thought of, and observable conditions form the specifications for that subject in its context.&lt;/p&gt;

&lt;p&gt;This demands programmers sway their technical minds from more of a usability, high-level, business oriented mind while defining specifications, and back down to the essence of the technology they are using when writing the code that satisfies those specifications.&lt;/p&gt;

&lt;p&gt;Providing documentation this way ensures that whomever can understand the subject and its context can understand the documentation and how that subject is used.&amp;#160; This swaying prevents writing documentation that is too technical.&lt;/p&gt;

&lt;p&gt;There are few instances when technical specifications need to be defined for a particular subject or context.&amp;#160; However, one example where I’ve run into that particular situation involves a sub-system that performs connection caching.&amp;#160; It is perfectly acceptable to write specifications for the caching operations under these circumstances because they define an inherent requirement.&lt;/p&gt;

&lt;p&gt;Context Specification allows you to write documentation for subjects within specific contexts that are most important, and makes you more aware of what you are trying to test and write code for.&lt;/p&gt;

&lt;p&gt;Domain awareness is strengthened by thinking more about a subject and context and less about object-oriented technical feats and the latest and greatest programming technology of the hour.&amp;#160; The quality of a solution’s design and code is improved by getting closer to the true problems in the domain.&lt;/p&gt;

&lt;p&gt;I hope you have fun writing specifications for your subjects and their contexts!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Special thanks to &lt;a href="http://blog.scottbellware.com/"&gt;Scott Bellware&lt;/a&gt; for providing the inspiration of these article and for reviewing it.&lt;/em&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3406666181435971572-8557564486890032025?l=blog.michaelbrennan.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=-KHnULKUItM:jAzGu4iSedQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=-KHnULKUItM:jAzGu4iSedQ:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=-KHnULKUItM:jAzGu4iSedQ:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?i=-KHnULKUItM:jAzGu4iSedQ:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=-KHnULKUItM:jAzGu4iSedQ:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MichaelBrennan/~4/-KHnULKUItM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.michaelbrennan.net/feeds/8557564486890032025/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.michaelbrennan.net/2009/09/introducing-context-specification.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/8557564486890032025?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/8557564486890032025?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MichaelBrennan/~3/-KHnULKUItM/introducing-context-specification.html" title="Introducing Context Specification" /><author><name>Michael Brennan</name><uri>http://www.blogger.com/profile/09351708784127332440</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/_JW7gLMzR6nE/SvxkKuJiIkI/AAAAAAAAAgc/xXHC5leUnYI/S220/me4_left.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/_JW7gLMzR6nE/SjbOPND0TlI/AAAAAAAAAdI/Zk1soF3C_E0/s72-c/iStock_000008633650Small_thumb%5B18%5D.jpg?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.michaelbrennan.net/2009/09/introducing-context-specification.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUcCRXw5fCp7ImA9WxJXFEo.&quot;"><id>tag:blogger.com,1999:blog-3406666181435971572.post-2361660213349703265</id><published>2009-06-08T11:04:00.001-05:00</published><updated>2009-06-08T11:04:24.224-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-08T11:04:24.224-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="DDD" /><title>An Interesting Article on DDD &amp; Ruby</title><content type="html">&lt;p&gt;&lt;a href="http://dddonruby.wordpress.com" target="_blank"&gt;Fábio Rehm&lt;/a&gt; and I have recently started talking about DDD and how to best implement some of the ideas in Ruby.&amp;#160; He just posted a very interesting article on his attempt at implementing a basic customer/order DDD example in Ruby.&amp;#160; Check it out:&amp;#160; &lt;a href="http://dddonruby.wordpress.com/2009/06/08/my-aproach-for-doing-ddd-on-ruby-introduction-and-part-i" target="_blank"&gt;http://dddonruby.wordpress.com/2009/06/08/my-aproach-for-doing-ddd-on-ruby-introduction-and-part-i&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3406666181435971572-2361660213349703265?l=blog.michaelbrennan.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=tSRiFP1t_84:pNlmmOVWhfw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=tSRiFP1t_84:pNlmmOVWhfw:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=tSRiFP1t_84:pNlmmOVWhfw:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?i=tSRiFP1t_84:pNlmmOVWhfw:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=tSRiFP1t_84:pNlmmOVWhfw:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MichaelBrennan/~4/tSRiFP1t_84" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.michaelbrennan.net/feeds/2361660213349703265/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.michaelbrennan.net/2009/06/interesting-article-on-ddd-ruby.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/2361660213349703265?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/2361660213349703265?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MichaelBrennan/~3/tSRiFP1t_84/interesting-article-on-ddd-ruby.html" title="An Interesting Article on DDD &amp;amp; Ruby" /><author><name>Michael Brennan</name><uri>http://www.blogger.com/profile/09351708784127332440</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/_JW7gLMzR6nE/SvxkKuJiIkI/AAAAAAAAAgc/xXHC5leUnYI/S220/me4_left.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.michaelbrennan.net/2009/06/interesting-article-on-ddd-ruby.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE4GQXs4eSp7ImA9WxJXFU0.&quot;"><id>tag:blogger.com,1999:blog-3406666181435971572.post-1035872975823788004</id><published>2009-06-06T20:58:00.001-05:00</published><updated>2009-06-08T18:15:20.531-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-08T18:15:20.531-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="expressiveness" /><category scheme="http://www.blogger.com/atom/ns#" term="DDD" /><category scheme="http://www.blogger.com/atom/ns#" term="elegance" /><category scheme="http://www.blogger.com/atom/ns#" term="philosophy" /><category scheme="http://www.blogger.com/atom/ns#" term="c#" /><category scheme="http://www.blogger.com/atom/ns#" term="C++" /><title>Expressiveness in Modern Programming Languages</title><content type="html">&lt;h4&gt;&lt;img style="border-right-width: 0px; margin: 0px 0px 40px 40px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="iStock_000009524688XSmall" border="0" alt="iStock_000009524688XSmall" align="right" src="http://lh5.ggpht.com/_JW7gLMzR6nE/SiyG26MVebI/AAAAAAAAAdA/cAfD4EmRPQY/iStock_000009524688XSmall%5B6%5D.jpg?imgmax=800" width="283" height="424" /&gt; The Technical Aptitude Required for Object-Oriented Programming&lt;/h4&gt;  &lt;p&gt;One of the primary purposes of an object-oriented programming language is to recreate representations of solutions to specific problems with code.&amp;#160; These representations are transformations of solutions that were typically solved previously with human interactions.&lt;/p&gt;  &lt;p&gt;Sometimes certain problems are solved only with the feat of modern computer software.&amp;#160; In other facets, ingenuous minds forge an inventive technology in software not unlike the ways of the great mechanical inventors of our age.&lt;/p&gt;  &lt;p&gt;Traditional object-oriented programming has been one of those great technical inventions.&amp;#160; While simple guidelines allow most programmers to attempt object-oriented programming, only few understand the principles and practices to actually model real concepts correctly.&lt;/p&gt;  &lt;p&gt;Frequently, programmers create objects that simply do not exist in the domain, or are bastardizations of the true domain concept.&amp;#160; Unfortunately, in these scenarios success is short-lived.&amp;#160; Maintainability quickly degrades, and often the code is completely thrown away.&lt;/p&gt;  &lt;p&gt;Incorrect representations of the domain are similar to the adage of trying to fit a square peg into a round hole.&amp;#160; Perhaps it’s possible to do this with creative technical feats.&amp;#160; However, as more features are requested, as bugs are fixed, and the code evolves, misrepresentations are quickly revealed.&lt;/p&gt;  &lt;p&gt;When this happens, feature requests and bug fixes take longer than expected, and a tremendous amount of pressure is put on the development team to meet deadlines.&amp;#160; Managers and executives begin to wonder why it is taking so much time to complete what they think are smaller tasks.&lt;/p&gt;  &lt;p&gt;All-nighters, pizza, and an insane amount of coffee support the developers through their death march.&amp;#160; If you have been developing for a decent amount of time, I am sure you have told of such horror stories over lunch or over a good beer.&lt;/p&gt;  &lt;h4&gt;The Expressiveness of a Language Matters&lt;/h4&gt;  &lt;p&gt;How do we prevent this pain?&amp;#160; There are several factors that contribute to these unfortunate events, however expressiveness within source code can be an important piece of the puzzle.&amp;#160; The best developers are often the most expressive in the language he or she is operating in.&lt;/p&gt;  &lt;p&gt;Instead of engineering solutions using technical wizardry and concepts that only programmers can understand, being expressive within the source code can keep business rules intact as development continues and solutions evolve.&lt;/p&gt;  &lt;p&gt;Expressiveness is a quality that developers must constantly be working toward.&amp;#160; Interestingly enough, the choice of a programming language can greatly assist in this struggle.&amp;#160; The more expressive a language is, the easier it is for the programmer to think about the domain.&lt;/p&gt;  &lt;p&gt;If non-programmer types and developers communicate with a ubiquitous language, this language can pervade into the source code.&amp;#160; The pervasiveness of a domain’s language allows ideas to be more easily understood.&lt;/p&gt;  &lt;h4&gt;Contrasting Language Expressiveness&lt;/h4&gt;  &lt;p&gt;On May 30th, 2009, &lt;a href="http://blog.scottbellware.com" target="_blank"&gt;Scott Bellware&lt;/a&gt; gave a talk entitled, “A Handful of Things You Can Do in Ruby That Scares the Pants Off of C# Developers.”&amp;#160; In this fascinating talk, Scott showed two functionally equivalent, plain classes:&amp;#160; one defined in C#, the other defined in Ruby.&lt;/p&gt;  &lt;p&gt;An interesting illustration emerged when Scott showed how the C# class’s definition comprised of a lot more statements to instruct the compiler on what to do and how to perform.&amp;#160; These statements take the programmer’s mind away from the domain and bring him or her to thinking in a technical programming wonderland.&lt;/p&gt;  &lt;p&gt;On the other hand, the Ruby class contained very little compiler instructions; the class was mostly comprised of domain expressions.&amp;#160; This is a powerful illustration, so I’d like to show it as well as a means of illustrating expressiveness.&lt;/p&gt;  &lt;p&gt;Let us define a simple class that records recommendations of businesses.&amp;#160; Recommendations can be used for any business type, such as restaurants.&amp;#160; A ‘recommender’ can recommend a business only once.&amp;#160; The class will allow a means to determine how many recommendations all of the businesses have received. &lt;/p&gt;  &lt;h4&gt;The C++ Definition (brace yourself)&lt;/h4&gt;  &lt;p&gt;First, I will define the class using one of the most traditional object-oriented programming languages:&amp;#160; C++.&amp;#160; Let’s start as we always do with C++:&amp;#160; with a header file definition:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #cc6633"&gt;#pragma&lt;/span&gt; &lt;span style="color: #cc6633"&gt;once&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;map&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; &lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;vector&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; &lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;string&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; std;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; BusinessRecommendations&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; RecommendationTracker&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt;:&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;typedef&lt;/span&gt; vector&amp;lt;pair&amp;lt;string, &lt;span style="color: #0000ff"&gt;unsigned&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt;&amp;gt;&amp;gt; RecommendationTotalsList;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; AddRecommendation(&lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* recommender,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;                                &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* business);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; GetRecommendationTotals(RecommendationTotalsList&amp;amp; recommendations) &lt;span style="color: #0000ff"&gt;const&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;private&lt;/span&gt;:&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;typedef&lt;/span&gt; map&amp;lt;string, vector&amp;lt;string&amp;gt;&amp;gt; RecommendationsMap;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;         RecommendationsMap recommendations;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; HasRecommenderRecommendedBusiness(&lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* recommender,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum25"&gt;  25:&lt;/span&gt;                                                &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* business);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum26"&gt;  26:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; RecordRecommendation(&lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* business, &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* recommender);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum27"&gt;  27:&lt;/span&gt;     };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum28"&gt;  28:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;This will define the basic contract that consuming code will use to work with the RecommendationTracker class.&amp;#160; Pay particular attention to the usage of pointers, references, “constness”, and other statements used to tell the compiler what to do.&lt;/p&gt;

&lt;p&gt;Now that we’ve declared the contract, lets look at the overly verbose definition of the class:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &amp;lt;algorithm&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color: #cc6633"&gt;#include&lt;/span&gt; &lt;span style="color: #006080"&gt;&amp;quot;RecommendationTracker.h&amp;quot;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; std;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; BusinessRecommendations&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; RecommendationTracker::AddRecommendation(&lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* recommender,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;                                                   &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* business)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (HasRecommenderRecommendedBusiness(recommender, business))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; exception(&lt;span style="color: #006080"&gt;&amp;quot;You may only recommend the same business once.&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;         RecordRecommendation(business, recommender);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; RecommendationTracker::GetRecommendationTotals(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;         RecommendationTotalsList&amp;amp; recommendationTotals) &lt;span style="color: #0000ff"&gt;const&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (RecommendationsMap::const_iterator it =&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;             recommendations.begin();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;             it != recommendations.end();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;             ++it)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum25"&gt;  25:&lt;/span&gt;             recommendationTotals.push_back(make_pair(it-&amp;gt;first,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum26"&gt;  26:&lt;/span&gt;                 it-&amp;gt;second.size()));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum27"&gt;  27:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum28"&gt;  28:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum29"&gt;  29:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum30"&gt;  30:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; RecommendationTracker::HasRecommenderRecommendedBusiness(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum31"&gt;  31:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* recommender,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum32"&gt;  32:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* business)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum33"&gt;  33:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum34"&gt;  34:&lt;/span&gt;         RecommendationsMap::const_iterator it =&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum35"&gt;  35:&lt;/span&gt;             recommendations.find(business);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum36"&gt;  36:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (it == recommendations.end())&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum37"&gt;  37:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; false;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum38"&gt;  38:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum39"&gt;  39:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; find(it-&amp;gt;second.begin(), it-&amp;gt;second.end(), recommender) !=&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum40"&gt;  40:&lt;/span&gt;             it-&amp;gt;second.end();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum41"&gt;  41:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum42"&gt;  42:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum43"&gt;  43:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; RecommendationTracker::RecordRecommendation(&lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* business,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum44"&gt;  44:&lt;/span&gt;                                                      &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* recommender)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum45"&gt;  45:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum46"&gt;  46:&lt;/span&gt;         recommendations[business].push_back(recommender);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum47"&gt;  47:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum48"&gt;  48:&lt;/span&gt;  }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Once again, we have several statements regarding constant state of pointers, language like “it-&amp;gt;second.size()”, which refers to the size of a vector that is the value portion of a map.&amp;#160; Look at how the class name is repeated before each function definition; this tells the compiler what scope we are in.&lt;/p&gt;

&lt;p&gt;Although not appearing in this example, frequently C++ programmers have to tell the compiler whether they want to allocate objects’ memory on the stack or heap, and have to manage the lifetime of that memory. &lt;/p&gt;

&lt;p&gt;All of these intrinsic C++ concepts force the programmer to be very technical.&amp;#160; Much time is spent on considering the language itself rather than the domain.&lt;/p&gt;

&lt;h4&gt;The C# Definition (a little better)&lt;/h4&gt;

&lt;p&gt;Now lets port this same class to C#.&amp;#160; C# is a bit more modern than C++, slightly more functional, and isn’t so concerned about telling the compiler what to do.&lt;/p&gt;

&lt;p&gt;One slight problem:&amp;#160; since there is no easy way to return a list of pairs as in the C++ definition, I’ve created a small helper class called “RecommendationTotal.”&amp;#160; I could have returned a dictionary, but the usage of a dictionary in C# usually suggests something other than name/value pairs:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; BusinessRecommendations&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; RecommendationTotal&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; RecommendationTotal(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; business, &lt;span style="color: #0000ff"&gt;uint&lt;/span&gt; numberOfRecommendations)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;             Business = business;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;             NumberOfRecommendations = numberOfRecommendations;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; Business&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;get&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;private set&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;uint&lt;/span&gt; NumberOfRecommendations&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;get&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;private set&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Some may argue that this adds readability to the code; for C#, it probably does.&amp;#160; Now, the definition of the RecommendationTracker class is as follows:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; BusinessRecommendations&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; RecommendationTracker&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;readonly&lt;/span&gt; IDictionary&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;, ICollection&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&amp;gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;             recommendations = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Dictionary&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;, ICollection&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&amp;gt;&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; AddRecommendation(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; recommender, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; business)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (HasRecommenderRecommendedBusiness(recommender, business))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Exception(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;                 &lt;span style="color: #006080"&gt;&amp;quot;You may only recommend the same business once.&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;             RecordRecommendation(business, recommender);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; IEnumerable&amp;lt;RecommendationTotal&amp;gt; RecommendationTotals&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;             get&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (var business &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; recommendations.Keys)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum25"&gt;  25:&lt;/span&gt;                 {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum26"&gt;  26:&lt;/span&gt;                     &lt;span style="color: #0000ff"&gt;yield&lt;/span&gt; &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; RecommendationTotal(business,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum27"&gt;  27:&lt;/span&gt;                         (&lt;span style="color: #0000ff"&gt;uint&lt;/span&gt;) recommendations[business].Count);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum28"&gt;  28:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum29"&gt;  29:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum30"&gt;  30:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum31"&gt;  31:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum32"&gt;  32:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; HasRecommenderRecommendedBusiness(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum33"&gt;  33:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; recommender, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; business)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum34"&gt;  34:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum35"&gt;  35:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; recommendations.ContainsKey(business) &amp;amp;&amp;amp;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum36"&gt;  36:&lt;/span&gt;                 recommendations[business].Contains(recommender);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum37"&gt;  37:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum38"&gt;  38:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum39"&gt;  39:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; RecordRecommendation(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; business,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum40"&gt;  40:&lt;/span&gt;                                           &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; recommender)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum41"&gt;  41:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum42"&gt;  42:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (!recommendations.ContainsKey(business))&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum43"&gt;  43:&lt;/span&gt;             {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum44"&gt;  44:&lt;/span&gt;                 recommendations[business] = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;&amp;gt;();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum45"&gt;  45:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum46"&gt;  46:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum47"&gt;  47:&lt;/span&gt;             recommendations[business].Add(recommender);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum48"&gt;  48:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum49"&gt;  49:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum50"&gt;  50:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;It’s nice that the declaration and definition are now combined into one, and we don’t have to deal with header files anymore.&amp;#160; However, there are still many references to compiler instructions.&lt;/p&gt;

&lt;p&gt;Every method must tell the compiler whether it should make the method public or private.&amp;#160; There are several references to types, such as “IEnumerable&amp;lt;RecommendationTotal&amp;gt;” and “IDictionary&amp;lt;string, ICollection&amp;lt;string&amp;gt;&amp;gt;.”&lt;/p&gt;

&lt;p&gt;These compiler instructions and type declarations take our minds away from thinking about the business and have us spend more time on thinking about programming.&lt;/p&gt;

&lt;h4&gt;The Ruby Definition&lt;/h4&gt;

&lt;p&gt;Now let’s look at the same code in Ruby:&lt;/p&gt;

&lt;pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  1: &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; RecommendationTracker
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  2:     &lt;span style="color: #0000ff"&gt;def&lt;/span&gt; add_recommendation(recommender, business)
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  3:       has_recommender_recommended_business?(recommender, business) &lt;span style="color: #0000ff"&gt;do&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  4:         &lt;span style="color: #00008b"&gt;raise&lt;/span&gt; &lt;a style="color: #ff0000" href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/StandardError.html"&gt;StandardError&lt;/a&gt;, 'You may only recommend the same business once.'
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  5:       &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  6: 
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  7:       @recommendations[business] &amp;lt;&amp;lt; recommender
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  8:     &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt;  9: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 10:     &lt;span style="color: #0000ff"&gt;def&lt;/span&gt; recommendation_totals
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 11:       recommendation_totals = &lt;a style="color: #ff0000" href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/Hash.html"&gt;Hash&lt;/a&gt;.new
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 12: 
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 13:       @recommendations.each_key &lt;span style="color: #0000ff"&gt;do&lt;/span&gt; |business|
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 14:         recommendation_totals[business] =  @recommendations[business].length
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 15:       &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 16: 
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 17:       recommendation_totals
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 18:     &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 19: 
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 20:   private
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 21:     &lt;span style="color: #0000ff"&gt;def&lt;/span&gt; initialize
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 22:       @recommendations = &lt;a style="color: #ff0000" href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/Hash.html"&gt;Hash&lt;/a&gt;.new &lt;span style="color: #0000ff"&gt;do&lt;/span&gt; |recommendations, business|
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 23:         recommendations[business] = &lt;span style="color: #00008b"&gt;Array&lt;/span&gt;.new
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 24:       &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 25:     &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 26: 
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 27:     &lt;span style="color: #0000ff"&gt;def&lt;/span&gt; has_recommender_recommended_business?(recommender, business)
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 28:       &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;false&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; !@recommendations.has_key? business
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 29:       &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;false&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; !@recommendations[business].include?(recommender)
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 30: 
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 31:       &lt;span style="color: #0000ff"&gt;yield&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 32:       &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 33:     &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,&amp;#39;Courier New&amp;#39;,courier,monospace; font-size: 12px"&gt; 34: &lt;span style="color: #0000ff"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;

&lt;p&gt;Notice how concise the Ruby definition is?&amp;#160; Compiler instructions are kept to a minimum, and the statements seems to emphasize the logic of the domain more.&amp;#160; Furthermore, all unnecessary references to types have been removed.&lt;/p&gt;

&lt;p&gt;Simple one line boolean statements have been rearranged in a “action if condition” format instead of “if action then condition.”&amp;#160; Methods have a question mark to add to readability.&amp;#160; Overall, the code is simply a lot more expressive.&lt;/p&gt;

&lt;h4&gt;Summary&lt;/h4&gt;

&lt;p&gt;Contrast the Ruby definition to the original C++ definition.&amp;#160; We’ve come a long way haven’t we?&amp;#160; What’s frightening is to think that Ruby was created in 1992!&amp;#160; For some reason, it’s only recent that it has been receiving a lot of attention (probably due to Rails and the direction of software toward web platforms).&lt;/p&gt;

&lt;p&gt;C++ is still a great language, and has its place within specific industries.&amp;#160; Game development is still primarily performed in C++, mainly due to the performance requirements where every bit of speed must be squeezed out of the code.&lt;/p&gt;

&lt;p&gt;C++ is definitely a professional programming language, and requires the programmer to understand the power it can provide.&amp;#160; A high degree of technical aptitude is required to create concrete, easy to understand, scalable, and powerful applications in C++.&amp;#160; Unfortunately, it also takes more time.&lt;/p&gt;

&lt;p&gt;However, instead of focusing on technical aptitude, developers should focus on adding value to the domain they are developing for.&amp;#160; This means most thought should be spent thinking about how best to express the core domain, where all of the business rules and logic should reside.&lt;/p&gt;

&lt;p&gt;Compiler instructions and nifty technical tricks are cool, but they take time away from adding to the core domain.&amp;#160; As Eric Evans has illustrated, the easiest way to determine the core domain is ask why is the development effort important?&amp;#160; How will the code you are writing help the business compete?&lt;/p&gt;

&lt;p&gt;The answer to those questions should point you straight to the core domain.&amp;#160; Expressiveness allows developers to define the core domain with a refined eloquence that helps lead to a deeper understanding of the problems at hand.&lt;/p&gt;

&lt;p&gt;If source code is less infected with technical concepts, true domain problems are more easily read.&amp;#160; This greatly adds to maintainability, and allows object-oriented principles to be practiced more easily.&lt;/p&gt;

&lt;p&gt;I am excited to see more developers diving into Ruby.&amp;#160; Hopefully, as the community becomes even more established than it already is, we will all start creating more elegant designs and expressions of problems without focusing too much on telling the compiler what to do.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3406666181435971572-1035872975823788004?l=blog.michaelbrennan.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=Dm-rmab78FM:c-M_FVIBytk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=Dm-rmab78FM:c-M_FVIBytk:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=Dm-rmab78FM:c-M_FVIBytk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?i=Dm-rmab78FM:c-M_FVIBytk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=Dm-rmab78FM:c-M_FVIBytk:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MichaelBrennan/~4/Dm-rmab78FM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.michaelbrennan.net/feeds/1035872975823788004/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.michaelbrennan.net/2009/06/expressiveness-in-modern-programming.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/1035872975823788004?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/1035872975823788004?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MichaelBrennan/~3/Dm-rmab78FM/expressiveness-in-modern-programming.html" title="Expressiveness in Modern Programming Languages" /><author><name>Michael Brennan</name><uri>http://www.blogger.com/profile/09351708784127332440</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/_JW7gLMzR6nE/SvxkKuJiIkI/AAAAAAAAAgc/xXHC5leUnYI/S220/me4_left.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/_JW7gLMzR6nE/SiyG26MVebI/AAAAAAAAAdA/cAfD4EmRPQY/s72-c/iStock_000009524688XSmall%5B6%5D.jpg?imgmax=800" height="72" width="72" /><thr:total>4</thr:total><feedburner:origLink>http://blog.michaelbrennan.net/2009/06/expressiveness-in-modern-programming.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEcGRX0-cCp7ImA9WxJQGEw.&quot;"><id>tag:blogger.com,1999:blog-3406666181435971572.post-1493520554446123926</id><published>2009-05-31T18:15:00.001-05:00</published><updated>2009-05-31T18:20:24.358-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-31T18:20:24.358-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Austin Code Camp" /><category scheme="http://www.blogger.com/atom/ns#" term="lean" /><category scheme="http://www.blogger.com/atom/ns#" term="philosophy" /><title>Organizations That Thrive off of Waste – Anti-Lean</title><content type="html">&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_JW7gLMzR6nE/SiMPpTmLSiI/AAAAAAAAAcU/2P0s34EcLK0/s1600-h/iStock_000003435126XSmall%5B5%5D.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 0px 40px 40px; display: inline; border-top: 0px; border-right: 0px" title="iStock_000003435126XSmall" border="0" alt="iStock_000003435126XSmall" align="right" src="http://lh5.ggpht.com/_JW7gLMzR6nE/SiMPqLI1T_I/AAAAAAAAAcY/fTbET7ZUaws/iStock_000003435126XSmall_thumb%5B3%5D.jpg?imgmax=800" width="283" height="424" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h4&gt;The Lean Thinking Movement&lt;/h4&gt;  &lt;p&gt;The primary goal in &lt;a href="http://en.wikipedia.org/wiki/Lean_software_development" target="_blank"&gt;Lean software development&lt;/a&gt; is to eliminate waste and optimize flow.&amp;#160; This is accomplished by applying the theory of constraints and reducing the time it takes to produce artifacts in areas of a process that take the most time.&lt;/p&gt;  &lt;p&gt;Lean ideology is critical for private organizations who cannot survive unless they optimize their business.&amp;#160; Customers who give an organization money choose to do so solely because the organization provides the best product or service for a fair price.&lt;/p&gt;  &lt;p&gt;As soon as another organization can produce something better, or cheaper, or a combination of the two, customers’ loyalty will promptly shift to the better organization.&amp;#160; Capitalism thrives off of this concept:&amp;#160; better products and services are created and refined due to competition.&lt;/p&gt;  &lt;p&gt;Capitalism can be a beautiful thing, allowing free-enterprise to provide us with a high-tech culture, provides phenomenal products and services, creates jobs, and allows our economy to thrive.&amp;#160; However, some organizations do not thrive off of competition.&lt;/p&gt;  &lt;h4&gt;Thriving off of Waste&lt;/h4&gt;  &lt;p&gt;Some organizations actually thrive off of being wasteful.&amp;#160; Margins are improved by overproducing or extending the amount of time it takes to provide value.&lt;/p&gt;  &lt;p&gt;For example, in his talk on Scrumban at the 2009 Austin Code Camp, &lt;a href="http://www.lostechies.com/blogs/joe_ocampo" target="_blank"&gt;Joe Ocampo&lt;/a&gt; described an insurance company who took longer to process claims because they made more money by doing so.&lt;/p&gt;  &lt;p&gt;I am not exactly sure how they profit from this condition; perhaps it reduces their risk, or allows their investments to squeeze out more interest before they pay for a claim.&lt;/p&gt;  &lt;h4&gt;Milk The Government&lt;/h4&gt;  &lt;p&gt;The federal government has been doing business like this for years.&amp;#160; The government encourages wasteful contractors.&amp;#160; It is no secret that major contractors underbid government projects on purpose in order to get the contract.&amp;#160; Once out of money, the contractor simply asks for more.&lt;/p&gt;  &lt;p&gt;Since everybody in the sector knows that the government operates like this, they are free to underbid by great margins, fully understanding they will not be able to complete the project with the original bid.&lt;/p&gt;  &lt;p&gt;Contractors will extend time lines, get paid to create features that add no value, and perform a number of other tricks to squeeze as much milk from the government utter as possible.&amp;#160; How is this possible?&amp;#160; The answer is the opposite of way capitalism thrives:&amp;#160; lack of competition.&lt;/p&gt;  &lt;p&gt;Since contractors only have one customer to satisfy, and they all know how that customer operates, they work together to pry as much cash out of government hands as possible.&amp;#160; One major contractor does the majority of the underbidding, while subcontractors negotiate for their slice of the pie.&lt;/p&gt;  &lt;p&gt;Under these circumstances, efficiency, optimization, adding value, eliminating waste, and all of the other tenants of Lean thinking do not make any sense.&amp;#160; If a contractor changes to embrace Lean thinking, they provide a more valuable product but are not rewarded for it.&lt;/p&gt;  &lt;p&gt;A Lean contractor would get paid less because the competition would underbid them.&amp;#160; The competition receives more money to create more waste and less value.&amp;#160; This type of business model has to stop!&lt;/p&gt;  &lt;h4&gt;“Change We Can Believe In”&amp;#160; - President Obama’s Campaign Slogan?&lt;/h4&gt;  &lt;p&gt;Companies who thrive off of waste destroy what is best about a capitalistic society.&amp;#160; The bigger a wasteful industry is, the more it hampers the economy, and sets back the great achievements of a culture.&amp;#160; Does anyone know how to change these industries?&amp;#160; Has anyone had success?&lt;/p&gt;  &lt;p&gt;The biggest problem I am aware of is the Federal Government.&amp;#160; We have got to get them to change their ways.&amp;#160; President Obama has stated that he wants to improve the government’s way of doing business.&lt;/p&gt;  &lt;p&gt;How do we start?&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3406666181435971572-1493520554446123926?l=blog.michaelbrennan.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=7kJkdZhcHC8:xCOJVIRZoRM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=7kJkdZhcHC8:xCOJVIRZoRM:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=7kJkdZhcHC8:xCOJVIRZoRM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?i=7kJkdZhcHC8:xCOJVIRZoRM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=7kJkdZhcHC8:xCOJVIRZoRM:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MichaelBrennan/~4/7kJkdZhcHC8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.michaelbrennan.net/feeds/1493520554446123926/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.michaelbrennan.net/2009/05/organizations-that-thrive-off-of-waste.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/1493520554446123926?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/1493520554446123926?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MichaelBrennan/~3/7kJkdZhcHC8/organizations-that-thrive-off-of-waste.html" title="Organizations That Thrive off of Waste – Anti-Lean" /><author><name>Michael Brennan</name><uri>http://www.blogger.com/profile/09351708784127332440</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/_JW7gLMzR6nE/SvxkKuJiIkI/AAAAAAAAAgc/xXHC5leUnYI/S220/me4_left.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/_JW7gLMzR6nE/SiMPqLI1T_I/AAAAAAAAAcY/fTbET7ZUaws/s72-c/iStock_000003435126XSmall_thumb%5B3%5D.jpg?imgmax=800" height="72" width="72" /><thr:total>3</thr:total><feedburner:origLink>http://blog.michaelbrennan.net/2009/05/organizations-that-thrive-off-of-waste.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMHSXo7cCp7ImA9WxJQF0k.&quot;"><id>tag:blogger.com,1999:blog-3406666181435971572.post-1622737070291755755</id><published>2009-05-30T22:26:00.001-05:00</published><updated>2009-05-30T22:27:18.408-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-30T22:27:18.408-05:00</app:edited><title>2009 Austin Code Camp Was Great!</title><content type="html">&lt;p&gt;I started off watching Jimmy Bogart introduce C# 4.0.&amp;#160; I had watched a video last year where &lt;a href="http://channel9.msdn.com/pdc2008/TL16/"&gt;Anders Hejlsberg&lt;/a&gt; introduced C# 4.0 more in depth.&amp;#160; Jimmy’s presentation was quite good, but seeing an introduction to C# 4.0 prior to the code camp, I wish I would have gone to &lt;a href="http://www.lostechies.com/blogs/joe_ocampo"&gt;Joe Ocampo&lt;/a&gt;’s “Git For People.”&lt;/p&gt;  &lt;p&gt;The talk on S.O.L.I.D. principles by Derick Bailey was great.&amp;#160; However, I only attended half the talk, and left after the explanation of the open-closed principle.&amp;#160; I have done a lot of reading on S.O.L.I.D. principles, and this was more of a recap for me.&lt;/p&gt;  &lt;p&gt;I went to &lt;a href="http://blog.scottbellware.com"&gt;Scott Bellware&lt;/a&gt;’s “A Handful of Things You Can Do in Ruby That Scares the Pants Off of C# Developers.”&amp;#160; This was one of the most entertaining talks of the day.&lt;/p&gt;  &lt;p&gt;Ruby was fighting to be my favorite language in the past couple of months; after today it definitely is now my favorite.&amp;#160; Scott showed some meta-programming that had a few C# developers’ jaws dropping.&lt;/p&gt;  &lt;p&gt;I think the best talk of the day was &lt;a href="http://www.lostechies.com/blogs/joe_ocampo/"&gt;Joe Ocampo&lt;/a&gt;’s discussion on Scrumban.&amp;#160; I had yet to see how to implement Lean principles into an actual process.&amp;#160; Joe showed his process and went into great detail.&amp;#160; Not only was the presentation informative, but Joe, as a speaker, is very entertaining!&lt;/p&gt;  &lt;p&gt;Finally, &lt;a href="http://www.lostechies.com/blogs/chad_myers/"&gt;Chad Myers&lt;/a&gt; gave a very detailed presentation on how to use FubuMVC.&amp;#160; Chad delivered exactly what I’d been hoping for:&amp;#160; how exactly to get started with it.&amp;#160; Prior to today, I had a hard time getting started with FubuMVC.&amp;#160; Chad presented great documentation on how to do just that.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3406666181435971572-1622737070291755755?l=blog.michaelbrennan.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=oRzidhnLt_4:S7-FWWDvciM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=oRzidhnLt_4:S7-FWWDvciM:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=oRzidhnLt_4:S7-FWWDvciM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?i=oRzidhnLt_4:S7-FWWDvciM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=oRzidhnLt_4:S7-FWWDvciM:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MichaelBrennan/~4/oRzidhnLt_4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.michaelbrennan.net/feeds/1622737070291755755/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.michaelbrennan.net/2009/05/2009-austin-code-camp-was-great.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/1622737070291755755?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/1622737070291755755?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MichaelBrennan/~3/oRzidhnLt_4/2009-austin-code-camp-was-great.html" title="2009 Austin Code Camp Was Great!" /><author><name>Michael Brennan</name><uri>http://www.blogger.com/profile/09351708784127332440</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/_JW7gLMzR6nE/SvxkKuJiIkI/AAAAAAAAAgc/xXHC5leUnYI/S220/me4_left.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://blog.michaelbrennan.net/2009/05/2009-austin-code-camp-was-great.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C08CRH86eCp7ImA9WxJQFkg.&quot;"><id>tag:blogger.com,1999:blog-3406666181435971572.post-1757252106145255985</id><published>2009-05-24T18:59:00.001-05:00</published><updated>2009-05-29T21:51:05.110-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-29T21:51:05.110-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Austin Code Camp" /><category scheme="http://www.blogger.com/atom/ns#" term="conferences" /><title>My Schedule For Austin Code Camp</title><content type="html">&lt;p&gt;The schedule for the 2009 Austin Code Camp has been posted, and I have picked which sessions I will be attending.&amp;#160; The Code Camp is this Saturday, May 30th.&lt;/p&gt;  &lt;p&gt;It was very tough to pick which classes I wanted to attend due to the great content.&amp;#160; Here is what I picked, with the class I would have attended had the main pick not been available:&lt;/p&gt;  &lt;p&gt;09:00am - 10:00am    &lt;br /&gt;Room 103, Sneak Peek at C# 4.0 by Jimmy Bogard     &lt;br /&gt;Runner up:&amp;#160; Git for People by Joe Ocampo&lt;/p&gt;  &lt;p&gt;10:00am - 12:00pm    &lt;br /&gt;Room 103, S.O.L.I.D. Software Development:&amp;#160; Achieving Object Oriented Principles, One Step At A Time by Derick Bailey     &lt;br /&gt;Runner up:&amp;#160; Introduction to Web testing with Watir and Ruby by Jim Mathews&lt;/p&gt;  &lt;p&gt;12:45pm - 02:45pm    &lt;br /&gt;Room 103, Enterprise Architecture Patterns:&amp;#160; Presentation, Business Logic, and Persistence by Chad Myers &amp;amp; John Teague     &lt;br /&gt;Runner up:&amp;#160; Intro to Scrumban by Joe Ocampo&lt;/p&gt;  &lt;p&gt;02:45pm - 04:45pm    &lt;br /&gt;Room 207, Introduction to FubuMVC by Chad Myers     &lt;br /&gt;Runner up:&amp;#160; Practical Inversion of Control by Matt Hinze&lt;/p&gt;  &lt;p&gt;I hope to see you or meet you there!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3406666181435971572-1757252106145255985?l=blog.michaelbrennan.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=X47AaCfUFOI:qd9PvhdHolU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=X47AaCfUFOI:qd9PvhdHolU:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=X47AaCfUFOI:qd9PvhdHolU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?i=X47AaCfUFOI:qd9PvhdHolU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=X47AaCfUFOI:qd9PvhdHolU:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MichaelBrennan/~4/X47AaCfUFOI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.michaelbrennan.net/feeds/1757252106145255985/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.michaelbrennan.net/2009/05/my-schedule-for-austin-code-camp.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/1757252106145255985?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/1757252106145255985?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MichaelBrennan/~3/X47AaCfUFOI/my-schedule-for-austin-code-camp.html" title="My Schedule For Austin Code Camp" /><author><name>Michael Brennan</name><uri>http://www.blogger.com/profile/09351708784127332440</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/_JW7gLMzR6nE/SvxkKuJiIkI/AAAAAAAAAgc/xXHC5leUnYI/S220/me4_left.jpg" /></author><thr:total>3</thr:total><feedburner:origLink>http://blog.michaelbrennan.net/2009/05/my-schedule-for-austin-code-camp.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkIDQ385eip7ImA9WxNTFU4.&quot;"><id>tag:blogger.com,1999:blog-3406666181435971572.post-2109102980986911330</id><published>2009-05-24T13:52:00.002-05:00</published><updated>2009-08-17T14:49:32.122-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-17T14:49:32.122-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="DDD" /><category scheme="http://www.blogger.com/atom/ns#" term="design" /><category scheme="http://www.blogger.com/atom/ns#" term="c#" /><title>Entities Should Not Depend on Other Objects</title><content type="html">&lt;p&gt;&lt;img title="iStock_000004447463XSmall" style="border-width: 0px; margin: 0px auto 15px; display: block; float: none;" alt="iStock_000004447463XSmall" src="http://lh3.ggpht.com/_JW7gLMzR6nE/ShmXej07xUI/AAAAAAAAAbc/cdSPb2vEwOA/iStock_000004447463XSmall%5B5%5D.jpg?imgmax=800" width="172" border="0" height="240" /&gt; For those familiar with Domain Driven Design (DDD), this may seem like common sense.  However, as more people adopt DDD concepts, this subtlety is definitely something to pay attention to.&lt;/p&gt;  &lt;h4&gt;Quick Overview of Entities&lt;/h4&gt;  &lt;p&gt;In DDD, an entity is a design pattern used to describe an object in the domain model that is truly unique; it has its own identity and distinctive behavior.  An easy way to identify entities is to ask yourself, “If I duplicate an instance of this object, will it cause data integrity issues or other problems within my domain?”&lt;/p&gt;  &lt;p&gt;For example, an address might be a value object or an entity, depending upon how it is used in your domain.  If an address can be duplicated and substituted in places where an address is needed without a problem, then it is a value object.&lt;/p&gt;  &lt;p&gt;However, if an address is truly unique, as it might be in a post office application, a duplicate address would cause data integrity problems.  If a package needed to be dispatched to a specific address, and two of those addresses existed with the same identity, this condition would cause problems; a package can only be delivered to one address.&lt;/p&gt;  &lt;h4&gt;An Example of Incorrectly Implementing Entities&lt;/h4&gt;  &lt;p&gt;Entities should be expressed with as much simplicity as possible.  An entity should only contain business logic specific to itself.  This concept is defined as plain-old CLR objects in C#/VB.NET, etc. (POCO), POJO in Java, PORO in Ruby, etc.&lt;/p&gt;  &lt;p&gt;If you find your entities are dependent on other objects, this is usually a design smell calling for the use of the service DDD pattern.  Let’s use the canonical customer/order example:&lt;/p&gt;  &lt;p&gt;Look at the following sample dialog with a domain expert.  This person is an expert in some sort of online retailing business you might be contracted to write software for:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;You:  So tell me a little bit more about your business, who are your customers?&lt;/p&gt;    &lt;p&gt;Expert:  We sell groceries online to people living in the New York City area.  We are fairly new in the market and are are looking to automate our business a little more, that’s why we’re hiring you!&lt;/p&gt;    &lt;p&gt;You:  Great!  I’ll do my best to improve your automation.  Let’s start with your customers, how do they place orders?&lt;/p&gt;    &lt;p&gt;Expert:  First, they browse around our online store, adding items to their shopping cart.  Once they are ready to checkout, they hit the checkout button.  We get an email from the customer containing a list of items from our inventory, and the quantity of those items that they want to purchase.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Your brain starts to flash with ideas on how to improve their current system.  First, you might make a value object to encapsulate line items in an order as follows:&lt;/p&gt;  &lt;div&gt;   &lt;div id="codeSnippet"   style="border-style: none; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;     &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum1" style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; LineItem&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum2" style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum3" style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; LineItem(&lt;span style="color: rgb(0, 0, 255);"&gt;uint&lt;/span&gt; itemId, &lt;span style="color: rgb(0, 0, 255);"&gt;uint&lt;/span&gt; quantity)&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum4" style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum5" style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;         ItemId = itemId;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum6" style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;         Quantity = quantity;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum7" style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum8" style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum9" style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;uint&lt;/span&gt; ItemId&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum10" style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum11" style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum12" style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum13" style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum14" style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum15" style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;uint&lt;/span&gt; Quantity&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum16" style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum17" style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum18" style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum19" style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum20" style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Next, let’s focus on the representation of the customer in the domain model.  The customer is definitely an entity; it cannot be duplicated and substituted for another customer, because this would result in the order being processed for the wrong person.&lt;/p&gt;

&lt;p&gt;A representation of a customer in a domain model needs an address, and the ability to change that address.  The domain expert stated that they do not service areas outside of New York City.  One way of expressing that in the entity is to throw an exception whenever the customer tries to change their address to a city other than New York City.&lt;/p&gt;

&lt;p&gt;Recall the domain expert stated, “We get an email from the customer containing a list of items from our inventory, and the quantity of those items that they want to purchase.”  This statement might lead you to think that you need to encapsulate this behavior on the Customer class itself.&lt;/p&gt;

&lt;p&gt;What the expert was really trying to communicate was that their current system compiles the customer information along with the order information and packages it up into an email.  Regardless, you go along with it, and start thinking about how to implement that behavior within the customer class.&lt;/p&gt;

&lt;p&gt;To handle the orders, you might have an order generator that serves as a DDD factory to create an order, along with an order processor that actually places the order in the system.&lt;/p&gt;

&lt;p&gt;Enough analysis, we now have a pretty good idea of what the first iteration of the Customer class should look like:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
 &lt;div id="codeSnippet"   style="border-style: none; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;
   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum1" style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; Customer&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum2" style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum3" style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;readonly&lt;/span&gt; IOrderGenerator orderGenerator;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum4" style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;readonly&lt;/span&gt; IOrderProcessor orderProcessor;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum5" style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; Address address;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum6" style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum7" style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; Customer(IOrderGenerator orderGenerator, IOrderProcessor orderProcessor) : &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;(orderGenerator, orderProcessor, &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Address())&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum8" style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum9" style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum10" style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum11" style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; Customer(IOrderGenerator orderGenerator, IOrderProcessor orderProcessor, Address address)&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum12" style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum13" style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.orderGenerator = orderGenerator;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum14" style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.orderProcessor = orderProcessor;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum15" style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.address = address;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum16" style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum17" style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum18" style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; Address Address&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum19" style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt;     { &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum20" style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum21" style="color: rgb(96, 96, 96);"&gt;  21:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum22" style="color: rgb(96, 96, 96);"&gt;  22:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; address;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum23" style="color: rgb(96, 96, 96);"&gt;  23:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum24" style="color: rgb(96, 96, 96);"&gt;  24:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum25" style="color: rgb(96, 96, 96);"&gt;  25:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum26" style="color: rgb(96, 96, 96);"&gt;  26:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (newAddress.City != &lt;span style="color: rgb(0, 96, 128);"&gt;"New York City"&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum27" style="color: rgb(96, 96, 96);"&gt;  27:&lt;/span&gt;                 &lt;span style="color: rgb(0, 0, 255);"&gt;throw&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; ArgumentException(&lt;span style="color: rgb(0, 96, 128);"&gt;"We do not service customers in your area, sorry!"&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum28" style="color: rgb(96, 96, 96);"&gt;  28:&lt;/span&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum29" style="color: rgb(96, 96, 96);"&gt;  29:&lt;/span&gt;             address = newAddress;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum30" style="color: rgb(96, 96, 96);"&gt;  30:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum31" style="color: rgb(96, 96, 96);"&gt;  31:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum32" style="color: rgb(96, 96, 96);"&gt;  32:&lt;/span&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum33" style="color: rgb(96, 96, 96);"&gt;  33:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; OrderResult PlaceOrder(IEnumerable&amp;lt;LineItem&amp;gt; lineItems)&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum34" style="color: rgb(96, 96, 96);"&gt;  34:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum35" style="color: rgb(96, 96, 96);"&gt;  35:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; orderInformation = orderGenerator.CreateOrderFromLineItems(lineItems);&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum36" style="color: rgb(96, 96, 96);"&gt;  36:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; orderProcessor.ProcessOrder(orderInformation);&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum37" style="color: rgb(96, 96, 96);"&gt;  37:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum38" style="color: rgb(96, 96, 96);"&gt;  38:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;With this implementation, it seems very easy to place an order with code like this:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
 &lt;pre id="codeSnippet" style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;customer.PlaceOrder(lineItems);&lt;/pre&gt;


&lt;/div&gt;

&lt;h4&gt;&lt;/h4&gt;

&lt;h4&gt;&lt;/h4&gt;

&lt;h4&gt;The Correct Way of Implementing Entities&lt;/h4&gt;

&lt;p&gt;The problem with the Customer implementation is that it is coupled to an order generator and an order processor.  This implies that in the real domain, customers have knowledge of these two services.&lt;/p&gt;

&lt;p&gt;The way a customer is expressed in this domain model is fundamentally flawed.  Customers do not know of such things; I frequently shop on Amazon.com, and I have no knowledge of an order generator, nor a processor.&lt;/p&gt;

&lt;p&gt;In DDD, the order generator is an example of the factory pattern.  Factories are only used to support a domain model, not to define the domain model.  There are exceptions where the domain actually has some concept of creating something new, such as real factories.&lt;/p&gt;

&lt;p&gt;The order processor is an example of the DDD service pattern, encapsulating interactions between other entities and value objects.  Other services or a higher layer should be consuming the order processor, not entities or value objects.&lt;/p&gt;

&lt;p&gt;A more appropriate implementation of the Customer class can be defined by stripping dependencies on the two services from the class, distilling what is truly important to a customer in this domain model.  In this example, all that would remain is the validation that occurs when setting a new address.&lt;/p&gt;

&lt;p&gt;This greatly simplifies the Customer class, and allows the definition to be a POCO:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
 &lt;div id="codeSnippet"   style="border-style: none; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;
   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum1" style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; Customer&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum2" style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum3" style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; Address address;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum4" style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum5" style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; Customer() : &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;(&lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Address())&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum6" style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum7" style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum8" style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum9" style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; Customer(Address address)&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum10" style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum11" style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.address = address;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum12" style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum13" style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum14" style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; Address Address&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum15" style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;     { &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum16" style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;get&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum17" style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum18" style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; address;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum19" style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum20" style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;set&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum21" style="color: rgb(96, 96, 96);"&gt;  21:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum22" style="color: rgb(96, 96, 96);"&gt;  22:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;value&lt;/span&gt;.City != &lt;span style="color: rgb(0, 96, 128);"&gt;"New York City"&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum23" style="color: rgb(96, 96, 96);"&gt;  23:&lt;/span&gt;                 &lt;span style="color: rgb(0, 0, 255);"&gt;throw&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; ArgumentException(&lt;span style="color: rgb(0, 96, 128);"&gt;"We do not service customers in your area, sorry!"&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum24" style="color: rgb(96, 96, 96);"&gt;  24:&lt;/span&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum25" style="color: rgb(96, 96, 96);"&gt;  25:&lt;/span&gt;             address = &lt;span style="color: rgb(0, 0, 255);"&gt;value&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum26" style="color: rgb(96, 96, 96);"&gt;  26:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum27" style="color: rgb(96, 96, 96);"&gt;  27:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum28" style="color: rgb(96, 96, 96);"&gt;  28:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Notice how simpler the class is?  It contains business logic only.  The messiness of invoking the services has been removed.  The removed behavior is an excellent candidate for another service, due to its interaction with entities and value objects.  Let’s create an OrderService class:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
 &lt;div id="codeSnippet"   style="border-style: none; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;
   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum1" style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; OrderService&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum2" style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum3" style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;readonly&lt;/span&gt; IOrderGenerator orderGenerator;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum4" style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;readonly&lt;/span&gt; IOrderProcessor orderProcessor;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum5" style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum6" style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; OrderService(IOrderGenerator orderGenerator, IOrderProcessor orderProcessor)&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum7" style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum8" style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.orderGenerator = orderGenerator;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum9" style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.orderProcessor = orderProcessor;&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum10" style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum11" style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;  &lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum12" style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; OrderResult PlaceOrderForCustomer(Customer customer, IEnumerable&amp;lt;LineItem&amp;gt; lineItems)&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum13" style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum14" style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; orderInformation = orderGenerator.CreateOrderForCustomer(customer);&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum15" style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;         orderInformation.AddLineItems(lineItems);&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum16" style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; orderProcessor.ProcessOrder(orderInformation);&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre    style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt;font-family:'Courier New',courier,monospace;font-size:8pt;color:white;"&gt;&lt;span id="lnum17" style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

   &lt;pre   style="border-style: none; margin: 0em; padding: 0px; overflow: visible; width: 100%; color: black; direction: ltr; line-height: 12pt; background-color: rgb(244, 244, 244); text-align: left;font-family:'Courier New',courier,monospace;font-size:8pt;"&gt;&lt;span id="lnum18" style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The OrderService class adheres to the dependency inversion principle and can be configured with an IoC container to inject default implementations of the constructor dependencies.  This service allows for interaction of the customer entity, line item value objects, an order generation service, and an order processing service.&lt;/p&gt;

&lt;p&gt;It is quite common to have services be dependent upon other services.  Services, factories, and repositories can have dependencies on other other pieces in the domain model or on infrastructure level objects. &lt;/p&gt;

&lt;p&gt;We can now write a line of code to place an order similar to the previous line, without making direct calls on the Customer instance:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
 &lt;pre id="codeSnippet" style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; direction: ltr; line-height: 12pt; font-family: 'Courier New',courier,monospace; background-color: rgb(244, 244, 244); text-align: left;"&gt;orderService.PlaceOrderForCustomer(customer, lineItems);&lt;/pre&gt;


&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;h4&gt;Summary&lt;/h4&gt;

&lt;p&gt;You should be weary of a design smell whenever your entities depend on other objects.  These dependencies are typically domain model services or infrastructure pieces, such as logging or database support classes (ActiveRecord anyone?).&lt;/p&gt;

&lt;p&gt;Keep your entities as simple and pure as possible.  Leaving out threading, logging, and all of the other impurities that can muck up the class.  Use services to encapsulate interaction between entities and value objects.&lt;/p&gt;

&lt;p&gt;For further information, I recommend reading Eric Evans’ &lt;em&gt;Domain Driven Design.&lt;/em&gt;&lt;/p&gt;

&lt;table class="display"&gt;&lt;tbody&gt;
   &lt;tr&gt;
     &lt;td&gt;&lt;img src="http://ecx.images-amazon.com/images/I/31ywgz51v-L._SL75_.jpg" /&gt; &lt;/td&gt;

     &lt;td valign="top"&gt;&lt;a href="http://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215%3FSubscriptionId%3D0JTCV5ZMHMF7ZYTXGFR2%26tag%3Dbrdicr-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0321125215"&gt;Domain-Driven Design: Tackling Complexity in the Heart of Software&lt;/a&gt; &lt;/td&gt;
   &lt;/tr&gt;
 &lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3406666181435971572-2109102980986911330?l=blog.michaelbrennan.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=A45bfbw5k7E:GBtMzS26YCw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=A45bfbw5k7E:GBtMzS26YCw:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=A45bfbw5k7E:GBtMzS26YCw:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?i=A45bfbw5k7E:GBtMzS26YCw:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=A45bfbw5k7E:GBtMzS26YCw:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MichaelBrennan/~4/A45bfbw5k7E" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.michaelbrennan.net/feeds/2109102980986911330/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.michaelbrennan.net/2009/05/entities-should-not-depend-on-other.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/2109102980986911330?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/2109102980986911330?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MichaelBrennan/~3/A45bfbw5k7E/entities-should-not-depend-on-other.html" title="Entities Should Not Depend on Other Objects" /><author><name>Michael Brennan</name><uri>http://www.blogger.com/profile/09351708784127332440</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/_JW7gLMzR6nE/SvxkKuJiIkI/AAAAAAAAAgc/xXHC5leUnYI/S220/me4_left.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/_JW7gLMzR6nE/ShmXej07xUI/AAAAAAAAAbc/cdSPb2vEwOA/s72-c/iStock_000004447463XSmall%5B5%5D.jpg?imgmax=800" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://blog.michaelbrennan.net/2009/05/entities-should-not-depend-on-other.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkQMRXkyfyp7ImA9WxNTFU4.&quot;"><id>tag:blogger.com,1999:blog-3406666181435971572.post-4192680243718718076</id><published>2009-05-19T07:11:00.002-05:00</published><updated>2009-08-17T14:46:24.797-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-08-17T14:46:24.797-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="elegance" /><category scheme="http://www.blogger.com/atom/ns#" term="philosophy" /><category scheme="http://www.blogger.com/atom/ns#" term="design" /><title>Elegance in Code</title><content type="html">&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_JW7gLMzR6nE/ShKiA5MrrvI/AAAAAAAAAag/jeYMaUlnHnY/s1600-h/iStock_000006810500XSmall%5B9%5D.jpg"&gt;&lt;img style="border-width: 0px; margin: 0px auto 35px; display: block; float: none;" title="Elegance" alt="Elegance" src="http://lh3.ggpht.com/_JW7gLMzR6nE/ShKiBB_I-4I/AAAAAAAAAak/a1Xpxv7gWuU/iStock_000006810500XSmall_thumb%5B9%5D.jpg?imgmax=800" width="425" border="0" height="282" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Elegance is a refined quality of gracefulness and good taste.  An elegant solution to a problem is defined by an ingenious simplicity and neatness.  Elegance demands an unusual effectiveness, and allows for complexity to be illustrated in a beautiful and fascinating way.&lt;/p&gt;  &lt;p&gt;We should all strive for elegance in our code.  Elegance is what allows clear communication of a solution, no matter how complex the problem may be.&lt;/p&gt;  &lt;p&gt;Utterly expressive code conveys its intent explicitly, and facilitates an ease of acceptance for new features or changes to existing behaviors.  In this way, illustrative code becomes the documentation of itself, eliminating the need for other artifacts to crack the code into more readable terms.&lt;/p&gt;  &lt;p&gt;Haphazardly writing code, without a struggle for elegance, breeds endless cycles of sloppiness, “hacks,” maintenance nightmares, and confusing pieces to an endless puzzle.  &lt;/p&gt;  &lt;p&gt;Are you familiar with the broken window effect?  The idea was first published in March of 1982 inside &lt;em&gt;The Atlantic Monthly &lt;/em&gt;entitled, “Broken Windows,” by James Q. Wilson and George L. Kelling.  An excerpt reads as follows:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Consider a building with a few broken windows.  If the windows are not repaired, the tendency is for vandals to break a few more windows.  Eventually, they may even break into the building, and if it’s unoccupied, perhaps become squatters light fires inside.  Or consider a sidewalk.  Some litter accumulates.  Soon, more litter accumulates.  Eventually, people start leaving bags of trash from take-out restaurants there or break into cars.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The broken window effect was used to cleanup the great city of New York in the 1990’s.  Code can also have “broken windows” in the form of haphazardness, sloppiness, incompleteness, and hacks.&lt;/p&gt;  &lt;p&gt;These broken windows can be fixed in an effort to strive toward elegance.  The more the struggle toward elegance is cultivated, the easier maintenance becomes and new features are accepted with simplicity.&lt;/p&gt;  &lt;p&gt;Bad architectural design of software that cannot be changed forces those who strive for elegance to bang their head against a wall repeatedly.  Architectural changes are not cheap, and often perpetuate their cost as time goes by.&lt;/p&gt;  &lt;p&gt;A bad architecture is like having a three-legged mule.  The cost of hacking a solution up in order to ride on top of the three-legged mule will eventually compound until the mule trips and everything it was carrying crashes down with it.&lt;/p&gt;  &lt;p&gt;Exceptional architectural design should be fanatically sought after by the people able to change it.  Designers ought to be the masters of elegance; without an elegant design, the code which supports it is truly doomed.&lt;/p&gt;  &lt;p&gt;Developers often misunderstand elegance and reduce its meaning to simplicity alone.  Simplicity by itself is in no way elegant.  Simplicity is not bad, but complete simplicity in a complex system is not possible;  the complexities simply cannot be made simple.  Elegance is required in these situations.&lt;/p&gt;  &lt;p&gt;For example, a toaster is a simple contraption.  You put an item in the slot, push the button down, and in a few minutes your toasted wishes come true.  Functionally, this is a simple procedure.&lt;/p&gt;  &lt;p&gt;However, attractive looking kitchens demand attractive looking toasters.  A functional, beautiful toaster requires a bit of elegance:&lt;/p&gt;  &lt;table class="display" width="100%"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td width="50%" valign="top"&gt;&lt;a href="http://lh5.ggpht.com/_JW7gLMzR6nE/ShNvf1heB4I/AAAAAAAAAaw/FWXFUr0SOrI/s1600-h/iStock_000002547950XSmall%5B4%5D.jpg"&gt;&lt;img style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="iStock_000002547950XSmall" alt="iStock_000002547950XSmall" src="http://lh3.ggpht.com/_JW7gLMzR6nE/ShNvgGPf0fI/AAAAAAAAAa0/hBr0xeqb6ZM/iStock_000002547950XSmall_thumb%5B2%5D.jpg?imgmax=800" width="240" border="0" height="200" /&gt;&lt;/a&gt; &lt;/td&gt;        &lt;td width="50%" valign="top"&gt;&lt;a href="http://lh5.ggpht.com/_JW7gLMzR6nE/ShNvgU1A3LI/AAAAAAAAAa4/QINBwuScW8Q/s1600-h/iStock_000006158277XSmall%5B4%5D.jpg"&gt;&lt;img style="border-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="Shiny chrome toaster with two slices of bread" alt="Shiny chrome toaster with two slices of bread" src="http://lh6.ggpht.com/_JW7gLMzR6nE/ShNvgrZsDJI/AAAAAAAAAa8/PYhDOhzqRAI/iStock_000006158277XSmall_thumb%5B2%5D.jpg?imgmax=800" width="240" border="0" height="159" /&gt;&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td width="50%" valign="top"&gt;         &lt;p align="center"&gt;A functional, inelegant toaster&lt;/p&gt;       &lt;/td&gt;        &lt;td width="50%" valign="top"&gt;         &lt;p align="center"&gt;A functional, beautiful, simple toaster&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;How can we be elegant developers?  Unfortunately, there is no simple answer;  elegance is not a design pattern.  Usage of the proper design patterns in the proper place, and at the proper time, can positively affect the elegance of code.&lt;/p&gt;  &lt;p&gt;Conversely, overuse or misuse of design patterns can quickly destroy any existent elegance.  A continuous study of architectural design, code design, and experience while keeping elegance in mind will produce a great developer.&lt;/p&gt;  &lt;p&gt;Therefore, the greatest developers can express complex ideas in a superior and fascinating way, explicitly communicate intent, and produce code that is surprisingly easy to read and maintain.&lt;/p&gt;  &lt;p&gt;For further study, I would recommend reading Eric Evans’ &lt;em&gt;Domain Driven Design&lt;/em&gt;. Eric is one of the most eloquent expressive writers I have ever read, and I am sure his code reads the same way.  I would also recommend Robert C. Martin's &lt;em&gt;Clean Code&lt;/em&gt;, as he is one of the most outspoken legends on the matter.&lt;/p&gt;  &lt;table style="border-width: 0px;" class="display"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td width="128"&gt;&lt;img style="border-width: 0px; display: inline; margin-left: 0px; margin-right: 0px;" src="http://ecx.images-amazon.com/images/I/515FeOFonQL._SL160_.jpg" border="0" /&gt; &lt;/td&gt;        &lt;td width="321" valign="top"&gt;&lt;a href="http://www.amazon.com/Domain-Driven-Design-Fowler-Martin-Evans/dp/B001JDYE0O%3FSubscriptionId%3D0JTCV5ZMHMF7ZYTXGFR2%26tag%3Dbrdicr-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB001JDYE0O"&gt;Domain-Driven Design&lt;/a&gt; &lt;/td&gt;        &lt;td width="76"&gt;&lt;img style="border-width: 0px; display: inline; margin-left: 0px; margin-right: 0px;" src="http://ecx.images-amazon.com/images/I/419EFaGEGvL._SL160_.jpg" align="left" border="0" /&gt; &lt;/td&gt;        &lt;td width="267" valign="top"&gt;&lt;a href="http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882%3FSubscriptionId%3D0JTCV5ZMHMF7ZYTXGFR2%26tag%3Dbrdicr-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0132350882"&gt;Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin Series)&lt;/a&gt; &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3406666181435971572-4192680243718718076?l=blog.michaelbrennan.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=b91Pc3XeAYU:vn_RxyGBFws:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=b91Pc3XeAYU:vn_RxyGBFws:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=b91Pc3XeAYU:vn_RxyGBFws:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?i=b91Pc3XeAYU:vn_RxyGBFws:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=b91Pc3XeAYU:vn_RxyGBFws:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MichaelBrennan/~4/b91Pc3XeAYU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.michaelbrennan.net/feeds/4192680243718718076/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.michaelbrennan.net/2009/05/elegance-in-code.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/4192680243718718076?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/4192680243718718076?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MichaelBrennan/~3/b91Pc3XeAYU/elegance-in-code.html" title="Elegance in Code" /><author><name>Michael Brennan</name><uri>http://www.blogger.com/profile/09351708784127332440</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/_JW7gLMzR6nE/SvxkKuJiIkI/AAAAAAAAAgc/xXHC5leUnYI/S220/me4_left.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/_JW7gLMzR6nE/ShKiBB_I-4I/AAAAAAAAAak/a1Xpxv7gWuU/s72-c/iStock_000006810500XSmall_thumb%5B9%5D.jpg?imgmax=800" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://blog.michaelbrennan.net/2009/05/elegance-in-code.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUEFQnk8fCp7ImA9WxJRFks.&quot;"><id>tag:blogger.com,1999:blog-3406666181435971572.post-1275784818630954571</id><published>2009-05-18T08:56:00.001-05:00</published><updated>2009-05-18T11:20:13.774-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-18T11:20:13.774-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gotchas" /><category scheme="http://www.blogger.com/atom/ns#" term="c#" /><title>What happens when you change a struct to a class in .NET if you don’t recompile the type’s dependencies?</title><content type="html">&lt;p&gt;An interesting issue arose out of a recent code review I was conducting.&amp;#160; If you change a type from a struct to a class, do you have to recompile all modules that are dependent on that type?&lt;/p&gt;  &lt;p&gt;Let’s use a simple example.&amp;#160; The following diagram illustrates several packages that are dependent on a “Geometry” package, with the Geometry package containing a struct called “Point”:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_JW7gLMzR6nE/ShGKktXpKGI/AAAAAAAAAaQ/ODBEZu5kGs8/s1600-h/Module_Dependency_Example%5B5%5D.jpg"&gt;&lt;img title="Module_Dependency_Example" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="326" alt="Module_Dependency_Example" src="http://lh6.ggpht.com/_JW7gLMzR6nE/ShGKlPN03OI/AAAAAAAAAaU/zRB6BZAb9Q8/Module_Dependency_Example_thumb%5B3%5D.jpg?imgmax=800" width="394" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Point is defined as follows:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;struct&lt;/span&gt; Point&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; X;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; Y;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;In the dependent module, I’ve defined a class called “Consumer” and created a constructor that references the Point struct:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Consumer&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; Consumer()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; point = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Point&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;             X = 1,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;             Y = 5&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;         };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Let’s examine this constructor in IL:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; .method public hidebysig specialname rtspecialname instance void .ctor() cil managed&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;     .maxstack 2&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt;     .locals init (&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt;         [0] valuetype [DependentModule]Geometry.Point point,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;         [1] valuetype [DependentModule]Geometry.Point &amp;lt;&amp;gt;g__initLocal0,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;         [2] valuetype [DependentModule]DependentModule.Point CS$0$0000)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;     L_0000: ldarg.0 &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;     L_0001: call instance void [mscorlib]System.Object::.ctor()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;     L_0006: nop &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt;     L_0007: nop &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt;     L_0008: ldloca.s CS$0$0000&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum13" style="color: #606060"&gt;  13:&lt;/span&gt;     L_000a: initobj [ExampleModule]DependentModule.Point&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum14" style="color: #606060"&gt;  14:&lt;/span&gt;     L_0010: ldloc.2 &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum15" style="color: #606060"&gt;  15:&lt;/span&gt;     L_0011: stloc.1 &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum16" style="color: #606060"&gt;  16:&lt;/span&gt;     L_0012: ldloca.s &amp;lt;&amp;gt;g__initLocal0&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum17" style="color: #606060"&gt;  17:&lt;/span&gt;     L_0014: ldc.i4.1 &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum18" style="color: #606060"&gt;  18:&lt;/span&gt;     L_0015: stfld int32 [ExampleModule]DependentModule.Point::X&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum19" style="color: #606060"&gt;  19:&lt;/span&gt;     L_001a: ldloca.s &amp;lt;&amp;gt;g__initLocal0&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum20" style="color: #606060"&gt;  20:&lt;/span&gt;     L_001c: ldc.i4.5 &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum21" style="color: #606060"&gt;  21:&lt;/span&gt;     L_001d: stfld int32 [ExampleModule]DependentModule.Point::Y&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum22" style="color: #606060"&gt;  22:&lt;/span&gt;     L_0022: ldloc.1 &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum23" style="color: #606060"&gt;  23:&lt;/span&gt;     L_0023: stloc.0 &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum24" style="color: #606060"&gt;  24:&lt;/span&gt;     L_0024: nop &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum25" style="color: #606060"&gt;  25:&lt;/span&gt;     L_0025: ret &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum26" style="color: #606060"&gt;  26:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Pay attention to lines 5 through 7; the “valuetype” instruction declares an instance variable as a value type.&amp;#160; This is important, because it means that the memory that the variable “point” occupies will be passed by value, not by reference.&amp;#160; Also notice line 13; this call’s the Point struct’s constructor.&lt;/p&gt;

&lt;p&gt;If the Point struct changes to a class, the IL in lines 5 through 7 will throw an exception, because classes can’t be declared as value types.&amp;#160; If we change, the Point struct to a class and recompile the Geometry and dependent modules, the constructor’s init block looks like this:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   4:&lt;/span&gt; .locals init (&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   5:&lt;/span&gt;     [0] class [ExampleModule]DependentModule.Point point,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   6:&lt;/span&gt;     [1] class [ExampleModule]DependentModule.Point &amp;lt;&amp;gt;g__initLocal0)&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Notice how the point variable is now being defined with the “class” instruction, telling the native-compiler to treat this variable as a reference type.&amp;#160; Also, the call to initialize the variable has changed:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   13:&lt;/span&gt; L_0008: newobj instance void [DependentModule]Geometry.Point::.ctor()&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Instead of using the “initobj” instruction, the “newobj” instruction is being used.&lt;/p&gt;

&lt;p&gt;The impact of this nuance is very small, because everybody is either using a continuous-integration server to build their solutions (I hope).&amp;#160; However, when you’re attempting to perform local changes on your development box this problem can manifest itself.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3406666181435971572-1275784818630954571?l=blog.michaelbrennan.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=4P1ONy-gj_M:o0OmUxC7vuU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=4P1ONy-gj_M:o0OmUxC7vuU:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=4P1ONy-gj_M:o0OmUxC7vuU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?i=4P1ONy-gj_M:o0OmUxC7vuU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=4P1ONy-gj_M:o0OmUxC7vuU:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MichaelBrennan/~4/4P1ONy-gj_M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.michaelbrennan.net/feeds/1275784818630954571/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.michaelbrennan.net/2009/05/what-happens-when-you-change-struct-to.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/1275784818630954571?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/1275784818630954571?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MichaelBrennan/~3/4P1ONy-gj_M/what-happens-when-you-change-struct-to.html" title="What happens when you change a struct to a class in .NET if you don’t recompile the type’s dependencies?" /><author><name>Michael Brennan</name><uri>http://www.blogger.com/profile/09351708784127332440</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/_JW7gLMzR6nE/SvxkKuJiIkI/AAAAAAAAAgc/xXHC5leUnYI/S220/me4_left.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/_JW7gLMzR6nE/ShGKlPN03OI/AAAAAAAAAaU/zRB6BZAb9Q8/s72-c/Module_Dependency_Example_thumb%5B3%5D.jpg?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://blog.michaelbrennan.net/2009/05/what-happens-when-you-change-struct-to.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUEHQ3o-eip7ImA9WxJRFks.&quot;"><id>tag:blogger.com,1999:blog-3406666181435971572.post-5750429124287260800</id><published>2009-03-01T10:21:00.000-06:00</published><updated>2009-05-18T11:20:32.452-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-18T11:20:32.452-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gotchas" /><category scheme="http://www.blogger.com/atom/ns#" term="c#" /><title>The Major Consequences of Using the C# “as” keyword</title><content type="html">&lt;p&gt;I was recently trying to create my own &amp;quot;CaseInsensitiveString&amp;quot; class to behave as if character case did not matter in terms of comparison; this is easy enough, or at least it sounds like it is.&lt;/p&gt;  &lt;p&gt;The first thing I did was override the Equals method to allow for case-insensitive comparison; easy enough. Next I added operator == and operator != for easier comparison syntax; easy enough.&amp;#160; I also wanted to make my class be assignable from a string, and have it be implicitly castable to a string; easy enough, just provide an implicit operator string(MyClass) and an implicit operator MyClass(string).&amp;#160; After righting some quick sanity unit-tests, a problem arose:&amp;#160; all of these assertions work in this unit test:&lt;/p&gt;  &lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;   &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; caseInsensitiveString = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; CaseInsensitiveString(&lt;span style="color: #006080"&gt;&amp;quot;Test String&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; @&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; = caseInsensitiveString;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt; Assert.IsTrue(caseInsensitiveString.Equals(@&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt; Assert.IsTrue(caseInsensitiveString == @&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt; Assert.IsTrue(@&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Equals(caseInsensitiveString));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt; Assert.IsTrue(@&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; == caseInsensitiveString);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;However, line 7 will not work.&amp;#160; Why?&lt;/p&gt;

&lt;p&gt;After a little research, I found out that nUnit's Assert.IsTrue method is invoking the following version of System.String.Equals:&lt;/p&gt;

&lt;div style="font-size: 10pt; background: white; color: black; font-family: lucida console"&gt;
  &lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
    &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;
      &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; Equals(System.Object obj);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;

&lt;p&gt;Microsoft's implementation of this code is as follows: &lt;/p&gt;

&lt;div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; background-color: #f4f4f4; text-align: left"&gt;
  &lt;div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum1" style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; Equals(System.Object obj)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum2" style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum3" style="color: #606060"&gt;   3:&lt;/span&gt;     String str = obj &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; String;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum4" style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (str == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum5" style="color: #606060"&gt;   5:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum6" style="color: #606060"&gt;   6:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// exception will be thrown later for null this&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum7" style="color: #606060"&gt;   7:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;this&lt;/span&gt; != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum8" style="color: #606060"&gt;   8:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum9" style="color: #606060"&gt;   9:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum10" style="color: #606060"&gt;  10:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum11" style="color: #606060"&gt;  11:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; EqualsHelper(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, str);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"&gt;&lt;span id="lnum12" style="color: #606060"&gt;  12:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;

&lt;p&gt;Do you see the problem yet?&amp;#160; The &amp;quot;as&amp;quot; keyword, for whatever reason, does not invoke any casting operators!&amp;#160; I find it strange that an explicit cast would work in this instance, or even an implicit cast, but not the &amp;quot;as&amp;quot; keyword.&lt;/p&gt;

&lt;p&gt;The moral of the story is if you are using implicit type conversion operators, use the &amp;quot;as&amp;quot; keyword only if you only want the object in question to be explicitly casted to the type you provide.&amp;#160; The “as” keyword works fine with inheritance chains (as well as the “is” keyword).&amp;#160; However, in implicit type conversion operators it will not allow other objects to cast to the target. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3406666181435971572-5750429124287260800?l=blog.michaelbrennan.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=Qvvi0vOTpQc:oqil2IfLKkc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=Qvvi0vOTpQc:oqil2IfLKkc:63t7Ie-LG7Y"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=63t7Ie-LG7Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=Qvvi0vOTpQc:oqil2IfLKkc:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?i=Qvvi0vOTpQc:oqil2IfLKkc:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/MichaelBrennan?a=Qvvi0vOTpQc:oqil2IfLKkc:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/MichaelBrennan?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/MichaelBrennan/~4/Qvvi0vOTpQc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.michaelbrennan.net/feeds/5750429124287260800/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.michaelbrennan.net/2009/05/major-consequences-of-using-c-as.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/5750429124287260800?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3406666181435971572/posts/default/5750429124287260800?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MichaelBrennan/~3/Qvvi0vOTpQc/major-consequences-of-using-c-as.html" title="The Major Consequences of Using the C# “as” keyword" /><author><name>Michael Brennan</name><uri>http://www.blogger.com/profile/09351708784127332440</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/_JW7gLMzR6nE/SvxkKuJiIkI/AAAAAAAAAgc/xXHC5leUnYI/S220/me4_left.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.michaelbrennan.net/2009/05/major-consequences-of-using-c-as.html</feedburner:origLink></entry></feed>

