<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://commons.oreilly.com/wiki/skins/common/feed.css?97"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;action=history&amp;feed=atom</id>
		<title>Code in the Language of the Domain - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;action=history&amp;feed=atom"/>
		<link rel="alternate" type="text/html" href="http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;action=history"/>
		<updated>2013-06-19T23:20:27Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.11.0</generator>

	<entry>
		<id>http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24963&amp;oldid=prev</id>
		<title>Kevlin at 23:08, 19 July 2009</title>
		<link rel="alternate" type="text/html" href="http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24963&amp;oldid=prev"/>
				<updated>2009-07-19T23:08:54Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 23:08, 19 July 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 7:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 7:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; Map&amp;lt;int, Map&amp;lt;int, int&amp;gt;&amp;gt; portfolioIdsByTraderId;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; Map&amp;lt;int, Map&amp;lt;int, int&amp;gt;&amp;gt; portfolioIdsByTraderId;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Gradually you realise it might be something to do with whether a trader has access to a particular portfolio. And of course you will find the same &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;map &lt;/del&gt;lookup &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;code &lt;/del&gt;fragment &amp;amp;mdash; or more likely a similar-but-subtly-different code fragment &amp;amp;mdash; whenever something cares whether a trader has access to a particular portfolio.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Gradually you realise it might be something to do with whether a trader has access to a particular portfolio. And of course you will find the same lookup fragment &amp;amp;mdash; or more likely a similar-but-subtly-different code fragment &amp;amp;mdash; whenever something cares whether a trader has access to a particular portfolio.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In the other codebase you come across this:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In the other codebase you come across this:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; if (trader.canView(portfolio)) {...}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; if (trader.canView(portfolio)) {...}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;No head scratching. You don't need to know how a trader knows. Perhaps there is one of these maps-of-maps tucked away somewhere inside. But that's the &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Trader&lt;/del&gt;'s business, not yours.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;No head scratching. You don't need to know how a trader knows. Perhaps there is one of these maps-of-maps tucked away somewhere inside. But that's the &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;trader&amp;lt;/code&amp;gt;&lt;/ins&gt;'s business, not yours.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now which of those codebases would you rather be working in?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now which of those codebases would you rather be working in?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Once upon a time we only had very basic data structures: bits and bytes and characters (really just bytes but we would pretend they were letters and punctuation). Decimals were a bit tricky because our base 10 numbers don't work very well in binary, so we had several sizes of floating point types. Then came arrays and strings &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;amp;mdash; which were &lt;/del&gt;just different arrays. Then we had stacks and queues and hashes and linked lists and skip lists and lots of other exciting data structures ''that don't exist in the real world''. &amp;quot;Computer science&amp;quot; was about spending lots of effort mapping the real world into our restrictive data structures. The real gurus could even remember how they had done it.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Once upon a time we only had very basic data structures: bits and bytes and characters (really just bytes but we would pretend they were letters and punctuation). Decimals were a bit tricky because our base 10 numbers don't work very well in binary, so we had several sizes of floating&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;-&lt;/ins&gt;point types. Then came arrays and strings &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;(really &lt;/ins&gt;just different arrays&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;)&lt;/ins&gt;. Then we had stacks and queues and hashes and linked lists and skip lists and lots of other exciting data structures ''that don't exist in the real world''. &amp;quot;Computer science&amp;quot; was about spending lots of effort mapping the real world into our restrictive data structures. The real gurus could even remember how they had done it.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Then we got user-defined types! OK, this isn't news, but it does change the game somewhat. If your domain contains concepts like traders and portfolios, you can model them with types called, say, &amp;lt;code&amp;gt;Trader&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Portfolio&amp;lt;/code&amp;gt;. But, more importantly than this, you can model ''relationships between them'' using domain terms too. &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;(Note that this isn't exclusive to the object-oriented folks. It applies to functional languages too.)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Then we got user-defined types! OK, this isn't news, but it does change the game somewhat. If your domain contains concepts like traders and portfolios, you can model them with types called, say, &amp;lt;code&amp;gt;Trader&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Portfolio&amp;lt;/code&amp;gt;. But, more importantly than this, you can model ''relationships between them'' using domain terms too.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you don't code using domain terms you are creating a tacit (read: secret) understanding that ''this'' &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over here means the way to identify a trader, whereas that &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over ''there'' means the way to identify a portfolio. (Best not to get them mixed up!) And if you represent a business concept (&amp;quot;Some traders are not allowed to view some portfolios &amp;amp;mdash; it's illegal&amp;quot;) with an algorithmic snippet, say an existence relationship in a map of keys, you aren't doing the audit and compliance guys any favors.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you don't code using domain terms you are creating a tacit (read: secret) understanding that ''this'' &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over here means the way to identify a trader, whereas that &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over ''there'' means the way to identify a portfolio. (Best not to get them mixed up!) And if you represent a business concept (&amp;quot;Some traders are not allowed to view some portfolios &amp;amp;mdash; it's illegal&amp;quot;) with an algorithmic snippet, say an existence relationship in a map of keys, you aren't doing the audit and compliance guys any favors.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The next programmer along might not be in on the secret, so why not make it explicit? Using a key as a lookup to another key that performs an existence check is not terribly obvious. How is someone supposed to intuit &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;that &lt;/del&gt;that's where the &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Chinese Walls &lt;/del&gt;business rules are implemented?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The next programmer along might not be in on the secret, so why not make it explicit? Using a key as a lookup to another key that performs an existence check is not terribly obvious. How is someone supposed to intuit that's where the business rules &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;preventing conflict of interest &lt;/ins&gt;are implemented?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Making domain concepts explicit in your code means other programmers can gather the ''intent'' of the code much more easily than by trying to retrofit an algorithm into what they understand about a domain. It also means that when the domain model evolves &amp;amp;mdash; which it will as your understanding of the domain grows &amp;amp;mdash; you are in a good position to evolve the code. Coupled with good encapsulation, the chances are good that the rule will &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;only &lt;/del&gt;exist in one place, and that you can change it without any of the dependent code being any the wiser.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Making domain concepts explicit in your code means other programmers can gather the ''intent'' of the code much more easily than by trying to retrofit an algorithm into what they understand about a domain. It also means that when the domain model evolves &amp;amp;mdash; which it will as your understanding of the domain grows &amp;amp;mdash; you are in a good position to evolve the code. Coupled with good encapsulation, the chances are good that the rule will exist in &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;only &lt;/ins&gt;one place, and that you can change it without any of the dependent code being any the wiser.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The programmer who comes along a few months later to work on the code will thank you. The programmer who comes along a few months later might be you.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The programmer who comes along a few months later to work on the code will thank you. The programmer who comes along a few months later might be you.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:24959:newid:24963 --&gt;
&lt;/table&gt;</summary>
		<author><name>Kevlin</name></author>	</entry>

	<entry>
		<id>http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24959&amp;oldid=prev</id>
		<title>DanNorth at 20:55, 19 July 2009</title>
		<link rel="alternate" type="text/html" href="http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24959&amp;oldid=prev"/>
				<updated>2009-07-19T20:55:26Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 20:55, 19 July 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Once upon a time we only had very basic data structures: bits and bytes and characters (really just bytes but we would pretend they were letters and punctuation). Decimals were a bit tricky because our base 10 numbers don't work very well in binary, so we had several sizes of floating point types. Then came arrays and strings &amp;amp;mdash; which were just different arrays. Then we had stacks and queues and hashes and linked lists and skip lists and lots of other exciting data structures ''that don't exist in the real world''. &amp;quot;Computer science&amp;quot; was about spending lots of effort mapping the real world into our restrictive data structures. The real gurus could even remember how they had done it.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Once upon a time we only had very basic data structures: bits and bytes and characters (really just bytes but we would pretend they were letters and punctuation). Decimals were a bit tricky because our base 10 numbers don't work very well in binary, so we had several sizes of floating point types. Then came arrays and strings &amp;amp;mdash; which were just different arrays. Then we had stacks and queues and hashes and linked lists and skip lists and lots of other exciting data structures ''that don't exist in the real world''. &amp;quot;Computer science&amp;quot; was about spending lots of effort mapping the real world into our restrictive data structures. The real gurus could even remember how they had done it.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Then we got user-defined types! OK, this isn't news, but it does change the game somewhat. If your domain contains concepts like traders and portfolios, you can model them with types called, say, &amp;lt;code&amp;gt;Trader&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Portfolio&amp;lt;/code&amp;gt;. But, more importantly than this, you can model ''relationships between them'' using domain terms too. (Note that this isn't exclusive to the object-oriented folks. It applies to functional languages &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;with types &lt;/del&gt;too.)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Then we got user-defined types! OK, this isn't news, but it does change the game somewhat. If your domain contains concepts like traders and portfolios, you can model them with types called, say, &amp;lt;code&amp;gt;Trader&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Portfolio&amp;lt;/code&amp;gt;. But, more importantly than this, you can model ''relationships between them'' using domain terms too. (Note that this isn't exclusive to the object-oriented folks. It applies to functional languages too.)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;compose your types &lt;/del&gt;using &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;the built-in, general-purpose types, &lt;/del&gt;you are creating a tacit (read: secret) understanding that ''this'' &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over here means the way to identify a trader, whereas that &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over ''there'' means the way to identify a portfolio. (Best not to get them mixed up!) And if you represent a business concept (&amp;quot;Some traders are not allowed to view some portfolios &amp;amp;mdash; it's illegal&amp;quot;) with an algorithmic snippet, say an existence relationship in a map of keys, you aren't doing the audit and compliance guys any favors.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;don't code &lt;/ins&gt;using &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;domain terms &lt;/ins&gt;you are creating a tacit (read: secret) understanding that ''this'' &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over here means the way to identify a trader, whereas that &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over ''there'' means the way to identify a portfolio. (Best not to get them mixed up!) And if you represent a business concept (&amp;quot;Some traders are not allowed to view some portfolios &amp;amp;mdash; it's illegal&amp;quot;) with an algorithmic snippet, say an existence relationship in a map of keys, you aren't doing the audit and compliance guys any favors.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The next programmer along might not be in on the secret, so why not make it explicit? Using a key as a lookup to another key that performs an existence check is not terribly obvious. How is someone supposed to intuit that that's where the Chinese Walls business rules are implemented?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The next programmer along might not be in on the secret, so why not make it explicit? Using a key as a lookup to another key that performs an existence check is not terribly obvious. How is someone supposed to intuit that that's where the Chinese Walls business rules are implemented?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:24958:newid:24959 --&gt;
&lt;/table&gt;</summary>
		<author><name>DanNorth</name></author>	</entry>

	<entry>
		<id>http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24958&amp;oldid=prev</id>
		<title>DanNorth at 20:27, 19 July 2009</title>
		<link rel="alternate" type="text/html" href="http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24958&amp;oldid=prev"/>
				<updated>2009-07-19T20:27:34Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 20:27, 19 July 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Once upon a time we only had very basic data structures: bits and bytes and characters (really just bytes but we would pretend they were letters and punctuation). Decimals were a bit tricky because our base 10 numbers don't work very well in binary, so we had several sizes of floating point types. Then came arrays and strings &amp;amp;mdash; which were just different arrays. Then we had stacks and queues and hashes and linked lists and skip lists and lots of other exciting data structures ''that don't exist in the real world''. &amp;quot;Computer science&amp;quot; was about spending lots of effort mapping the real world into our restrictive data structures. The real gurus could even remember how they had done it.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Once upon a time we only had very basic data structures: bits and bytes and characters (really just bytes but we would pretend they were letters and punctuation). Decimals were a bit tricky because our base 10 numbers don't work very well in binary, so we had several sizes of floating point types. Then came arrays and strings &amp;amp;mdash; which were just different arrays. Then we had stacks and queues and hashes and linked lists and skip lists and lots of other exciting data structures ''that don't exist in the real world''. &amp;quot;Computer science&amp;quot; was about spending lots of effort mapping the real world into our restrictive data structures. The real gurus could even remember how they had done it.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Then we got &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;objects&lt;/del&gt;! OK, this isn't news, but it does change the game somewhat. If your domain contains concepts like traders and portfolios, you can model them with &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;classes &lt;/del&gt;called, say, &amp;lt;code&amp;gt;Trader&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Portfolio&amp;lt;/code&amp;gt;. But, more importantly than this, you can model ''relationships between them'' using domain terms too.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Then we got &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;user-defined types&lt;/ins&gt;! OK, this isn't news, but it does change the game somewhat. If your domain contains concepts like traders and portfolios, you can model them with &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;types &lt;/ins&gt;called, say, &amp;lt;code&amp;gt;Trader&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Portfolio&amp;lt;/code&amp;gt;. But, more importantly than this, you can model ''relationships between them'' using domain terms too. &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;(Note that this isn't exclusive to the object-oriented folks. It applies to functional languages with types too.)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you compose your &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;objects &lt;/del&gt;using the built-in, general-purpose types &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;amp;mdash; ints, strings, chars&lt;/del&gt;, &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;lists and maps &amp;amp;mdash; then &lt;/del&gt;you are creating a tacit (read: secret) understanding that ''this'' &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over here means the way to identify a trader, whereas that &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over ''there'' means the way to identify a portfolio. (Best not to get them mixed up!) And if you represent a business concept (&amp;quot;Some traders are not allowed to view some portfolios &amp;amp;mdash; it's illegal&amp;quot;) with an algorithmic snippet, say an existence relationship in a map of keys, you aren't doing the audit and compliance guys any favors.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you compose your &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;types &lt;/ins&gt;using the built-in, general-purpose types, you are creating a tacit (read: secret) understanding that ''this'' &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over here means the way to identify a trader, whereas that &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over ''there'' means the way to identify a portfolio. (Best not to get them mixed up!) And if you represent a business concept (&amp;quot;Some traders are not allowed to view some portfolios &amp;amp;mdash; it's illegal&amp;quot;) with an algorithmic snippet, say an existence relationship in a map of keys, you aren't doing the audit and compliance guys any favors.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The next programmer along might not be in on the secret, so why not make it explicit? Using a key as a lookup to another key that performs an existence check is not terribly obvious. How is someone supposed to intuit that that's where the Chinese Walls business rules are implemented?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The next programmer along might not be in on the secret, so why not make it explicit? Using a key as a lookup to another key that performs an existence check is not terribly obvious. How is someone supposed to intuit that that's where the Chinese Walls business rules are implemented?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:24957:newid:24958 --&gt;
&lt;/table&gt;</summary>
		<author><name>DanNorth</name></author>	</entry>

	<entry>
		<id>http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24957&amp;oldid=prev</id>
		<title>DanNorth at 20:16, 19 July 2009</title>
		<link rel="alternate" type="text/html" href="http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24957&amp;oldid=prev"/>
				<updated>2009-07-19T20:16:39Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 20:16, 19 July 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 17:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 17:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now which of those codebases would you rather be working in?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now which of those codebases would you rather be working in?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Once upon a time we only had very basic data structures: bits and bytes and characters (really just bytes but we would pretend they were letters and punctuation). &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Things like decimal numbers &lt;/del&gt;were a bit tricky because our base 10 &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;number system doesn&lt;/del&gt;'t work very well in binary, so we had several sizes of floating point types. Then came arrays and strings &amp;amp;mdash; which were just different arrays. Then we had stacks and queues and &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;lists. And array lists &lt;/del&gt;and linked lists and skip lists&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;. And maps and sets and iterators &lt;/del&gt;and lots of other exciting data structures ''that don't exist in the real world''. &amp;quot;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Software engineering&lt;/del&gt;&amp;quot; was about spending lots of effort mapping the real world into our restrictive data structures. The real gurus could even remember how they had done it.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Once upon a time we only had very basic data structures: bits and bytes and characters (really just bytes but we would pretend they were letters and punctuation). &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Decimals &lt;/ins&gt;were a bit tricky because our base 10 &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;numbers don&lt;/ins&gt;'t work very well in binary, so we had several sizes of floating point types. Then came arrays and strings &amp;amp;mdash; which were just different arrays. Then we had stacks and queues and &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;hashes &lt;/ins&gt;and linked lists and skip lists and lots of other exciting data structures ''that don't exist in the real world''. &amp;quot;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Computer science&lt;/ins&gt;&amp;quot; was about spending lots of effort mapping the real world into our restrictive data structures. The real gurus could even remember how they had done it.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Then we got objects! OK, this isn't news, but it does change the game somewhat. If your domain contains concepts like traders and portfolios, you can model them with classes called, say, &amp;lt;code&amp;gt;Trader&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Portfolio&amp;lt;/code&amp;gt;. But, more importantly than this, you can model ''relationships between them'' using domain terms too.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Then we got objects! OK, this isn't news, but it does change the game somewhat. If your domain contains concepts like traders and portfolios, you can model them with classes called, say, &amp;lt;code&amp;gt;Trader&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Portfolio&amp;lt;/code&amp;gt;. But, more importantly than this, you can model ''relationships between them'' using domain terms too.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you compose your objects using the built-in, general-purpose types &amp;amp;mdash; ints, strings, chars, lists and maps &amp;amp;mdash; then you are creating a tacit (read: secret) understanding that ''this'' &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over here means the way to identify a trader, whereas that &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over ''there'' means the way to identify a portfolio. (Best not to get them mixed up!) And if you represent a business concept (&amp;quot;Some traders are not allowed to view some portfolios &amp;amp;mdash; it's illegal&amp;quot;) with an algorithmic snippet, say an existence relationship in a map of keys, you aren't doing the audit and compliance guys any favors.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you compose your objects using the built-in, general-purpose types &amp;amp;mdash; ints, strings, chars, lists and maps &amp;amp;mdash; then you are creating a tacit (read: secret) understanding that ''this'' &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over here means the way to identify a trader, whereas that &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over ''there'' means the way to identify a portfolio. (Best not to get them mixed up!) And if you represent a business concept (&amp;quot;Some traders are not allowed to view some portfolios &amp;amp;mdash; it's illegal&amp;quot;) with an algorithmic snippet, say an existence relationship in a map of keys, you aren't doing the audit and compliance guys any favors.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;thing is, the &lt;/del&gt;next programmer along might not be in on the secret, so why not make it explicit? Using a key as a lookup &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;into a map of maps &lt;/del&gt;to &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;then use &lt;/del&gt;another key &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;to perform &lt;/del&gt;an existence check is not terribly obvious. How is someone supposed to intuit that that's where the Chinese Walls business rules are implemented?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The next programmer along might not be in on the secret, so why not make it explicit? Using a key as a lookup to another key &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;that performs &lt;/ins&gt;an existence check is not terribly obvious. How is someone supposed to intuit that that's where the Chinese Walls business rules are implemented?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Making domain concepts explicit in your code means other programmers can gather the ''intent'' of the code much more easily than by trying to retrofit an algorithm into what they understand about a domain. It also means that when the domain model evolves &amp;amp;mdash; which it will as your understanding of the domain grows &amp;amp;mdash; you are in a good position to evolve the code. Coupled with good encapsulation, the chances are good that the rule will only exist in one place, and that you can change it without any of the dependent code being any the wiser.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Making domain concepts explicit in your code means other programmers can gather the ''intent'' of the code much more easily than by trying to retrofit an algorithm into what they understand about a domain. It also means that when the domain model evolves &amp;amp;mdash; which it will as your understanding of the domain grows &amp;amp;mdash; you are in a good position to evolve the code. Coupled with good encapsulation, the chances are good that the rule will only exist in one place, and that you can change it without any of the dependent code being any the wiser.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:24756:newid:24957 --&gt;
&lt;/table&gt;</summary>
		<author><name>DanNorth</name></author>	</entry>

	<entry>
		<id>http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24756&amp;oldid=prev</id>
		<title>Kevlin at 19:48, 9 July 2009</title>
		<link rel="alternate" type="text/html" href="http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24756&amp;oldid=prev"/>
				<updated>2009-07-09T19:48:56Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 19:48, 9 July 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 21:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 21:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Then we got objects! OK, this isn't news, but it does change the game somewhat. If your domain contains concepts like traders and portfolios, you can model them with classes called, say, &amp;lt;code&amp;gt;Trader&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Portfolio&amp;lt;/code&amp;gt;. But, more importantly than this, you can model ''relationships between them'' using domain terms too.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Then we got objects! OK, this isn't news, but it does change the game somewhat. If your domain contains concepts like traders and portfolios, you can model them with classes called, say, &amp;lt;code&amp;gt;Trader&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Portfolio&amp;lt;/code&amp;gt;. But, more importantly than this, you can model ''relationships between them'' using domain terms too.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you compose your objects using the built-in general purpose types &amp;amp;mdash; ints, strings, chars, lists and maps &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;- &lt;/del&gt;then you are creating a tacit (read: secret) understanding that ''this'' &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over here means the way to identify a trader, whereas that &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over ''there'' means the way to identify a portfolio. (Best not to get them mixed up!) And if you represent a business concept (&amp;quot;Some traders are not allowed to view some portfolios &amp;amp;mdash; it's illegal&amp;quot;) with an algorithmic snippet, say an existence relationship in a map of keys, you aren't doing the audit and compliance guys any favors.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you compose your objects using the built-in&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;, &lt;/ins&gt;general&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;-&lt;/ins&gt;purpose types &amp;amp;mdash; ints, strings, chars, lists and maps &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;amp;mdash; &lt;/ins&gt;then you are creating a tacit (read: secret) understanding that ''this'' &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over here means the way to identify a trader, whereas that &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; over ''there'' means the way to identify a portfolio. (Best not to get them mixed up!) And if you represent a business concept (&amp;quot;Some traders are not allowed to view some portfolios &amp;amp;mdash; it's illegal&amp;quot;) with an algorithmic snippet, say an existence relationship in a map of keys, you aren't doing the audit and compliance guys any favors.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The thing is, the next programmer along might not be in on the secret, so why not make it explicit? Using a key as a lookup into a map of maps to then use another key to perform an existence check is not terribly obvious. How is someone supposed to intuit that that's where the Chinese Walls business rules are implemented?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The thing is, the next programmer along might not be in on the secret, so why not make it explicit? Using a key as a lookup into a map of maps to then use another key to perform an existence check is not terribly obvious. How is someone supposed to intuit that that's where the Chinese Walls business rules are implemented?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:24751:newid:24756 --&gt;
&lt;/table&gt;</summary>
		<author><name>Kevlin</name></author>	</entry>

	<entry>
		<id>http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24751&amp;oldid=prev</id>
		<title>Kevlin: Code in the language of the domain moved to Code in the Language of the Domain</title>
		<link rel="alternate" type="text/html" href="http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24751&amp;oldid=prev"/>
				<updated>2009-07-09T19:22:49Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;a href=&quot;/wiki/index.php/Code_in_the_language_of_the_domain&quot; title=&quot;Code in the language of the domain&quot;&gt;Code in the language of the domain&lt;/a&gt; moved to &lt;a href=&quot;/wiki/index.php/Code_in_the_Language_of_the_Domain&quot; title=&quot;Code in the Language of the Domain&quot;&gt;Code in the Language of the Domain&lt;/a&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 19:22, 9 July 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/table&gt;</summary>
		<author><name>Kevlin</name></author>	</entry>

	<entry>
		<id>http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24750&amp;oldid=prev</id>
		<title>Kevlin at 19:22, 9 July 2009</title>
		<link rel="alternate" type="text/html" href="http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24750&amp;oldid=prev"/>
				<updated>2009-07-09T19:22:31Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 19:22, 9 July 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Picture two codebases. In one you come across:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Picture two codebases. In one you come across:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; if (portfolioIdsByTraderId.get(trader.getId()).containsKey(portfolio.getId())) {...}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; if (portfolioIdsByTraderId.get(trader.getId())&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;   &lt;/del&gt;.containsKey(portfolio.getId())) {...}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;and you &lt;/del&gt;scratch your head, wondering what this code might be for. It seems to be getting an &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;id &lt;/del&gt;from a trader object, using that to get a map out of a, well, map-of-maps apparently, and then seeing if another &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;id &lt;/del&gt;from a portfolio object exists in the inner map. You scratch your head some more. You look for the declaration of &amp;lt;code&amp;gt;portfolioIdsByTraderId&amp;lt;/code&amp;gt; and discover this:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;You &lt;/ins&gt;scratch your head, wondering what this code might be for. It seems to be getting an &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;ID &lt;/ins&gt;from a trader object, using that to get a map out of a, well, map-of-maps apparently, and then seeing if another &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;ID &lt;/ins&gt;from a portfolio object exists in the inner map. You scratch your head some more. You look for the declaration of &amp;lt;code&amp;gt;portfolioIdsByTraderId&amp;lt;/code&amp;gt; and discover this:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;code&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; Map&amp;lt;int, Map&amp;lt;int, int&amp;gt;&amp;gt; portfolioIdsByTraderId;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; Map&amp;lt;int, Map&amp;lt;int, int&amp;gt;&amp;gt; portfolioIdsByTraderId;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/code&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Gradually you realise it might be something to do with whether a trader has access to a particular portfolio. And of course you will find the same map lookup code fragment &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;- &lt;/del&gt;or more likely a similar-but-subtly-different code fragment &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;- &lt;/del&gt;whenever something cares whether a trader has access to a particular portfolio.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Gradually you realise it might be something to do with whether a trader has access to a particular portfolio. And of course you will find the same map lookup code fragment &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;amp;mdash; &lt;/ins&gt;or more likely a similar-but-subtly-different code fragment &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;amp;mdash; &lt;/ins&gt;whenever something cares whether a trader has access to a particular portfolio.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In the other codebase you come across this:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In the other codebase you come across this:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/del&gt;if (trader.canView(portfolio)) {...}&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; &lt;/ins&gt;if (trader.canView(portfolio)) {...}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;You don't need to know how a trader knows. Perhaps there is one of these maps-of-maps tucked away somewhere inside&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;, but &lt;/del&gt;that's the Trader's business, not yours.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;No head scratching. &lt;/ins&gt;You don't need to know how a trader knows. Perhaps there is one of these maps-of-maps tucked away somewhere inside&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;. But &lt;/ins&gt;that's the Trader's business, not yours.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now which of those codebases would you rather be working in?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now which of those codebases would you rather be working in?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Once upon a time we only had very basic data structures: bits and bytes and characters (really just bytes but we would pretend they were letters and punctuation). Things like decimal numbers were a bit tricky because our base 10 number system doesn't work very well in binary, so we had several sizes of floating point types. Then came arrays and strings &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;- &lt;/del&gt;which were just different arrays. Then we had stacks and queues and lists. And array lists and linked lists and skip lists. And maps and sets and iterators and lots of other exciting data structures ''that don't exist in the real world''. &amp;quot;Software engineering&amp;quot; was about spending lots of effort mapping the real world into our restrictive data structures. The real gurus could even remember how they had done it.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Once upon a time we only had very basic data structures: bits and bytes and characters (really just bytes but we would pretend they were letters and punctuation). Things like decimal numbers were a bit tricky because our base 10 number system doesn't work very well in binary, so we had several sizes of floating point types. Then came arrays and strings &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;amp;mdash; &lt;/ins&gt;which were just different arrays. Then we had stacks and queues and lists. And array lists and linked lists and skip lists. And maps and sets and iterators and lots of other exciting data structures ''that don't exist in the real world''. &amp;quot;Software engineering&amp;quot; was about spending lots of effort mapping the real world into our restrictive data structures. The real gurus could even remember how they had done it.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Then we got objects! &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Ok &lt;/del&gt;this isn't news, but it does change the game somewhat. If your domain contains concepts like &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Traders &lt;/del&gt;and &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Portfolios&lt;/del&gt;, you can model them with classes called, say, Trader and Portfolio. But more importantly than this, you can model ''relationships between them'' using domain terms too.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Then we got objects! &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;OK, &lt;/ins&gt;this isn't news, but it does change the game somewhat. If your domain contains concepts like &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;traders &lt;/ins&gt;and &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;portfolios&lt;/ins&gt;, you can model them with classes called, say, &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;Trader&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;and &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;Portfolio&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt;&lt;/ins&gt;. But&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;, &lt;/ins&gt;more importantly than this, you can model ''relationships between them'' using domain terms too.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you compose your objects using the built-in general purpose types &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;- &lt;/del&gt;ints, strings, chars, lists and maps - then you are creating a tacit (read: secret) understanding that ''this'' int over here means the way to identify a trader, whereas &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;this &lt;/del&gt;int over ''&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;here&lt;/del&gt;'' means the way to identify a portfolio. (Best not to get them mixed up!) And if you represent a business concept (&amp;quot;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;some &lt;/del&gt;traders are not allowed to view some portfolios &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;- &lt;/del&gt;it's illegal&amp;quot;) with an algorithmic snippet, say an existence relationship in a map of keys, you aren't doing the audit and compliance guys any &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;favours&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you compose your objects using the built-in general purpose types &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;amp;mdash; &lt;/ins&gt;ints, strings, chars, lists and maps - then you are creating a tacit (read: secret) understanding that ''this'' &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;code&amp;gt;&lt;/ins&gt;int&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;over here means the way to identify a trader, whereas &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;that &amp;lt;code&amp;gt;&lt;/ins&gt;int&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/code&amp;gt; &lt;/ins&gt;over ''&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;there&lt;/ins&gt;'' means the way to identify a portfolio. (Best not to get them mixed up!) And if you represent a business concept (&amp;quot;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;Some &lt;/ins&gt;traders are not allowed to view some portfolios &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;amp;mdash; &lt;/ins&gt;it's illegal&amp;quot;) with an algorithmic snippet, say an existence relationship in a map of keys, you aren't doing the audit and compliance guys any &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;favors&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The thing is, the next programmer along might not be in on the secret, so why not make it explicit? Using a key as a lookup into a map of maps to then use another key to perform an existence check is not terribly obvious. How is someone supposed to intuit that that's where the Chinese Walls business rules are implemented?&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The thing is, the next programmer along might not be in on the secret, so why not make it explicit? Using a key as a lookup into a map of maps to then use another key to perform an existence check is not terribly obvious. How is someone supposed to intuit that that's where the Chinese Walls business rules are implemented?&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Making domain concepts explicit in your code means other programmers can gather the ''intent'' of the code much more easily than by trying to retrofit an algorithm into what they understand about a domain. It also means that when the domain model evolves &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;- &lt;/del&gt;which it will as your understanding of the domain grows &lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;- &lt;/del&gt;you are in a good position to evolve the code. Coupled with good encapsulation, the chances are good that the rule will only exist in one place, and that you can change it without any of the dependent code being any the wiser.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Making domain concepts explicit in your code means other programmers can gather the ''intent'' of the code much more easily than by trying to retrofit an algorithm into what they understand about a domain. It also means that when the domain model evolves &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;amp;mdash; &lt;/ins&gt;which it will as your understanding of the domain grows &lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;amp;mdash; &lt;/ins&gt;you are in a good position to evolve the code. Coupled with good encapsulation, the chances are good that the rule will only exist in one place, and that you can change it without any of the dependent code being any the wiser.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The programmer who comes along a few months later to work on the code will thank you. The programmer who comes along a few months later might be you.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The programmer who comes along a few months later to work on the code will thank you. The programmer who comes along a few months later might be you.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;By [[Dan North]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This work is licensed under a&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;This work is licensed under a&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wikicontent:diff:version:1.11a:oldid:24708:newid:24750 --&gt;
&lt;/table&gt;</summary>
		<author><name>Kevlin</name></author>	</entry>

	<entry>
		<id>http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24708&amp;oldid=prev</id>
		<title>DanNorth: New page: Picture two codebases. In one you come across:  &lt;code&gt;  if (portfolioIdsByTraderId.get(trader.getId())    .containsKey(portfolio.getId())) {...} &lt;/code&gt;  and you scratch your head, wonderi...</title>
		<link rel="alternate" type="text/html" href="http://commons.oreilly.com/wiki/index.php?title=Code_in_the_Language_of_the_Domain&amp;diff=24708&amp;oldid=prev"/>
				<updated>2009-07-08T16:39:25Z</updated>
		
		<summary type="html">&lt;p&gt;New page: Picture two codebases. In one you come across:  &amp;lt;code&amp;gt;  if (portfolioIdsByTraderId.get(trader.getId())    .containsKey(portfolio.getId())) {...} &amp;lt;/code&amp;gt;  and you scratch your head, wonderi...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Picture two codebases. In one you come across:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 if (portfolioIdsByTraderId.get(trader.getId())&lt;br /&gt;
   .containsKey(portfolio.getId())) {...}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you scratch your head, wondering what this code might be for. It seems to be getting an id from a trader object, using that to get a map out of a, well, map-of-maps apparently, and then seeing if another id from a portfolio object exists in the inner map. You scratch your head some more. You look for the declaration of &amp;lt;code&amp;gt;portfolioIdsByTraderId&amp;lt;/code&amp;gt; and discover this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 Map&amp;lt;int, Map&amp;lt;int, int&amp;gt;&amp;gt; portfolioIdsByTraderId;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gradually you realise it might be something to do with whether a trader has access to a particular portfolio. And of course you will find the same map lookup code fragment - or more likely a similar-but-subtly-different code fragment - whenever something cares whether a trader has access to a particular portfolio.&lt;br /&gt;
&lt;br /&gt;
In the other codebase you come across this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;if (trader.canView(portfolio)) {...}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You don't need to know how a trader knows. Perhaps there is one of these maps-of-maps tucked away somewhere inside, but that's the Trader's business, not yours.&lt;br /&gt;
&lt;br /&gt;
Now which of those codebases would you rather be working in?&lt;br /&gt;
&lt;br /&gt;
Once upon a time we only had very basic data structures: bits and bytes and characters (really just bytes but we would pretend they were letters and punctuation). Things like decimal numbers were a bit tricky because our base 10 number system doesn't work very well in binary, so we had several sizes of floating point types. Then came arrays and strings - which were just different arrays. Then we had stacks and queues and lists. And array lists and linked lists and skip lists. And maps and sets and iterators and lots of other exciting data structures ''that don't exist in the real world''. &amp;quot;Software engineering&amp;quot; was about spending lots of effort mapping the real world into our restrictive data structures. The real gurus could even remember how they had done it.&lt;br /&gt;
&lt;br /&gt;
Then we got objects! Ok this isn't news, but it does change the game somewhat. If your domain contains concepts like Traders and Portfolios, you can model them with classes called, say, Trader and Portfolio. But more importantly than this, you can model ''relationships between them'' using domain terms too.&lt;br /&gt;
&lt;br /&gt;
If you compose your objects using the built-in general purpose types - ints, strings, chars, lists and maps - then you are creating a tacit (read: secret) understanding that ''this'' int over here means the way to identify a trader, whereas this int over ''here'' means the way to identify a portfolio. (Best not to get them mixed up!) And if you represent a business concept (&amp;quot;some traders are not allowed to view some portfolios - it's illegal&amp;quot;) with an algorithmic snippet, say an existence relationship in a map of keys, you aren't doing the audit and compliance guys any favours.&lt;br /&gt;
&lt;br /&gt;
The thing is, the next programmer along might not be in on the secret, so why not make it explicit? Using a key as a lookup into a map of maps to then use another key to perform an existence check is not terribly obvious. How is someone supposed to intuit that that's where the Chinese Walls business rules are implemented?&lt;br /&gt;
&lt;br /&gt;
Making domain concepts explicit in your code means other programmers can gather the ''intent'' of the code much more easily than by trying to retrofit an algorithm into what they understand about a domain. It also means that when the domain model evolves - which it will as your understanding of the domain grows - you are in a good position to evolve the code. Coupled with good encapsulation, the chances are good that the rule will only exist in one place, and that you can change it without any of the dependent code being any the wiser.&lt;br /&gt;
&lt;br /&gt;
The programmer who comes along a few months later to work on the code will thank you. The programmer who comes along a few months later might be you.&lt;br /&gt;
&lt;br /&gt;
This work is licensed under a&lt;br /&gt;
[http://creativecommons.org/licenses/by/3.0/us/ Creative Commons Attribution 3] &lt;br /&gt;
&lt;br /&gt;
Back to [[97 Things Every Programmer Should Know]] home page&lt;/div&gt;</summary>
		<author><name>DanNorth</name></author>	</entry>

	</feed>