<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
<title>My Secret Life as a Spaghetti Coder</title>
<link>http://www.codeodor.com/</link>
<description>Posts about Ruby, Java, Coldfusion, OOAD, TDD, DSLs, and more (some not TLAs!)... </description>
<lastBuildDate>Thu, 02 Jul 2009 07:30:37 -0500</lastBuildDate>
<language>en-us</language>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/codeodor" type="application/rss+xml" /><feedburner:emailServiceId>codeodor</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
<title>Quotables: Who cares, big ideas, and copyists vs. copyright holders</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/NAu3Qujn99c/2924</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2009/7/2/Quotables-Who-cares-big-ideas-and-copyists-vs-copyright-holders/2924</guid>
<pubDate>Thu, 02 Jul 2009 07:30:37 -0500</pubDate>
<description>This is the "my lawn needs more water and my wife disagrees" 
edition of &lt;a href="http://www.codeodor.com/index.cfm/category/Programming%20Quotables/27"&gt;Programming Quotables&lt;/a&gt;.
&lt;br/&gt;&lt;br/&gt; 
If you don't know - I don't like to have too many microposts on this blog 
(&lt;a href="http://twitter.com/codeodor"&gt;I'm on twitter for that&lt;/a&gt;), so I save them up as I run across them, 
and every once in a while I'll post a few of them.  The idea is to post quotes about programming that have 
one or more of the following attributes:
&lt;ol&gt;
&lt;li&gt;I find funny&lt;/li&gt;
&lt;li&gt;I find asinine&lt;/li&gt;
&lt;li&gt;I find insightfully true&lt;/li&gt;
&lt;li&gt;And stand on their own, with little to no comment needed&lt;/li&gt;
&lt;/ol&gt;

It's up to you decide which category they fall in, if you care to. Anyway, here we go:&lt;more&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;blockquote&gt;
"Is it still Scrum if we use a kanban board instead of a burndown?"
&lt;br/&gt;&lt;br/&gt;
"Is it still XP if we don't break things down into tasks but just use stories?"
&lt;br/&gt;&lt;br/&gt;
Who the hell cares???
&lt;/blockquote&gt;
&lt;div align="right"&gt;
Ron Jeffries,  &lt;a href="http://xprogramming.com/blog/needles/my-named-cloud-is-better-than-your-named-cloud.htm"&gt;My Named Cloud is Better Than Your Named Cloud&lt;/a&gt;
&lt;/div&gt;
&lt;br/&gt;
&lt;blockquote&gt;
	If we hope to excite people with the power of programming, we will do it with big ideas, not the placement of periods, spaces, keywords, and braces. We need to find ways so that students can solve problems and write programs by understanding the ideas behind them, using tools that get in the way as little as possible. No junk allowed. That may be through simpler languages, better libraries, or something else that I haven't learned about yet.
&lt;/blockquote&gt;
&lt;div align="right"&gt;
Eugene Wallingford,  &lt;a href="http://www.cs.uni.edu/%7Ewallingf/blog/archives/monthly/2009-04.html#e2009-04-23T20_51_09.htm"&gt;Getting Caught Up In Stupid Details&lt;/a&gt;
&lt;/div&gt;
&lt;br/&gt;
&lt;blockquote&gt;
It's entirely possible that there's a detente to be reached between the copyists and the copyright holders: a set of rules that only try to encompass "culture" and not "industry." But the only way to bring copyists to the table is to stop insisting that all unauthorized copying is theft and a crime and wrong. People who know that copying is simple, good, and beneficial hear that and assume that you're either talking nonsense or that you're talking about someone else. 
&lt;/blockquote&gt;
&lt;div align="right"&gt;
Cory Doctorow,  &lt;a href="http://www.locusmag.com/Features/2008/11/cory-doctorow-why-i-copyfight.html"&gt;Why I Copyfight&lt;/a&gt;
(and &lt;a href="http://www.codeodor.com/index.cfm/2009/6/24/An-Independent-Artists-View-of-Music-Piracy/2911"&gt;the independent artist's point of view&lt;/a&gt;)
&lt;/div&gt;
&lt;br/&gt;&lt;br/&gt;
Your comments, as always, are welcome.
	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2009/7/2/Quotables-Who-cares-big-ideas-and-copyists-vs-copyright-holders/2924#leave_a_comment" title="Go to the page and comments for Quotables: Who cares, big ideas, and copyists vs. copyright holders"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/NAu3Qujn99c" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[Programming]]></category>

<category><![CDATA[Programming Quotables]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2009/7/2/Quotables-Who-cares-big-ideas-and-copyists-vs-copyright-holders/2924</feedburner:origLink></item>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<item>
<title>Ruby LDAP</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/22ZUgJK_944/2922</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2009/6/30/Ruby-LDAP/2922</guid>
<pubDate>Tue, 30 Jun 2009 07:58:59 -0500</pubDate>
<description>&lt;acronym title="Lightweight Directory Access Protocol"&gt;LDAP&lt;/acronym&gt; in Ruby is better than LDAP in C#/.NET. Looking at it, I can't say it's much different minus the cruft from .NET.&lt;more&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;img src="http://www.codeodor.com/images/orly.jpg" alt="Lightweight? Seriously?" title="Lightweight? Seriously?"/&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;em&gt;Experiencing&lt;/em&gt; it while &lt;em&gt;actually writing code&lt;/em&gt;, it's &lt;em&gt;very&lt;/em&gt; different. I can't explain it, except to show it to you and tell you try it.
&lt;br/&gt;&lt;br/&gt;
&lt;a href="http://github.com/innovationfactory/ruby-net-ldap/tree/master"&gt;Ruby LDAP code is at github&lt;/a&gt;
even though &lt;a href="http://geekdamana.blogspot.com/2008/10/this-one-is-better-ruby-net-ldap.html"&gt;existing solutions with good examples&lt;/a&gt; point you to what are now broken links.
&lt;br/&gt;&lt;br/&gt;
To install (despite README.txt saying otherwise):
&lt;br/&gt;&lt;br/&gt;
&lt;div class="codeBlock"&gt;
gem install ruby-net-ldap
&lt;/div&gt;
&lt;br/&gt;
And here's some LDAP login/authorization/auth code:
&lt;br/&gt;
&lt;div class="codeBlock"&gt;
&lt;pre style='color:#000000;background:#ffffff;'&gt;&lt;span style='color:#400000; '&gt;require&lt;/span&gt; &lt;span style='color:#0000e6; '&gt;'rubygems'&lt;/span&gt;
&lt;span style='color:#400000; '&gt;require&lt;/span&gt; &lt;span style='color:#0000e6; '&gt;'net/ldap'&lt;/span&gt;

ldap &lt;span style='color:#808030; '&gt;=&lt;/span&gt; Net::LDAP&lt;span style='color:#808030; '&gt;.&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;new&lt;/span&gt;
ldap&lt;span style='color:#808030; '&gt;.&lt;/span&gt;host &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#0000e6; '&gt;"ldap.example.com"&lt;/span&gt;
ldap&lt;span style='color:#808030; '&gt;.&lt;/span&gt;port &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#0000e6; '&gt;"389"&lt;/span&gt;

username &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#0000e6; '&gt;"human_interest_stories"&lt;/span&gt;
password &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#0000e6; '&gt;"obituary"&lt;/span&gt;

ldap&lt;span style='color:#808030; '&gt;.&lt;/span&gt;auth &lt;span style='color:#0000e6; '&gt;"uid=#{username},ou=users,dc=example,dc=com"&lt;/span&gt;, password

is_authorized &lt;span style='color:#808030; '&gt;=&lt;/span&gt; ldap&lt;span style='color:#808030; '&gt;.&lt;/span&gt;bind &lt;span style='color:#696969; '&gt;# returns true if auth works, false otherwise (or throws error if it can't connect to the server)&lt;/span&gt;

&lt;span style='color:#696969; '&gt;#searching the LDAP from &lt;a href="http://geekdamana.blogspot.com/2008/10/this-one-is-better-ruby-net-ldap.html"&gt;Damana (linked above too)&lt;/a&gt;&lt;/span&gt;
filter &lt;span style='color:#808030; '&gt;=&lt;/span&gt; Net::LDAP::Filter&lt;span style='color:#808030; '&gt;.&lt;/span&gt;eq&lt;span style='color:#808030; '&gt;(&lt;/span&gt; &lt;span style='color:#0000e6; '&gt;"uid"&lt;/span&gt;, username &lt;span style='color:#808030; '&gt;)&lt;/span&gt;
&lt;span style='color:#696969; '&gt;#attrs = ["ou" , "objectClass"] # you can specify attributes&lt;/span&gt;
attrs &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;[&lt;/span&gt;&lt;span style='color:#808030; '&gt;]&lt;/span&gt;

ldap&lt;span style='color:#808030; '&gt;.&lt;/span&gt;search&lt;span style='color:#808030; '&gt;(&lt;/span&gt; :base &lt;span style='color:#808030; '&gt;=&lt;/span&gt;&gt; &lt;span style='color:#0000e6; '&gt;"ou=users,dc=example,dc=com"&lt;/span&gt;, :attributes &lt;span style='color:#808030; '&gt;=&lt;/span&gt;&gt; attrs, :filter &lt;span style='color:#808030; '&gt;=&lt;/span&gt;&gt; filter, :return_result &lt;span style='color:#808030; '&gt;=&lt;/span&gt;&gt; &lt;span style='color:#800000; font-weight:bold; '&gt;true&lt;/span&gt; &lt;span style='color:#808030; '&gt;)&lt;/span&gt; &lt;span style='color:#800000; font-weight:bold; '&gt;do&lt;/span&gt; |entry|
    &lt;span style='color:#400000; '&gt;puts&lt;/span&gt; entry&lt;span style='color:#808030; '&gt;.&lt;/span&gt;dn
    entry&lt;span style='color:#808030; '&gt;.&lt;/span&gt;attribute_names&lt;span style='color:#808030; '&gt;.&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;each&lt;/span&gt; &lt;span style='color:#800000; font-weight:bold; '&gt;do&lt;/span&gt; |n|
        &lt;span style='color:#400000; '&gt;puts&lt;/span&gt; &lt;span style='color:#0000e6; '&gt;"#{n} = #{entry[n]}"&lt;/span&gt;
    &lt;span style='color:#800000; font-weight:bold; '&gt;end&lt;/span&gt;
&lt;span style='color:#800000; font-weight:bold; '&gt;end&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt; 
&lt;br/&gt;
Hope it helps.
	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2009/6/30/Ruby-LDAP/2922#leave_a_comment" title="Go to the page and comments for Ruby LDAP"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/22ZUgJK_944" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[Ruby]]></category>

<category><![CDATA[.NET]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2009/6/30/Ruby-LDAP/2922</feedburner:origLink></item>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<item>
<title>An Independent Artist's View of Music Piracy</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/QIiwichGa48/2911</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2009/6/24/An-Independent-Artists-View-of-Music-Piracy/2911</guid>
<pubDate>Wed, 24 Jun 2009 23:39:18 -0500</pubDate>
<description>Many programmers view piracy as some inevitable righteous result of the coming of the information age. 
We justify the theft of music (in particular in this case) in several ways:
&lt;ol&gt;
	&lt;li&gt;Artists benefit because the number of fans increase which sells more tickets and merchandise at shows&lt;/li&gt;
	&lt;li&gt;Some &lt;a href="http://www.eff.org/deeplinks/2009/06/ascap-wants-be-paid-"&gt;ASCAP RIAA asshat wants to be paid for ridiculous things&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;The evil record companies need to get with the times and embrace file sharing&lt;/li&gt;
&lt;/ol&gt;
&lt;more&gt;
&lt;img src="http://www.codeodor.com/images/ascapasshat.png" alt="ASCAP asshats tweet"/&gt;&lt;br/&gt;&lt;br/&gt;
For the record, I agree with #3, used to think #1 was the case, and I'm refusing to do business with anyone 
I know is a member of &lt;s&gt;ASSHAT&lt;/s&gt; ASCAP. I'm very consciously changing my view on #1 
after hearing the artists' point of view. 
&lt;br/&gt;&lt;br/&gt;
As it turns out, maybe our righteous crusade is not all we'd like to think. 
	&lt;a href="http://benweasel.mu.nu/archives/288429.php"&gt;Quoth independent artist Ben Weasel&lt;/a&gt;: 
&lt;blockquote&gt;
	So the world will always have its Billy Joel's, along with its hot shot Internet sensations of the moment. 
	But what I want to know, again, is &lt;b&gt;who's going to be paying for the &lt;em&gt;recording&lt;/em&gt; of all this free music 
	dreamed up by small-timers (which description, if you're not aware, covers most of us)?&lt;/b&gt; 
	&lt;br/&gt;&lt;br/&gt;
	&lt;b&gt;And if the answer is "nobody," that means that music made by people who are even a little bit 
	outside the mainstream, off the beaten path, or just plain fucking &lt;i&gt;weird&lt;/i&gt;, is going to 
	disappear (save, of course, for those with disposable cash - the hobbyists and the rich kids - 
	but those people tend to make music that people can't even be bothered to download for free)&lt;/b&gt;.
	&lt;br/&gt;&lt;br/&gt; 
	Long term, this isn't going to work out well for music fans. I'm not scolding. I'm not trying to stuff 
	the genie back in the bottle. I just want the emperor's distinct lack of clothing noted: &lt;b&gt;the alleged death 
	of the music industry is in actuality the death of interesting music&lt;/b&gt;.
	&lt;br/&gt;&lt;br/&gt;
	I said the same thing six years ago when I first wrote about this stuff. 
	And what's happened since? Music has become more boring than ever, that's what. 
	Even punk rock has become more mind-numbingly mediocre than I ever remember it being before, 
	and I came of age when bands like Youth Of Today and Corrosion of Conformity were hot shit 
	with the dimbulb set. 
	&lt;br/&gt;&lt;br/&gt;
	I haven't seen so many bands playing it safe and copying what's popular since the skulls and 
	anarchy-symbol craze of 1984. If I hear another band aping the Dillinger Four and shouting 
	their Cookie Monster vocals at me through their hobo beards I may begin to sob.
	&lt;br/&gt;&lt;br/&gt;
	At the time I was first bemoaning the effect file-sharing was bound to have on the best music, 
	I was informed (rather condescendingly, as I recall) that &lt;b&gt;all those fans who were illegally 
	downloading my music were going to be paying me back in spades via sales of show tickets and merchandise&lt;/b&gt;.
	&lt;br/&gt;&lt;br/&gt; 
	And while my showing in that department is dandy at the moment, it certainly hasn't picked up any in 
	the ensuing six years. &lt;b&gt;In fact, merchandise sales are almost exactly the same&lt;/b&gt;. Granted, these days 
	that's cause to break out the bubbly and perch a lampshade on the old noggin, but &lt;b&gt;I can't help but 
	notice that this whole file sharing thing hasn't quite worked out as advertised - not just for me, 
	but for any other working musicians I know either&lt;/b&gt;. 
	&lt;br/&gt;&lt;br/&gt;
	Now maybe that's all a big, fat coincidence, 
	but it's kind of hard to escape the conclusion that what &lt;b&gt;this is, was, and always will be about 
	is people getting something for nothing&lt;/b&gt;. It's not about crazed rock fandom.
	&lt;br/&gt;&lt;br/&gt;
	It's about as gobbling 
	up as much free stuff as you can with little regard for what it is or might be, and virtually no 
	patience at all when it comes to evaluating the goods because, after all, if it's free, what can 
	it really be worth? And the reason people are doing it isn't because any sort of revolution has occurred; 
	&lt;b&gt;it's not a consequence of us poor artists having been unshackled from the chains of the evil 
	record labels&lt;/b&gt; and their PR teams and A&amp;amp;R men and distributors and lawyers and accountants. 
	&lt;br/&gt;&lt;br/&gt;
	&lt;b&gt;It's happening because people can steal music easily and without any real risk of getting caught.&lt;/b&gt; 
	That's the way the music business is these days and while I'm not happy about it I'm well aware 
	there's no point in fighting it. &lt;b&gt;I refuse to allow people to dress it up as something noble when 
	it's nothing more than simple greed and theft&lt;/b&gt;, but don't get the idea that I'm raging against the 
	dying of the light; I assure you that at this stage the cupboard has been rendered so bare that
	record royalties are more or less a moot point. 
	&lt;br/&gt;&lt;br/&gt;
	&lt;b&gt;I'd be happy to give away future albums, settling 
	for crossing my fingers and praying for the odd licensing deal, &lt;em&gt;if only I could figure out how to 
	pay for the damned recordings&lt;/em&gt;!&lt;/b&gt;
	&lt;br/&gt;&lt;br/&gt;
	(bolding and paragraph additions (for readability) by yours truly)
&lt;/blockquote&gt;
&lt;img src="http://www.codeodor.com/images/screechingweasel.jpg" alt="Screeching Weasel logo, the band whose leader was quoted above."/&gt;
&lt;br/&gt;&lt;br/&gt;
What say you?
	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2009/6/24/An-Independent-Artists-View-of-Music-Piracy/2911#leave_a_comment" title="Go to the page and comments for An Independent Artist's View of Music Piracy"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/QIiwichGa48" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[Miscellany]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2009/6/24/An-Independent-Artists-View-of-Music-Piracy/2911</feedburner:origLink></item>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<item>
<title>Packed and encoded information as names for things</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/FieyxVcOJkE/2904</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2009/6/18/Packed-and-encoded-information-as-names-for-things/2904</guid>
<pubDate>Thu, 18 Jun 2009 11:33:27 -0500</pubDate>
<description>Don't encode information into a string like "AAHD09102008BSHC813" and give that gibberish to people. Don't name your project that, don't give that to me as a value or way to identify something, and don't make humans see or interact with that in any form. (If you are generating something similar and parse it with a program in automated fashion, I don't care what you call it.)
&lt;br/&gt;&lt;br/&gt;
&lt;strong&gt;Give it a name we can use while communicating with each other and keep the rest of the information in a database&lt;/strong&gt;. I can look it up if I need to know it.
&lt;br/&gt;&lt;br/&gt;
Do not use file names, folder names, or project names as your as your database. I don't want to be required to scan each item in whatever set you chose and translate it using a lookup table to find what I'm looking for. I don't want to memorize the lookup table either.

	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2009/6/18/Packed-and-encoded-information-as-names-for-things/2904#leave_a_comment" title="Go to the page and comments for Packed and encoded information as names for things"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/FieyxVcOJkE" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[Programming]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2009/6/18/Packed-and-encoded-information-as-names-for-things/2904</feedburner:origLink></item>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<item>
<title>Strive for low coupling and high cohesion: What does that even mean?</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/IOpsHCeJ8bg/2902</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2009/6/17/Strive-for-low-coupling-and-high-cohesion-What-does-that-even-mean/2902</guid>
<pubDate>Wed, 17 Jun 2009 12:26:39 -0500</pubDate>
<description>low cou-pling and high co-he-sion&lt;br/&gt;
&lt;i&gt;n.&lt;/i&gt;
&lt;ol&gt;&lt;li&gt;
A standard bit of advice for people who are learning to design their code better, who want to 
write software with intention as opposed to coincidence, often parroted by the advisor 
with no attempt to explain the meaning. 
&lt;/li&gt;&lt;/ol&gt;

&lt;h2&gt;Motivation&lt;/h2&gt;
It's a great scam, don't you think? Someone asks a question about how to design their code, 
and we have these two nebulous words to throw back at them: coupling and cohesion. 
We even memorize a couple of adjectives that go with the words: low and high. &lt;more&gt;
&lt;br/&gt;&lt;br/&gt;
Cohesion Good. Coupling, Baaaaad! 
&lt;br/&gt;&lt;br/&gt;
&lt;img src="http://www.codeodor.com/images/napster_bad.png" alt="Metallica Good, Napster Bad." title="Beer, good. Fire, bad!"/&gt;
&lt;br/&gt;&lt;br/&gt;
It's great because it shuts up the newbie who asks the question -- he doesn't want to appear dumb, after all --
and it gets all of those in-the-know to nod their heads in approval. "Yep, that's right. He's got it. +1."
&lt;br/&gt;&lt;br/&gt;
But no one benefits from the exchange. The newbie is still frustrated, while the professional doesn't 
give a second thought to the fact that &lt;em&gt;he&lt;/em&gt; probably doesn't know what he means. He's just parroting 
back the advice that someone gave to him. It's not malicious or even conscious, but nobody is getting smarter 
as a result of the practice.
&lt;br/&gt;&lt;br/&gt;
Maybe we think the words are intuitive enough. Coupling means that something is depending on something else, multiple 
things are tied together. Cohesion means ... well, maybe the person asking the question heard something about
 it in high school chemistry and can recall it has something to do with sticking together. 
Maybe they don't know at all.
&lt;br/&gt;&lt;br/&gt;
Maybe, if they're motivated enough (and not that we've done anything to help in that department), they'll look it 
up:

&lt;h2&gt;Types of Cohesion and Coupling&lt;/h2&gt;

&lt;a href="http://en.wikipedia.org/wiki/Cohesion_(computer_science)"&gt;Types of Cohesion&lt;/a&gt;
&lt;blockquote&gt;
&lt;b&gt;Coincidental cohesion (worst)&lt;/b&gt;
 is when parts of a module are grouped arbitrarily (at random); the parts have no significant relationship (e.g. a module of frequently used functions).
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;Logical cohesion&lt;/b&gt;
is when parts of a module are grouped because they logically are categorised to do the same thing, even if they are different by nature (e.g. grouping all I/O handling routines).
&lt;br/&gt;&lt;br/&gt;

&lt;b&gt;Temporal cohesion&lt;/b&gt;
is when parts of a module are grouped by when they are processed - the parts are processed at a particular time in program execution (e.g. a function which is called after catching an exception which closes open files, creates an error log, and notifies the user).
&lt;br/&gt;&lt;br/&gt;

&lt;b&gt;Procedural cohesion&lt;/b&gt;
 is when parts of a module are grouped because they always follow a certain sequence of execution (e.g. a function which checks file permissions and then opens the file).
&lt;br/&gt;&lt;br/&gt;

&lt;b&gt;Communicational cohesion&lt;/b&gt;
 is when parts of a module are grouped because they operate on the same data (e.g. a module which operates on the same record of information).
&lt;br/&gt;&lt;br/&gt;

&lt;b&gt;Sequential cohesion&lt;/b&gt;
 is when parts of a module are grouped because the output from one part is the input to another part like an assembly line (e.g. a function which reads data from a file and processes the data).

&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;Functional cohesion (best)&lt;/b&gt;
is when parts of a module are grouped because they all contribute to a single well-defined task of the module
&lt;/blockquote&gt;


&lt;a href="http://en.wikipedia.org/wiki/Coupling_(computer_science)"&gt;Types of Coupling&lt;/a&gt;
&lt;blockquote&gt;
	&lt;b&gt;Content coupling (high)&lt;/b&gt;
	    is when one module modifies or relies on the internal workings of another module (e.g. accessing local data of another module).
	    Therefore changing the way the second module produces data (location, type, timing) will lead to changing the dependent module.
	&lt;br/&gt;&lt;br/&gt;
	&lt;b&gt;Common coupling&lt;/b&gt;
	    is when two modules share the same global data (e.g. a global variable).
	    Changing the shared resource implies changing all the modules using it.
	&lt;br/&gt;&lt;br/&gt;
	&lt;b&gt;External coupling&lt;/b&gt;
	    occurs when two modules share an externally imposed data format, communication protocol, or device interface.
	&lt;br/&gt;&lt;br/&gt;
	&lt;b&gt;Control coupling&lt;/b&gt;
	    is one module controlling the logic of another, by passing it information on what to do (e.g. passing a what-to-do flag).
	&lt;br/&gt;&lt;br/&gt;
	&lt;b&gt;Stamp coupling (Data-structured coupling)&lt;/b&gt;
	    is when modules share a composite data structure and use only a part of it, possibly a different part (e.g. passing a whole record to a function which only needs one field of it).
	    This may lead to changing the way a module reads a record because a field, which the module doesn't need, has been modified.
	&lt;br/&gt;&lt;br/&gt;
	&lt;b&gt;Data coupling&lt;/b&gt;
	    is when modules share data through, for example, parameters. Each datum is an elementary piece, and these are the only data which are shared (e.g. passing an integer to a function which computes a square root).
	&lt;br/&gt;&lt;br/&gt;
	&lt;b&gt;Message coupling (low)&lt;/b&gt;
	    is the loosest type of coupling. Modules are not dependent on each other, instead they use a public interface to exchange parameter-less messages (or events, see Message passing).
	&lt;br/&gt;&lt;br/&gt;
	&lt;b&gt;No coupling&lt;/b&gt;
	    [is when] modules do not communicate at all with one another.
&lt;/blockquote&gt;	

&lt;h2&gt;What does it all mean?&lt;/h2&gt;
The Wikipedia entries mention that "low coupling often correlates with high cohesion" and 
"high cohesion often correlates with loose coupling, and vice versa." 
&lt;br/&gt;&lt;br/&gt;
However, that's not the intuitive result of simple evaluation, especially on the part of someone who doesn't 
know in the first place.  
&lt;br/&gt;&lt;br/&gt;
In the context of the prototypical question
about how to improve the structure of code, one does not lead to the other. By reducing coupling, on the face of 
it the programmer is going to merge unrelated units of code, which would also reduce cohesion. Likewise, removing 
unrelated functions from a class will introduce another class on which the original will need to depend, increasing 
coupling.
&lt;br/&gt;&lt;br/&gt;
To understand how the relationships become inversely correlated requires a larger step in logic, where examples
of the different types of coupling and cohesion would prove helpful.

&lt;h2&gt;Examples from each category of cohesion&lt;/h2&gt; 
&lt;b&gt;Coincidental cohesion&lt;/b&gt; often looks like this:
&lt;br/&gt;&lt;br/&gt;
&lt;div class="codeBlock"&gt;
	class Helpers;&lt;br/&gt;&lt;br/&gt;
	class Util;&lt;br/&gt;&lt;br/&gt;
	int main(void) {&lt;br/&gt; 
	&amp;nbsp;&amp;nbsp;where almost all of your code goes here; &lt;br/&gt;
	&amp;nbsp;&amp;nbsp;return 0;&lt;br/&gt; 
	}&lt;br/&gt;	
&lt;/div&gt;
&lt;br/&gt;
In other words, the code is organized with no special thought as to &lt;em&gt;how it should be organized&lt;/em&gt;.
General helper and utility classes,
&lt;a href="http://stackoverflow.com/questions/361873/dealing-with-god-objects/361880"&gt;God Objects&lt;/a&gt;, 
&lt;a href="http://www.laputan.org/mud/"&gt;Big Balls of Mud&lt;/a&gt;, and other &lt;a href="http://c2.com/cgi/wiki?AntiPatternsCatalog"&gt;anti-patterns&lt;/a&gt;
are epitomes of coincidental cohesion. 
You might think of it as the lack of cohesion: we normally talk about cohesion being a good thing, whereas 
we'd like to avoid this type as much as possible.
&lt;br/&gt;&lt;br/&gt;
(However, one interesting property of coincidental cohesion is that even though the code in question should &lt;em&gt;not&lt;/em&gt; be stuck together, 
it tends to remain in that state because programmers are too afraid to touch it.) 
&lt;br/&gt;&lt;br/&gt;

With &lt;b&gt;logical cohesion&lt;/b&gt;, you start to have a bit of organization. The Wikipedia example mentions "grouping 
all I/O handling routines." You might think, "what's wrong with that? It makes perfect sense." Then consider that
you may have one file:
&lt;br/&gt;&lt;br/&gt;
IO.somelang
&lt;div class="codeBlock"&gt;
	function diskIO();&lt;br/&gt;
	function screenIO();&lt;br/&gt;
	function gameControllerIO();
&lt;/div&gt;
&lt;br/&gt;
While logical cohesion is much better than coincidental cohesion, it doesn't necessarily go far enough in terms 
of organizing your code. For one, we've got all IO in the same folder in the same file, no matter what type of 
device is doing the inputting and outputting. On another level, we've got functions that handle both input and 
output, when separating them out would make for better design.
&lt;br/&gt;&lt;br/&gt;

&lt;b&gt;Temporal cohesion&lt;/b&gt;
is one where you might be thinking "duh, of course code that's executed based on some other 
event is tied to that event." Especially considering the Wikipedia example:
&lt;blockquote&gt;
	a function which is called after catching an exception which closes open files, 
	creates an error log, and notifies the user.
&lt;/blockquote&gt;
But consider we're not talking about simple the relationship in time. We're really interested in the code's structure.
So to be temporally cohesive, your code in that error handling situation should keep the &lt;code&gt;closeFile&lt;/code&gt;,
&lt;code&gt;logError&lt;/code&gt;, and &lt;code&gt;notifyUser&lt;/code&gt; functions close to where they are used. That doesn't mean 
you'll always do the lowest-level implementation in the same file -- you can create small functions that take 
care of setting up the boilerplate needed to call the real ones.
&lt;br/&gt;&lt;br/&gt;
It's also important to note that you'll almost never want to implement all of that directly in the &lt;code&gt;catch&lt;/code&gt; 
block. That's sloppy, and the antithesis of good design. (I say "almost" because I am wary of absolutes, yet I cannot think 
of a situation where I would do so.) Doing so violates functional cohesion, which is what we're really 
striving for.
&lt;br/&gt;&lt;br/&gt;

&lt;b&gt;Procedural cohesion&lt;/b&gt;
is similar to temporal cohesion, but instead of time-based it's sequence-based. These are similar because 
many things we do close together in time are also done in sequence, but that's not always the case.
There's not much to say here. You want to keep the definitions of functions that do things together structurally 
close together in your code, assuming they have a reason to be close to begin with. For instance, 
you wouldn't put two modules of code together if they're not at least logically cohesive to begin with. Ideally,
as in every other type of cohesion, you'll strive for functional cohesion first.
&lt;br/&gt;&lt;br/&gt;

&lt;b&gt;Communicational cohesion&lt;/b&gt; 
typically looks like this:
&lt;br/&gt;&lt;br/&gt;
&lt;div class="codeBlock"&gt;
	some lines of code;&lt;br/&gt;
	data = new Data();&lt;br/&gt;
	function1(Data d) {...};&lt;br/&gt;
	function2(Data d) {...};&lt;br/&gt;
	some more lines of code; &lt;br/&gt;
&lt;/div&gt;
&lt;br/&gt;
In other words, you're keeping functions together that work on the same data.
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;Sequential cohesion&lt;/b&gt;
is much like procedural and temporal cohesion, except the reasoning behind it is that functions would 
chain together where the output of one feeds the input of another.
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;Functional cohesion&lt;/b&gt; is the ultimate goal. 
It's &lt;a href="http://www.objectmentor.com/resources/articles/srp.pdf"&gt;The Single Responsibility Principle [PDF]&lt;/a&gt; in 
action. Your methods are short and to the point. Ones that are related are grouped together locally in a file.
Even files or classes contribute to one purpose and do it well. Using the IO example from above, you might have 
a directory structure for each device, and within it, a class for Input and one for Output. Those would be children
of abstract I/O classes that implemented all but the device-specific pieces of code. 
&lt;br/&gt;&lt;br/&gt;
(I use inheritance terminology here only
as a subject that I believe communicates the idea to others. Of course, you don't have to even have inheritance 
available to you to achieve the goal of keeping device agnostic code in one locale while keeping the device 
specific code apart from it).

&lt;h2&gt;Examples from each category of coupling&lt;/h2&gt;
&lt;b&gt;Content coupling&lt;/b&gt; is horrific. You see it all over the place. It's probably in a lot of your code, and 
you don't realize it. It's often referred to a violation of encapsulation in OO-speak, and it looks like one 
piece of code reaching into another, without regard to any specified interfaces or respecting privacy. The problem
with it is that when you rely on an internal implementation as opposed to an explicit interface, any time that 
module you rely on changes, you have to change too:
&lt;br/&gt;&lt;br/&gt;
&lt;div class="codeBlock"&gt;
	module A&lt;br/&gt;
	&amp;nbsp;&amp;nbsp;data_member = 10&lt;br/&gt;
	end&lt;br/&gt;&lt;br/&gt;
	
	module B&lt;br/&gt;
	&amp;nbsp;&amp;nbsp;10 * A-&gt;data_member
	end 
&lt;/div&gt;
&lt;br/&gt;
What if data_member was really called &lt;code&gt;num_times_accessed&lt;/code&gt;? Well, now you're screwed since you're 
not calculating it.
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;Common coupling&lt;/b&gt;
occurs all the time too. The Wikipedia article mentions global variables, but this could be just a member in a class
where two or more functions rely on it if you consider it. It's not as bad when its encapsulated behind an interface,
where instead of accessing the resource directly, you do so indirectly, which allows you to change internal 
behavior behind the wall, and keeps your other units of code from having to change every time the shared resource 
changes.


&lt;br/&gt;&lt;br/&gt;
An example of &lt;b&gt;external coupling&lt;/b&gt; is a program where one part of the code reads a specific file format that 
another part of the code wrote. Both pieces need to know the format so when one changes, the other must as well.
&lt;br/&gt;&lt;br/&gt;
&lt;div class="codeBlock"&gt;
	unit A&lt;br/&gt; 
	&amp;nbsp;&amp;nbsp;write_csv_format();&lt;br/&gt;
	end&lt;br/&gt;
	&lt;br/&gt;
	unit B // in another file, probably&lt;br/&gt;
	&amp;nbsp;&amp;nbsp;read_csv_format();&lt;br/&gt;
	end&lt;br/&gt;
&lt;/div&gt;
&lt;br/&gt;

&lt;b&gt;Control coupling&lt;/b&gt;
    might look like:
	&lt;div class="codeBlock"&gt;
		// unit A&lt;br/&gt;
		function do(what){&lt;br/&gt;
		&amp;nbsp;&amp;nbsp;if(what == 1) do_wop;&lt;br/&gt;
		&amp;nbsp;&amp;nbsp;else if (what == 2) ba_ba_da_da_da_do_wop;&lt;br/&gt;
		}&lt;br/&gt;
		&lt;br/&gt;
		// unit B&lt;br/&gt; 
		A.do(1);&lt;br/&gt;
		
	&lt;/div&gt;
	
&lt;br/&gt;
&lt;b&gt;Stamp coupling (Data-structured coupling)&lt;/b&gt;
	involved disparate pieces of code touching the same data structure in different ways. For example:
	&lt;br/&gt;&lt;br/&gt;
	&lt;div class="codeBlock"&gt;
		employee = { :age =&gt; 24, :compensation=&gt; 2000 }&lt;br/&gt;
		&lt;br/&gt;
		def age_range(employee)&lt;br&gt;
		&amp;nbsp;&amp;nbsp;range = 1 if employee[:age] &amp;lt; 10&lt;br/&gt;
		&amp;nbsp;&amp;nbsp;range = 2 if employee[:age] &amp;gt; 10 &amp;amp;&amp;amp; &amp;lt; 20;&lt;br/&gt;
		&amp;nbsp;&amp;nbsp;...&lt;br/&gt;
		&amp;nbsp;&amp;nbsp;return range&lt;br/&gt;
		end&lt;br/&gt;
		&lt;br/&gt;
		def compensation_range(employee)&lt;br/&gt;
		&amp;nbsp;&amp;nbsp;... only relies on employee[:compensation] ...&lt;br/&gt;
		end
	&lt;/div&gt;
&lt;br/&gt;
The two functions don't need the employee structure, but they rely on it and if it changes, those two functions
have to change. It's much better to just pass the values and let them operate on that.

&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;Data coupling&lt;/b&gt;
   is starting to get to where we need to be. One module depends on another for data. It's a typical function call with parameters:
&lt;br/&gt;&lt;br/&gt;
&lt;div class="codeBlock"&gt;
	// in module A&lt;br/&gt;
	B.add(2, 4)&lt;br/&gt;
&lt;/div&gt;
&lt;br/&gt;
&lt;b&gt;Message coupling&lt;/b&gt;
    looks like data coupling, but it's even looser because two modules communicate indirectly without ever passing 
each other data. Method calls have no parameters, in other words. 
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;No coupling&lt;/b&gt;, like Wikipedia says, is when "modules do not communicate at all with one another."
There is no dependency from code A to code B.


&lt;h2&gt;Concluding Remarks&lt;/h2&gt;
So how do we reconcile the thought that "if I separate code to increase functional cohesion, I introduce dependencies 
which is going to increase coupling" with the assertion that low coupling and high cohesion go hand in hand? To do that,
you must recognize that the dependencies already exist. Perhaps not at the class level, but they do at the lines of 
code level. By pulling them out into related units, you remove the spaghetti structure (if you can call it that) 
and turn it into something much more manageable. 
&lt;br/&gt;&lt;br/&gt;
&lt;img src="http://www.codeodor.com/images/from_spaghetti_code_to_better_code.jpg" alt="Increasing cohesion and decreasing coupling."/&gt;
&lt;br/&gt;&lt;br/&gt;
A system of code can never be completely de-coupled unless it does nothing. Cohesion is a different story. 
I can't claim that your code cannot be perfectly cohesive, but I can't claim that it can. My belief is it 
can be very close, but at some point you'll encounter diminishing returns on your quest to make it so. 
&lt;br/&gt;&lt;br/&gt;
The key takeaway is to start looking at your code and think about what you can do to improve it as you notice 
the relationships between each line you write start take shape.
&lt;br/&gt;&lt;br/&gt;
Comments and corrections(!) are encouraged. &lt;b&gt;What are your thoughts?&lt;/b&gt;
	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2009/6/17/Strive-for-low-coupling-and-high-cohesion-What-does-that-even-mean/2902#leave_a_comment" title="Go to the page and comments for Strive for low coupling and high cohesion: What does that even mean?"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/IOpsHCeJ8bg" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[OOAD]]></category>

<category><![CDATA[DRY]]></category>

<category><![CDATA[Programming]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2009/6/17/Strive-for-low-coupling-and-high-cohesion-What-does-that-even-mean/2902</feedburner:origLink></item>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<item>
<title>Automating Excel with Ruby: A Simple Example</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/d3Vwam5iBFI/2898</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2009/6/9/Automating-Excel-with-Ruby-A-Simple-Example/2898</guid>
<pubDate>Tue, 09 Jun 2009 06:06:38 -0500</pubDate>
<description>From time to time I like to actually post a bit of code on this programming blog, so here's  

a stream-of-conscious (as in "not a lot of thought went into design quality") example that shows how to:
&lt;ol&gt;
	&lt;li&gt;Open Excel, making it invisible (or visible) to the user.&lt;/li&gt;
	&lt;li&gt;Create a workbook and access individual worksheets&lt;/li&gt;
	&lt;li&gt;Add data to a cell, or retrieve data from a cell&lt;/li&gt;
	&lt;li&gt;Add a chart to a worksheet, with constants for various chart types&lt;/li&gt;
	&lt;li&gt;Save as Excel 97-2003 format and close Excel&lt;/li&gt;
&lt;/ol&gt;
&lt;more&gt;
If you know where I can find the constants for file type numbers, that would be appreciated. Calling SaveAs 
without the type seems to use whatever version of Excel you are running, but I'd like to find how to save as 
CSV or other formats.
&lt;br/&gt;&lt;br/&gt;
Needless to say, this requires Excel be on the computer that's running the code.
&lt;br/&gt;&lt;br/&gt;
&lt;div class="codeBlock"&gt;
&lt;pre style='color:#000000;background:#ffffff;'&gt;&lt;span style='color:#400000; '&gt;require&lt;/span&gt; &lt;span style='color:#0000e6; '&gt;'win32ole'&lt;/span&gt;
xl &lt;span style='color:#808030; '&gt;=&lt;/span&gt; WIN32OLE&lt;span style='color:#808030; '&gt;.&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;new&lt;/span&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#0000e6; '&gt;"Excel.Application"&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;

&lt;span style='color:#400000; '&gt;puts&lt;/span&gt; &lt;span style='color:#0000e6; '&gt;"Excel failed to start"&lt;/span&gt; &lt;span style='color:#800000; font-weight:bold; '&gt;unless&lt;/span&gt; xl

xl&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Visible &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#800000; font-weight:bold; '&gt;false&lt;/span&gt;

workbook &lt;span style='color:#808030; '&gt;=&lt;/span&gt; xl&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Workbooks&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Add
sheet &lt;span style='color:#808030; '&gt;=&lt;/span&gt; workbook&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Worksheets&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#008c00; '&gt;1&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;

&lt;span style='color:#696969; '&gt;#create some fake data&lt;/span&gt;
data_a &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;[&lt;/span&gt;&lt;span style='color:#808030; '&gt;]&lt;/span&gt;
&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#008c00; '&gt;1&lt;/span&gt;&lt;span style='color:#808030; '&gt;.&lt;/span&gt;&lt;span style='color:#008000; '&gt;.10&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;.&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;each&lt;/span&gt;&lt;span style='color:#800080; '&gt;{&lt;/span&gt;|i| data_a&lt;span style='color:#808030; '&gt;.&lt;/span&gt;push i &lt;span style='color:#800080; '&gt;}&lt;/span&gt;

data_b &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;[&lt;/span&gt;&lt;span style='color:#808030; '&gt;]&lt;/span&gt;
&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#008c00; '&gt;1&lt;/span&gt;&lt;span style='color:#808030; '&gt;.&lt;/span&gt;&lt;span style='color:#008000; '&gt;.10&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;.&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;each&lt;/span&gt;&lt;span style='color:#800080; '&gt;{&lt;/span&gt;|i| data_b&lt;span style='color:#808030; '&gt;.&lt;/span&gt;push&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#400000; '&gt;rand&lt;/span&gt; &lt;span style='color:#808030; '&gt;*&lt;/span&gt; &lt;span style='color:#008c00; '&gt;100&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;.&lt;/span&gt;to_i&lt;span style='color:#808030; '&gt;)&lt;/span&gt; &lt;span style='color:#800080; '&gt;}&lt;/span&gt;

&lt;span style='color:#696969; '&gt;#fill the worksheet with the fake data&lt;/span&gt;
&lt;span style='color:#696969; '&gt;#showing 3 ways to populate cells with values&lt;/span&gt;
&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#008c00; '&gt;1&lt;/span&gt;&lt;span style='color:#808030; '&gt;.&lt;/span&gt;&lt;span style='color:#008000; '&gt;.10&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;.&lt;/span&gt;&lt;span style='color:#800000; font-weight:bold; '&gt;each&lt;/span&gt; &lt;span style='color:#800000; font-weight:bold; '&gt;do&lt;/span&gt; |i|
  sheet&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Range&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#0000e6; '&gt;"A#{i}"&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Select
  xl&lt;span style='color:#808030; '&gt;.&lt;/span&gt;ActiveCell&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Formula &lt;span style='color:#808030; '&gt;=&lt;/span&gt; data_a&lt;span style='color:#808030; '&gt;[&lt;/span&gt;i&lt;span style='color:#808030; '&gt;-&lt;/span&gt;&lt;span style='color:#008c00; '&gt;1&lt;/span&gt;&lt;span style='color:#808030; '&gt;]&lt;/span&gt;
  
  sheet&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Range&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#0000e6; '&gt;"B#{i}"&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Formula &lt;span style='color:#808030; '&gt;=&lt;/span&gt; data_b&lt;span style='color:#808030; '&gt;[&lt;/span&gt;i&lt;span style='color:#808030; '&gt;-&lt;/span&gt;&lt;span style='color:#008c00; '&gt;1&lt;/span&gt;&lt;span style='color:#808030; '&gt;]&lt;/span&gt;
  
  cell &lt;span style='color:#808030; '&gt;=&lt;/span&gt; sheet&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Range&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#0000e6; '&gt;"C#{i}"&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;
  cell&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Formula &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#0000e6; '&gt;"=A#{i} - B#{i}"&lt;/span&gt;
&lt;span style='color:#800000; font-weight:bold; '&gt;end&lt;/span&gt; 

&lt;span style='color:#696969; '&gt;#chart type constants (via &lt;/span&gt;&lt;span style='color:#5555dd; '&gt;&lt;a href="http://support.microsoft.com/kb/147803"&gt;http://support.microsoft.com/kb/147803&lt;/a&gt;&lt;/span&gt;&lt;span style='color:#696969; '&gt;)&lt;/span&gt;
xlArea &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#008c00; '&gt;1&lt;/span&gt;
xlBar &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#008c00; '&gt;2&lt;/span&gt;
xlColumn &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#008c00; '&gt;3&lt;/span&gt;
xlLine &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#008c00; '&gt;4&lt;/span&gt;
xlPie &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#008c00; '&gt;5&lt;/span&gt;
xlRadar &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;-&lt;/span&gt;&lt;span style='color:#008c00; '&gt;4151&lt;/span&gt;
xlXYScatter &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;-&lt;/span&gt;&lt;span style='color:#008c00; '&gt;4169&lt;/span&gt;
xlCombination &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;-&lt;/span&gt;&lt;span style='color:#008c00; '&gt;4111&lt;/span&gt;
xl3DArea &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;-&lt;/span&gt;&lt;span style='color:#008c00; '&gt;4098&lt;/span&gt;
xl3DBar &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;-&lt;/span&gt;&lt;span style='color:#008c00; '&gt;4099&lt;/span&gt;
xl3DColumn &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;-&lt;/span&gt;&lt;span style='color:#008c00; '&gt;4100&lt;/span&gt;
xl3DLine &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;-&lt;/span&gt;&lt;span style='color:#008c00; '&gt;4101&lt;/span&gt; 
xl3DPie &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;-&lt;/span&gt;&lt;span style='color:#008c00; '&gt;4102&lt;/span&gt;
xl3DSurface &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;-&lt;/span&gt;&lt;span style='color:#008c00; '&gt;4103&lt;/span&gt;
xlDoughnut &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;-&lt;/span&gt;&lt;span style='color:#008c00; '&gt;4120&lt;/span&gt;

&lt;span style='color:#696969; '&gt;#creating a chart &lt;/span&gt;
chart_object &lt;span style='color:#808030; '&gt;=&lt;/span&gt; sheet&lt;span style='color:#808030; '&gt;.&lt;/span&gt;ChartObjects&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Add&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#008c00; '&gt;10&lt;/span&gt;, &lt;span style='color:#008c00; '&gt;80&lt;/span&gt;, &lt;span style='color:#008c00; '&gt;500&lt;/span&gt;, &lt;span style='color:#008c00; '&gt;250&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;
chart &lt;span style='color:#808030; '&gt;=&lt;/span&gt; chart_object&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Chart
chart_range &lt;span style='color:#808030; '&gt;=&lt;/span&gt; sheet&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Range&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#0000e6; '&gt;"A1"&lt;/span&gt;, &lt;span style='color:#0000e6; '&gt;"B10"&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;
chart&lt;span style='color:#808030; '&gt;.&lt;/span&gt;SetSourceData&lt;span style='color:#808030; '&gt;(&lt;/span&gt;chart_range, &lt;span style='color:#800000; font-weight:bold; '&gt;nil&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;
chart&lt;span style='color:#808030; '&gt;.&lt;/span&gt;ChartType &lt;span style='color:#808030; '&gt;=&lt;/span&gt; xlXYScatter

&lt;span style='color:#696969; '&gt;#get the value from a cell&lt;/span&gt;
val &lt;span style='color:#808030; '&gt;=&lt;/span&gt; sheet&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Range&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#0000e6; '&gt;"C1"&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt;&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Value
&lt;span style='color:#400000; '&gt;puts&lt;/span&gt; val

&lt;span style='color:#696969; '&gt;#saving as pre-2007 format&lt;/span&gt;
excel97_2003_format &lt;span style='color:#808030; '&gt;=&lt;/span&gt; &lt;span style='color:#808030; '&gt;-&lt;/span&gt;&lt;span style='color:#008c00; '&gt;4143&lt;/span&gt; 
pwd &lt;span style='color:#808030; '&gt;=&lt;/span&gt;  Dir&lt;span style='color:#808030; '&gt;.&lt;/span&gt;pwd&lt;span style='color:#808030; '&gt;.&lt;/span&gt;&lt;span style='color:#400000; '&gt;gsub&lt;/span&gt;&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#0000e6; '&gt;'/'&lt;/span&gt;,&lt;span style='color:#0000e6; '&gt;'\\'&lt;/span&gt;&lt;span style='color:#808030; '&gt;)&lt;/span&gt; &amp;lt;&amp;lt; &lt;span style='color:#0000e6; '&gt;'\\'&lt;/span&gt;
&lt;span style='color:#696969; '&gt;#otherwise, it sticks it in default save directory- C:\Users\Sam\Documents on my system&lt;/span&gt;
workbook&lt;span style='color:#808030; '&gt;.&lt;/span&gt;SaveAs&lt;span style='color:#808030; '&gt;(&lt;/span&gt;&lt;span style='color:#0000e6; '&gt;"#{pwd}whatever.xls"&lt;/span&gt;, excel97_2003_format&lt;span style='color:#808030; '&gt;)&lt;/span&gt;

xl&lt;span style='color:#808030; '&gt;.&lt;/span&gt;Quit
&lt;/pre&gt;
&lt;/div&gt;
&lt;br/&gt;
It's also posted &lt;a href="http://github.com/codeodor/miscellany/blob/master/ruby_excel_ole/excel_automation.rb"&gt;in my Miscellany project at GitHub&lt;/a&gt;

	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2009/6/9/Automating-Excel-with-Ruby-A-Simple-Example/2898#leave_a_comment" title="Go to the page and comments for Automating Excel with Ruby: A Simple Example"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/d3Vwam5iBFI" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[Ruby]]></category>

<category><![CDATA[Programming]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2009/6/9/Automating-Excel-with-Ruby-A-Simple-Example/2898</feedburner:origLink></item>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<item>
<title>Answering the 100 Interview Questions for Software Developers: Technical Design</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/HrUmqHenrx4/2709</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2009/2/3/Answering-the-100-Interview-Questions-for-Software-Developers-Technical-Design/2709</guid>
<pubDate>Wed, 17 Jun 2009 12:31:17 -0500</pubDate>
<description>This is the third in a &lt;a href="http://www.codeodor.com/index.cfm/category/Answers%20To%20100%20Interview%20Questions/39"&gt;series of 
	answers&lt;/a&gt; to  
&lt;a href="http://www.noop.nl/2009/01/100-interview-questions-for-software-developers.html"&gt;100 Interview Questions for Software Developers&lt;/a&gt;.
&lt;br/&gt;&lt;br/&gt;
The list is not intended to be a "one-size-fits-all" list.
Instead, "the key is to ask challenging questions that enable you to distinguish the smart software 
developers from the moronic mandrills." Even still, "for most of the questions in this list there are no 
right and wrong answers!"
&lt;br/&gt;&lt;br/&gt;
Keeping that in mind, I thought it would be fun for me to provide my off-the-top-of-my-head answers, 
as if I had not prepared for the interview at all. Here's that attempt.
&lt;br/&gt;&lt;br/&gt;
Though I hope otherwise, I may fall flat on my face. Be nice, and enjoy (and help out where you can!).
&lt;br/&gt;&lt;br/&gt;
Last week's &lt;a href="http://www.codeodor.com/index.cfm/2009/1/29/Answering-the-100-Interview-Questions-for-Software-Developers-Functional-Design/2705"&gt;answers on Functional Design&lt;/a&gt; 
had me feeling that way. Luckily, this week we come to technical design - a topic I feel quite a bit stronger on. &lt;more&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;What do &lt;a href="http://codeodor.com/index.cfm/2009/6/17/Strive-for-low-coupling-and-high-cohesion-What-does-that-even-mean/2902"&gt;low coupling and high cohesion&lt;/a&gt; mean? What does the principle of encapsulation mean?&lt;/b&gt;&lt;br/&gt;
	Coupling refers to how strongly or loosely components in a system are tied together. You want that to be 
	low. Cohesion refers to how well the individual parts of a unit of code fit together for a single purpose.
	Encapsulation is about containing implementation of code so that outsiders don't need to know how it's works
	on the inside. By doing so you can reduce negative effects of coupling.
	&lt;br/&gt;&lt;br/&gt;
	Reading: Robert C. Martin's &lt;a href="http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod"&gt;&lt;acronym title="SRP, OCP, LSP, ISP, DIP"&gt;SOLID&lt;/acronym&gt;&lt;/a&gt; 
	principles of &lt;acronym title="Object-Oriented Design"&gt;OOD&lt;/acronym&gt;, which have been linked on this blog since day 1. His book, &lt;a href="http://www.amazon.com/gp/product/0135974445?ie=UTF8&amp;tag=myseclifasasp-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0135974445"&gt;Agile Software Development: Principles, Patterns, and Practices&lt;/a&gt;
	is another great resource for this topic. It's short and to the point, and comes highly recommended from myself.
	&lt;br/&gt;&lt;br/&gt;
	&lt;object width="425" height="344" title="Low cohesion, high coupling. Does your code look like this?"&gt;&lt;param name="movie" value="http://www.youtube.com/v/RouXygRcRC4&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/RouXygRcRC4&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;
	&lt;br/&gt;&lt;br/&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;How do you manage conflicts in a web application when different people are editing the same data?&lt;/b&gt;&lt;br/&gt;
	Set a flag when someone starts editing data unit A. If someone else loads it, let them know it's being edited 
	and that it's currently in read only mode. If the race was too fast, you can also have a check on the 
	commit side to let them know their changes conflict with another user, present them the data, and then let 
	them figure out how to merge the changes. This has rarely been a problem in my experience, but it could be, 
	and that's how I'd deal with it if the requirement came up. (If the changes don't conflict, you could 
	simply keep the user unaware as well.)
	&lt;br/&gt;&lt;br/&gt;
	My answer comes from the things you see in normal usage of shared files or just about any shared resource, 
	for that matter. Originally, 
	it comes down to &lt;a href="http://en.wikipedia.org/wiki/Race_condition"&gt;race conditions&lt;/a&gt;, so you might 
	be able to extrapolate some useful information from that low-level explanation.
	&lt;br/&gt;&lt;br/&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Do you know about design patterns? Which design patterns have you used, and in what situations?&lt;/b&gt;&lt;br/&gt;
	I know about design patterns. Most of the ones I'm familiar with, at least in &lt;a href="http://www.amazon.com/gp/product/0201633612?ie=UTF8&amp;tag=myseclifasasp-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0201633612"&gt;the canonical book&lt;/a&gt;,
	aren't of much daily use to me, as I tend to work in dynamic languages, where the sorts of flaws that precipitate 
	the patterns (as implemented in the book) just aren't factors as often as in other languages. (Yes, some of the 
	book is implemented in Smalltalk. I can implement them with as much superfluous junk as you desire in 
	any language - that doesn't make it a necessity.)
	&lt;br/&gt;&lt;br/&gt;
	I suppose most frequently I've used the &lt;a href="http://en.wikipedia.org/wiki/Strategy_pattern"&gt;Strategy pattern&lt;/a&gt;.
	(Perhaps the fact that I've focused so much on one in particular is a weakness in my coding style?) The situations 
	are when an interface should remain the same while the implementation should differ somewhat. I don't have a 
	concrete example on the top of my head.
	&lt;br/&gt;&lt;br/&gt;
	If I were to start working in Java again, or building larger applications in .NET (I currently build very small 
	apps in that space as part of my job), I'd re-read the book. I might even scan the inner cover daily just as a 
	refresher.
	&lt;br/&gt;&lt;br/&gt;
	I wouldn't say I'm strong on design patterns, but I've got reference information and know where to look 
	should I need to, along with the facilities to become strong should my situation call for it.
	&lt;br/&gt;&lt;br/&gt;
	Reading: The aforementioned book, &lt;a href="http://www.amazon.com/gp/product/0201633612?ie=UTF8&amp;tag=myseclifasasp-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0201633612"&gt;Design Patterns: Elements of Reusable Object-Oriented Software&lt;/a&gt;.
	I hear good things about the better-selling &lt;a href="http://www.amazon.com/gp/product/0596007124?ie=UTF8&amp;tag=myseclifasasp-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0596007124"&gt;Head First Design Patterns&lt;/a&gt;,
	but I've not read it myself, so I can't speak to its efficacy. 
	&lt;br/&gt;&lt;br/&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Do you know what a stateless business layer is? Where do long-running transactions fit into that picture?&lt;/b&gt;&lt;br/&gt;
	I hadn't heard it as a single term until now, but knowing the individual terms lets me say that objects in 
	the business layer (or domain model) are transient - or that their state is not preserved in memory between 
	subsequent requests for the same object. 
	&lt;br/&gt;&lt;br/&gt;
	This may note bode well for long running transactions, as state presumably must be set up each time an 
	object is loaded, along with any process that might be required for tear-down.
	&lt;br/&gt;&lt;br/&gt;
	For reading, this is just information as I've come across it throughout my various readings, so I don't 
	know what to recommend. 
	&lt;br/&gt;&lt;br/&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;What kinds of diagrams have you used in designing parts of an architecture, or a technical design?&lt;/b&gt;&lt;br/&gt;
	&lt;acronym title="Unified Modeling Language"&gt;UML&lt;/acronym&gt;, or some bastardization of it has always been enough. 
	Most likely the bastardized part where we just do a little design on paper or a whiteboard to gain a 
	better understanding of the intended design through some sketch-work. 
	&lt;br/&gt;&lt;br/&gt;
	I've never been a part of a team that practices &lt;acronym title="Big design up front"&gt;BDUF&lt;/acronym&gt;, nor 
	have I felt the need for it in any personal projects, so I'm light on recommendations for reading.
	&lt;a href="http://en.wikipedia.org/wiki/Unified_Modeling_Language"&gt;The Wikipedia article on UML&lt;/a&gt; is 
	sufficient for my tastes, but I've know people who dove into &lt;a href="http://martinfowler.com/books.html"&gt;Martin Fowler's books&lt;/a&gt;
	and came away more knowledgeable, so that may help you.
	&lt;br/&gt;&lt;br/&gt;
	&lt;img src="http://www.codeodor.com/images/bigassuml.gif" alt="Typical UML diagram"/&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Can you name the different tiers and responsibilities in an N-tier architecture?&lt;/b&gt;&lt;br/&gt;
	For what value of N? (I mean, we could have N=1000000 and I wouldn't know -- or if I did know, we might 
	be here all day.) Normally N=3, so we might be talking about presentation, logic, and data tiers. Sometimes 
	we might talk about Entities and others, or we might be considering (mistakenly?) &lt;acronym title="Model, View, Controller"&gt;MVC&lt;/acronym&gt;.
	I think the responsibilities are clear by their names, but if you'd like to discuss further, I'm 
	certainly okay with doing so.
	&lt;br/&gt;&lt;br/&gt;
	Reading: As often is the case, &lt;a href="http://en.wikipedia.org/wiki/Multitier_architecture"&gt;Wikipedia provides a good starting point&lt;/a&gt;,
	though certainly it's a topic with enough depth one could read several books about it.
	&lt;br/&gt;&lt;br/&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Can you name different measures to guarantee correctness and robustness of data in an architecture?&lt;/b&gt;&lt;br/&gt;
	I need a little direction here. It seems to me this is a product of many things, and I don't know where to start.
	For instance, we could say that unit tests and integration tests can go part of the way there. We could 
	talk about validating user input, and that it matches some definition of "looking correct." We could 
	have checks coded and in place between the various systems that make up the architecture. Constraints on the 
	database. I could go on if I were giving myself more time to think about it.
	&lt;br/&gt;&lt;br/&gt;
	Because of the open-endedness in this question, there are any number of references. I'd dive into 
	automated testing in its various forms, which when applied to the situation, should get you most of the 
	way there.
	&lt;br/&gt;&lt;br/&gt; 
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Can you name any differences between object-oriented design and component-based design?&lt;/b&gt;&lt;br/&gt;
	To be honest, this is the first I've heard of component-based design, so no, I can't name the differences.
	My thoughts would go towards having objects to design around (as in C++) vs. not having objects to 
	design around (as in C).
	&lt;br/&gt;&lt;br/&gt;
	As it happens, there may be a reason the term "component-based design" seems new to me: &lt;a href="http://conferences.computer.org/compsac/2008/workshops/CORCS2008.html"&gt;IEEE held the 
	"1st ... workshop" on it not 6 months ago&lt;/a&gt;. They could very well be behind the times. 
	Searching with Google also indicates this may be designing from the view of the outside, 
	as in &lt;acronym title="Service Oriented Architecture"&gt;SOA&lt;/acronym&gt;. 
	&lt;br/&gt;&lt;br/&gt;
	I think the SOLID principles I mentioned above go beyond the availability of objects-proper, so I don't expect 
	to be surprised here. However, I can't offer you any reading advice and without a definitive source 
	from the Google results, I cannot even tell if I'm in the right ballpark. 
	&lt;br/&gt;&lt;br/&gt;
	Your thoughts are especially encouraged on this topic.
	&lt;br/&gt;&lt;br/&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;How would you model user authorization, user profiles and permissions in a database?&lt;/b&gt;&lt;br/&gt;
	I wouldn't typically model the authorization piece in the DB. If I read you correctly, I'm 
	guessing you mean &lt;i&gt;the storage of authorization information&lt;/i&gt; in the database, as opposed to the 
	&lt;i&gt;act of authorizing&lt;/i&gt;. Under that assumption, I've modeled this situation in just about every 
	way I can imagine. A couple of scenarios:
	&lt;br/&gt;&lt;br/&gt;
	a. Under a denormalized scenario, I'd keep a table of permissions and a table of users (which includes authorization 
	information, profile information, and a list of permissions from the users table). This isn't ideal if permissions 		
	ever change, and especially not if you're returning a ton of users for the purpose of authorization while the 
	profile information is especially large. In that case you're transferring way more data than you need, and it could 
	result in performance problems. (The extra data transfer may only be a problem with &lt;acronym title="Object-Relational Mapping"&gt;ORM&lt;/acronym&gt; tools, as you 
	could always hand-write the queries to return only what you need. 
	On the other hand, storing of redundant data is a problem if storage space itself is an issue.)
	&lt;br/&gt;&lt;br/&gt;
	b. Under a completely normalized scenario, we'd have a table of permissions, a table relating users 
	to permissions, and a table for users. For the sake of cohesion (and potentially optimizing data transfer) 
	we might separate the users table into one for authentication and another for profile, while keeping the 
	relationship with permissions based on user_auth.
	&lt;br/&gt;&lt;br/&gt;
	c. Some variation in between the two extremes.  
	&lt;br/&gt;&lt;br/&gt;
	For reading? For me it's based on experience, and perhaps a couple of database courses in college. I guess 
	just about any book on database design would do. I wouldn't bother trying to understand the formal 
	academic descriptions of &lt;a href="http://en.wikipedia.org/wiki/Database_normalization"&gt;database normalization&lt;/a&gt;,
	but if you want to, you can only be better for it (as long as you can recognize the tradeoffs due to extra 
	joins!) Reader suggestions are highly welcome, as always.
	&lt;br/&gt;&lt;br/&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;How would you model the animal kingdom (with species and their behavior) as a class system?&lt;/b&gt;&lt;br/&gt;
	This one might deserve a blog post all on its own. It depends: If I'm working in a language with 
	multiple inheritance, I'd use a combination of class hierarchy that follows the animal kingdom along 
	with mixins (which are also inheritance, but with less of a hierarchical attitude) for behavior shared 
	between and among the hierarchy levels. Without multiple inheritance, I'd have to resort to 
	interfaces where available, and composition for actual code reuse where it made sense. 
	&lt;br/&gt;&lt;br/&gt;
	The short answer though, is that I probably wouldn't implement it as a class system. If I really was working 
	with &lt;a href="http://en.wikipedia.org/wiki/Alpha_taxonomy"&gt;taxonomy&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Biological_classification"&gt;biological classification&lt;/a&gt;,
	I don't think I'd model the real world with objects. I'd need to look into the subject quite a bit further 
	to tell you how I &lt;em&gt;would&lt;/em&gt; do it, but suffice to say I don't think it'd be using objects to match 
	it one-for-one, or even something resembling one-to-one.
	&lt;br/&gt;&lt;br/&gt;
	Reading: I wouldn't know where to begin. The SOLID principles will guide you, but I wouldn't think that's all 
	there is to it.
	&lt;br/&gt;&lt;br/&gt;
	&lt;img src="http://www.codeodor.com/images/animalkingdom_map.jpg" title="Perhaps I'd model it like this." alt="Map of Disney's Animal Kingdom park"/&gt;
	&lt;br/&gt;&lt;br/&gt;
	 
&lt;/li&gt;
&lt;/ol&gt;
What do you think? Where would your answers differ? 
	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2009/2/3/Answering-the-100-Interview-Questions-for-Software-Developers-Technical-Design/2709#leave_a_comment" title="Go to the page and comments for Answering the 100 Interview Questions for Software Developers: Technical Design"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/HrUmqHenrx4" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[OOAD]]></category>

<category><![CDATA[Programming]]></category>

<category><![CDATA[Answers To 100 Interview Questions]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2009/2/3/Answering-the-100-Interview-Questions-for-Software-Developers-Technical-Design/2709</feedburner:origLink></item>

</channel>
</rss>
