<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Code Dump &#187; Programming</title>
	<atom:link href="http://www.codelord.net/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codelord.net</link>
	<description>A place a coder rants at...</description>
	<lastBuildDate>Tue, 15 Jun 2010 17:45:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Book Review: Clean Code</title>
		<link>http://www.codelord.net/2010/06/15/book-review-clean-code/</link>
		<comments>http://www.codelord.net/2010/06/15/book-review-clean-code/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 17:45:19 +0000</pubDate>
		<dc:creator>abyx</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[software craftsmanship]]></category>

		<guid isPermaLink="false">http://www.codelord.net/?p=202</guid>
		<description><![CDATA[This is another post in my book reviews series. I finished reading Clean Code a few days ago and loved it. It makes me feel good, seeing my decision to wear the Clean Code wristband a few months ago was a smart one.
After I finished it, I felt a bit weird writing a blog post [...]]]></description>
			<content:encoded><![CDATA[<p>This is another post in my <a href="http://www.codelord.net/tag/books/">book reviews series</a>. I finished reading <a href="http://www.amazon.com/gp/product/0132350882?ie=UTF8&amp;tag=thcodu02-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0132350882">Clean Code</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=thcodu02-20&amp;l=as2&amp;o=1&amp;a=0132350882" border="0" alt="" width="1" height="1" /> a few days ago and loved it. It makes me feel good, seeing my decision to wear the Clean Code <a href="http://bit.ly/aPug4e">wristband</a> a few months ago was a smart one.</p>
<p>After I finished it, I felt a bit weird writing a blog post about it, because, just like the previous books I&#8217;ve blogged about, I found this book simply awesome. Then I thought about the fact it&#8217;s simply because I&#8217;m reading those books that show up enough in other contexts that I upped them in my reading queue enough to get on top.</p>
<p>The book is about practical, low level details of writing good code. There are chapters about comments, naming, functions, you name it. In a way, it reminds me of <a href="http://www.amazon.com/gp/product/0735619670?ie=UTF8&amp;tag=thcodu02-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0735619670">Code Complete</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=thcodu02-20&amp;l=as2&amp;o=1&amp;a=0735619670" border="0" alt="" width="1" height="1" />, other than the fact you can see it&#8217;s oriented for more practiced developers.</p>
<p>Like in his <a href="http://www.amazon.com/gp/product/0135974445?ie=UTF8&amp;tag=thcodu02-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0135974445">Agile Software Development</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=thcodu02-20&amp;l=as2&amp;o=1&amp;a=0135974445" border="0" alt="" width="1" height="1" /> book, Uncle Bob made sure to fill this one with code. Actually, this book has a lot more code. There are many examples of code still being worked on. It actually fills the gap I&#8217;ve felt in Agile Software Development of seeing the actual coding steps, test by test. The last chapter shows a really thorough (and actually quite mesmerizing) example of refactoring, with each change explained beforehand, including tests and alternatives considered.</p>
<p>In Agile Software Development, there were a few co-authored chapters. In Clean Code Uncle Bob took this a step further. Almost every chapter was written by a different author, each of very big caliber in the Agile and Software Craftsmanship world. This really resonated with me, because it&#8217;s kind of a &#8220;many in one&#8221; deal, and because I could actually hear a different tone in each chapter, and yet all were in harmony with the motive of clean code.</p>
<p>I think this is truly a masterpiece, and after reading, would recommend it to be read before Agile Software Development. Due to its greater technicality and the fact it&#8217;s quite new, it makes a really good read for developers, and it will have an effect on your coding a few pages in (pages! not even chapters).</p>
<p>The only thing that bothered me was that in the last chapter (which is also the best) I had to, as the introduction warned me, flip back and forth quite a bit, which was a bit hard at first since I&#8217;m not used to reading code on paper. I&#8217;d really love seeing some interactive version of this, but regardless of that, the book is really good.</p>
<p>I can&#8217;t recommend enough this concentrated piece of wisdom and experience.</p>
<p>Stay tuned, a review of <a href="http://www.amazon.com/gp/product/0596518382?ie=UTF8&amp;tag=thcodu02-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0596518382">Apprenticeship Patterns</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=thcodu02-20&amp;l=as2&amp;o=1&amp;a=0596518382" border="0" alt="" width="1" height="1" /> is nigh.</p>
<p>You should subscribe to my feed and follow me on twitter.
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F06%2F15%2Fbook-review-clean-code%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F06%2F15%2Fbook-review-clean-code%2F&amp;source=avivby&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codelord.net/2010/06/15/book-review-clean-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Case Study: Refactoring Interfaces with TDDed Tests</title>
		<link>http://www.codelord.net/2010/06/02/case-study-refactoring-interfaces-with-tdded-tests/</link>
		<comments>http://www.codelord.net/2010/06/02/case-study-refactoring-interfaces-with-tdded-tests/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 19:48:20 +0000</pubDate>
		<dc:creator>abyx</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[clean code]]></category>
		<category><![CDATA[software craftsmanship]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://www.codelord.net/?p=190</guid>
		<description><![CDATA[I&#8217;ve been practicing TDD for a couple of years now, and keep learning all the time.
In the past year I&#8217;ve been mainly working on a single project, the longest I&#8217;ve worked on a project with TDD. Putting aside how fun it is (TDD saved me quite a few times for me to be sure it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been practicing TDD for a couple of years now, and keep learning all the time.</p>
<p>In the past year I&#8217;ve been mainly working on a single project, the longest I&#8217;ve worked on a project with TDD. Putting aside how fun it is (TDD saved me quite a few times for me to be sure it&#8217;s worthwhile), working on a project for so long I finally got to see some of the main problems people have against TDD.</p>
<p>With the hundreds of test you have, refactoring on the class-interface level (that is, the interfaces of classes, and not inside classes) can be problematic, with you having to update all the tests.</p>
<p>I&#8217;m still learning how to handle this efficiently, and would like to share an experience I had today. This is an example of a problem regarding 2 collaborators and an interface change. Such refactorings in a TDD environment weren&#8217;t mentioned in the excellent &#8220;<a href="http://www.codelord.net/2010/01/12/every-coder-should-read-tdd-by-example/">TDD by Example</a>&#8221; book and similar works, so I&#8217;m pretty much guessing here.</p>
<p>The example:<br />
<script src="http://gist.github.com/422831.js?file=before+refactoring"></script></p>
<p>The change we&#8217;re interested in is making &#8220;eject&#8221; simply open the lid, without rewinding, and making the rewind operation public. This is in order to allow LazyPerson to take the tape out, without having to wait.  Gary Bernhardt <a href="http://blog.extracheese.org/2009/10/my-personal-failures-in-test-isolation.html">wrote</a> about this kind of changes a bit. I agree, the fact I need to make such a change is against the <a href="http://en.wikipedia.org/wiki/Open/closed_principle">OCP</a>. What can I say, I&#8217;m not perfect and made a design mistake. Saying &#8220;that&#8217;s not OCP&#8221; doesn&#8217;t help me &#8211; <strong>I&#8217;ve got this code and tests, and I need to change them</strong>.</p>
<p>I used to succumb to the temptation and make all the changes in one sweep. That means changing all the tests and the classes, then running the tests and hope they still pass. This, of course, is a crappy way of doing this. Had I been able to actually perform such tasks, I&#8217;d write less tests.  The secret is <strong>baby steps</strong>. The pressure Kent Beck puts on baby steps and gradually working towards change made me consider this and force myself to find a safe way of doing this.</p>
<p>I decided to start with the VCR and its test (the AutomaticPresenter doesn&#8217;t use the VCR itself but an interface, and the tests use test doubles. This means changing one part won&#8217;t break the other&#8217;s unit tests).  The path to enlightenment lies in finding the baby step that allows starting the refactoring without breaking the rest of the tests. I decided to add a test for the should-now-be-public &#8220;rewind&#8221; operation, while not breaking the existing tests.</p>
<p>The solution is adding a default value for telling the &#8220;eject&#8221; function whether it should rewind or not. This means existing users (be them tests or not) will still get the previous behavior, and new tests can start work with the new interface (in Java I&#8217;d probably do this with method overloading): <script src="http://gist.github.com/422856.js?file=mid+refactoring"></script></p>
<p>This got me to <span style="color: #00ff00;">green</span> pretty fast. Now I can slowly remove every rewind-related assertion from the old tests and also add the &#8220;should_rewind=False&#8221; flag to them, all with quick-green cycles. And we&#8217;re done with the first half.</p>
<p>The next move is to change the AutomaticPresenter to call &#8220;rewind&#8221; before &#8220;eject&#8221;, which is now really easy to do in the tests. Once we hit green, we remove the &#8220;should_rewind&#8221; flag and be done with the refactoring. Baby steps save the day:<br />
<script src="http://gist.github.com/422862.js?file=post+refatoring"></script></p>
<p>Being able to get the refactoring working so easily makes me happy, but I&#8217;m still not sure this is the smartest way, and there are harder refactorings to master ahead. Yet, I hope this will help TDD adopters see that it&#8217;s possible to handle refactorings even with many tests, because once the right baby-step is found, each test can take practically seconds to convert.</p>
<p>I&#8217;d really love getting feedback on this cycle.</p>
<p>You should subscribe to my <a href="http://feeds.feedburner.com/TheCodeDump">RSS</a> feed or follow me on <a href="http://www.twitter.com/avivby">twitter</a>!
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F06%2F02%2Fcase-study-refactoring-interfaces-with-tdded-tests%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F06%2F02%2Fcase-study-refactoring-interfaces-with-tdded-tests%2F&amp;source=avivby&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codelord.net/2010/06/02/case-study-refactoring-interfaces-with-tdded-tests/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Stop Apologizing for Your Code</title>
		<link>http://www.codelord.net/2010/05/13/stop-apologizing-for-your-code/</link>
		<comments>http://www.codelord.net/2010/05/13/stop-apologizing-for-your-code/#comments</comments>
		<pubDate>Thu, 13 May 2010 18:13:14 +0000</pubDate>
		<dc:creator>abyx</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.codelord.net/?p=179</guid>
		<description><![CDATA[Have a habit of apologizing for your code before showing it to someone else? You&#8217;re doing it wrong.
I&#8217;ve been the only TDDer in my team for about a year now. When I just joined the team, my TDD ways were looked at as a weird fad. Nevertheless, I kept working in my ways, know that, [...]]]></description>
			<content:encoded><![CDATA[<p>Have a habit of apologizing for your code before showing it to someone else? <em>You&#8217;re doing it wrong.</em></p>
<p>I&#8217;ve been the only TDDer in my team for about a year now. When I just joined the team, my <a href="http://www.codelord.net/2010/01/12/every-coder-should-read-tdd-by-example/">TDD</a> ways were looked at as a weird fad. Nevertheless, I kept working in my ways, know that, at least for me, it works best.</p>
<p>Working like that can be very frustrating. You make sure your code is clean, well tested and refactored. Then comes along someone that makes a small change and your tests no longer cover that part of the code. You open up some other part of the system, see bad code and though you try to follow the <a href="http://bit.ly/ba2Dvt">boy-scout rule</a>, you can&#8217;t because you&#8217;d need to harness 10 computers and a goat to test the code in its current state.</p>
<p>A few months ago I asked Uncle Bob what is a programmer to do in such a situation. <a href="http://bit.ly/aWGu3s">His</a> <a href="http://bit.ly/9Yhxhj">response</a>:</p>
<blockquote><p>It&#8217;s frustrating and difficult. But what choice do you have? All you can do is keep at it. Shame the others by keeping to your disciplines.</p></blockquote>
<p>And boy was he right. As months passed, and people glancing over saw me running hundreds of tests in a second and being able to make quick changes without fear (or very little), I noticed a weird pattern.</p>
<p>Whenever people asked me to lend them a hand with a piece of code, the presentation of the code started with a disclaimer: &#8220;<em>Never mind how ugly it is</em>&#8220;, and <em>&#8220;I know it looks bad&#8221;</em>.</p>
<p>At first, my ego always happy to boast, I took it as a compliment. Later, it dawned on me that it&#8217;s not that my code looks like pure prose simply because it&#8217;s TDDed.</p>
<p>What that apologizing means is &#8220;<strong><em>I&#8217;m sorry I don&#8217;t care about the code as much you do</em><span style="font-weight: normal;">&#8220;. Uncle Bob was right, people were actually <em>ashamed</em>. Sounds weird right? But then again, if you do care, why haven&#8217;t you removed the need to apologize after the second time? </span></strong></p>
<p><strong><span style="font-weight: normal;">Get out of this shame-phase. Being ashamed means you care, do something with it. The next step is simply making the code cleaner. Some of my team-mates have already started down the enlightened path. </span></strong></p>
<p><strong><span style="font-weight: normal;">Remember, coding is a social activity. When you disrespect the code, you disrespect your friends. When you <em>rock on</em>, you <em>all</em> enjoy. As a wise man <a href="http://bit.ly/aLE5dp">said</a>, keep working on your code till <strong><em>you’re ready to project the code onto the wall for the whole team to see.</em></strong></span></strong></p>
<p><strong><span style="font-weight: normal;">And if you&#8217;re in my shoes, keep it up. <a href="http://www.codelord.net/2009/04/04/sometimes-all-it-takes-is-a-little-push/">Sometimes all it takes is a little push</a>.</span></strong></p>
<p><strong><span style="font-weight: normal;">You should subscribe to my <a href="http://feeds.feedburner.com/TheCodeDump">feed</a> and follow me on <a href="http://twitter.com/avivby">twitter</a>!</span></strong>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F05%2F13%2Fstop-apologizing-for-your-code%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F05%2F13%2Fstop-apologizing-for-your-code%2F&amp;source=avivby&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codelord.net/2010/05/13/stop-apologizing-for-your-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Notes From the (First?) Israeli Code Retreat</title>
		<link>http://www.codelord.net/2010/05/10/notes-from-the-first-israeli-code-retreat/</link>
		<comments>http://www.codelord.net/2010/05/10/notes-from-the-first-israeli-code-retreat/#comments</comments>
		<pubDate>Mon, 10 May 2010 16:12:52 +0000</pubDate>
		<dc:creator>abyx</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[software craftsmanship]]></category>

		<guid isPermaLink="false">http://www.codelord.net/?p=173</guid>
		<description><![CDATA[Today I had the honor of running a Code Retreat right here in our little country.
A Code Retreat is a concept that was born in the beginning of 2009. It&#8217;s a day that consists of a bunch of programmers working in pairs about a problem &#8211; a session is 40 minutes long and after each [...]]]></description>
			<content:encoded><![CDATA[<p>Today I had the honor of running a Code Retreat right here in our little country.</p>
<p>A <a href="http://www.coderetreat.com/">Code Retreat</a> is a concept that was born in the beginning of 2009. It&#8217;s a day that consists of a bunch of programmers working in pairs about a problem &#8211; a session is 40 minutes long and after each pairs rotate and the start from scratch.</p>
<p>This code retreat was a bit special. It wasn&#8217;t a public one. My previous employer liked the concept and I was asked to help with running one for some of their coders. The group consisted of 15 coders that are in the company at least 2 years.</p>
<p>Most of the people don&#8217;t pair at work and none TDD (only some unit test). Because of this we&#8217;ve decided before starting not to make TDD a must, but introduce it and encourage trying it out.</p>
<p>One of the things that surprised me was that after 3 sessions, some people asked if it was possible to get a different exercise. I haven&#8217;t heard of a code retreat with more than 1 exercise and I&#8217;m puzzled why this team has brought this up. Currently, my only guess is that the Israeli temper and to-the-point attitude (&#8220;Dugri&#8221; or &#8220;Takhles&#8221; in Hebrew)  caused it (even though there were many wicked implementation ideas running around). I&#8217;m still not sure giving them another option was a good thing, as I believe squeezing more ideas from one exercise is where things get really interesting (and some preferred staying with the original one).</p>
<p>Another point was that some people said they would have appreciated more structure/direction &#8211; what to do in each session and getting a list of implementation ideas for Game of Life.</p>
<p>We were also asked for longer sessions &#8211; 40 minutes felt like too little and our single 50 minutes session felt more like it.</p>
<p>A bit unsurprisingly, when we performed the <a href="http://bit.ly/aSwMdV">String Calculator Kata</a> to demonstrate some TDD, most people thought this was going overboard with tests for such a simple thing. I hope some got the message and I think that the fact we actually had bugs caught instantly by the tests helped!</p>
<p>To sum it up, I think that all-in-all people had a good time. I practically had to pull some from the keyboard at the end of sessions. Can&#8217;t wait for the next one! I&#8217;m thinking of getting a bunch of <a href="http://bit.ly/aPug4e">Clean Code wrist bands</a> to give away.</p>
<p>For future reference, here&#8217;s the list of <a href="http://bit.ly/cePVyl">Game of Life</a> ideas people have tried:</p>
<ul>
<li>Cell centered</li>
<li>Board/Universe centered</li>
<li>if-less (as possible)</li>
<li>Uber-threaded (each cell is a thread)</li>
<li>Performance-centered (board is a byte array)</li>
<li>Focus on the neighboring-connection (the &#8220;lines&#8221; between cells)</li>
<li>Implement in a few different languages and their idioms (we had Java, Python and some C)</li>
<li>Different topologies (hive-like and 3D)</li>
<li>Calculate results by hashing certain parts of the universe and the expected results for them</li>
</ul>
<p>And, the second problem that was given is the Poker Hands Kata:</p>
<ul>
<li>Go through the cards and seek the best hand</li>
<li>After each card is added to the hand, hand-types that are no more possible are removed</li>
<li>Encode the hand as a 64bit number, and then find better hand by subtracting the numbers</li>
</ul>
<p>You should subscribe to my <a href="http://feeds.feedburner.com/TheCodeDump">feed</a> and follow me on <a href="http://twitter.com/avivby">twitter</a>!
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F05%2F10%2Fnotes-from-the-first-israeli-code-retreat%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F05%2F10%2Fnotes-from-the-first-israeli-code-retreat%2F&amp;source=avivby&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codelord.net/2010/05/10/notes-from-the-first-israeli-code-retreat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Case Study: Single Responsibility Principle Violation</title>
		<link>http://www.codelord.net/2010/05/09/case-study-single-responsibility-principle-violation/</link>
		<comments>http://www.codelord.net/2010/05/09/case-study-single-responsibility-principle-violation/#comments</comments>
		<pubDate>Sun, 09 May 2010 18:15:25 +0000</pubDate>
		<dc:creator>abyx</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[clean code]]></category>
		<category><![CDATA[software craftsmanship]]></category>

		<guid isPermaLink="false">http://www.codelord.net/?p=159</guid>
		<description><![CDATA[Having recently finished the amazing PPP book (more here) my code-sense is getting better in putting the finger on the smells in code that make it painful for me to use. This is the story of one of them, in Buildbot.
Disclaimer: Buildbot is a pretty awesome building/continuous integration system that I use and contribute code [...]]]></description>
			<content:encoded><![CDATA[<p>Having recently finished the amazing PPP book (more <a href="http://www.codelord.net/2010/05/02/agile-software-development-you-will-never-code-the-same-again/">here</a>) my code-sense is getting better in putting the finger on the smells in code that make it painful for me to use. This is the story of one of them, in <a href="http://buildbot.net/">Buildbot</a>.</p>
<p>Disclaimer: Buildbot is a pretty awesome building/continuous integration system that I use and contribute code to regularly. Indeed, it is far from perfect, but none of the coders should take offense.</p>
<p>So, what is the Single Responsibility Principle (<a href="http://bit.ly/bs003B">SRP</a>) ?</p>
<blockquote><p><strong>A class should have one, and only one, reason to change.</strong></p>
<div id="_mcePaste">If a class has more than one responsibility, then the responsibilities become coupled. Changes to one responsibility may impair or inhibit the class’ ability to meet the others. This kind of coupling leads to fragile designs that break in unexpected ways when changed.</div>
</blockquote>
<div>And now, to the gory details. Buildbot has a built-in class for executing shell commands, called <em>ShellCommand</em>. Now let&#8217;s say we want to create a class, <em>VerboseCommand</em> that always executes commands with the &#8216;<em>-v</em>&#8216; flag. One would assume this is the right way to do it:</div>
<p><script src="http://gist.github.com/395295.js"></script> But this turns out to be wrong. Say we tried to execute &#8216;<em>nosetests</em>&#8216;, the actual command that will be executed is &#8216;<em>nosetests -v -v</em>&#8216; (which is harmless, but you might have guessed my real use-case wasn&#8217;t adding the &#8216;<em>-v</em>&#8216; flag).  The reason is, as the <a href="http://djmitche.github.com/buildbot/docs/0.7.12/#Writing-BuildStep-Constructors">Buildbot manual</a> will happily tell you, that <strong>every step is also its own factory</strong>.</p>
<p>Wait, what? Given the fact the a certain step will need to be run in multiple builds on multiple slaves, a new one needs to be created every time. But, as a user you only instantiate the step once. Turns out that behind the scenes, Buildbot will save the arguments given to the command&#8217;s constructor and call it with them again every time it needs a new instance.</p>
<p>This means that in our case, we must find a way to tell in the constructor whether we&#8217;re instantiating the factory or being instantiated by the factory, and add the flag only in one case but not both. My cute example turns to this mess:  <script src="http://gist.github.com/395302.js"></script></p>
<p>(If you&#8217;re really bothered with understanding every detail, read the <a href="http://djmitche.github.com/buildbot/docs/0.7.12/#Writing-BuildStep-Constructors">manual</a>, but I&#8217;m sure you can get the gist of it without doing so.)</p>
<p>Now, if you&#8217;re anything like me, you&#8217;re looking at this and wondering something along the lines of &#8220;<em>what the hell were they thinking?</em>&#8220;. That feeling, that tingling in your code-sense, is the smell of an SRP violation.</p>
<p>Because this class has to also act as its own constructor, the coupling between the two actions is high, and as the definition clearly states, the class now has 2 reasons to change.</p>
<p>Surely, separating this to 2 different classes (the actual step and a factory) will have solved this problem elegantly. Given that this might be considered &#8220;advanced&#8221; usage I&#8217;m willing to accept that creating a factory will be <em>optional</em>. But really people, this <em>addFactoryArguments</em> screams <em>HACK</em>.</p>
<p>If you liked this post, you&#8217;ll definitely want to read the <a href="http://www.codelord.net/2010/05/02/agile-software-development-you-will-never-code-the-same-again/">PPP book</a>.</p>
<p>You should subscribe to my <a href="http://feeds.feedburner.com/TheCodeDump">feed</a> and follow me on <a href="http://twitter.com/avivby">twitter</a>!
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F05%2F09%2Fcase-study-single-responsibility-principle-violation%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F05%2F09%2Fcase-study-single-responsibility-principle-violation%2F&amp;source=avivby&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codelord.net/2010/05/09/case-study-single-responsibility-principle-violation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python (nose) Test Coverage on Buildbot</title>
		<link>http://www.codelord.net/2010/05/09/python-nose-test-coverage-on-buildbot/</link>
		<comments>http://www.codelord.net/2010/05/09/python-nose-test-coverage-on-buildbot/#comments</comments>
		<pubDate>Sun, 09 May 2010 17:03:07 +0000</pubDate>
		<dc:creator>abyx</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[buildbot]]></category>
		<category><![CDATA[nose]]></category>

		<guid isPermaLink="false">http://www.codelord.net/?p=155</guid>
		<description><![CDATA[Once we got our builds happily running on Buildbot, there&#8217;s really no reason not to add coverage since it&#8217;s so easy (especially if you get bragging rights over your non-TDDers teammates).
All you have to do is this (code is based on this blog post, with adaptations to work on slaves that don&#8217;t share directories with [...]]]></description>
			<content:encoded><![CDATA[<p>Once we got our builds happily running on Buildbot, there&#8217;s really no reason not to add coverage since it&#8217;s so easy (especially if you get bragging rights over your non-TDDers teammates).</p>
<p>All you have to do is this (code is based on this <a href="http://copypasteprogrammer.blogspot.com/2010/03/buildbot-and-nose-test-coverage.html">blog post</a>, with adaptations to work on slaves that don&#8217;t share directories with the master, since the createSummary method runs on the master):</p>
<p><script src="http://gist.github.com/395269.js"></script>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F05%2F09%2Fpython-nose-test-coverage-on-buildbot%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F05%2F09%2Fpython-nose-test-coverage-on-buildbot%2F&amp;source=avivby&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codelord.net/2010/05/09/python-nose-test-coverage-on-buildbot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Agile Software Development: You Will Never Code The Same Again</title>
		<link>http://www.codelord.net/2010/05/02/agile-software-development-you-will-never-code-the-same-again/</link>
		<comments>http://www.codelord.net/2010/05/02/agile-software-development-you-will-never-code-the-same-again/#comments</comments>
		<pubDate>Sun, 02 May 2010 18:30:17 +0000</pubDate>
		<dc:creator>abyx</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[software craftsmanship]]></category>

		<guid isPermaLink="false">http://www.codelord.net/?p=148</guid>
		<description><![CDATA[How often do you get to work along some coding superstar that&#8217;s been at it for decades? If you&#8217;re anything like me, the answer is &#8220;never&#8221;. That&#8217;s why I&#8217;ve recently decided to go after books that are aimed to fill this gap exactly. The latest is &#8220;Agile Software Development: Principles, Patterns, and Practices&#8221; by the [...]]]></description>
			<content:encoded><![CDATA[<p>How often do you get to work along some coding superstar that&#8217;s been at it for decades? If you&#8217;re anything like me, the answer is &#8220;never&#8221;. That&#8217;s why I&#8217;ve recently decided to go after books that are aimed to fill this gap exactly. The latest is <a href="http://www.amazon.com/gp/product/0135974445?ie=UTF8&amp;tag=thcodu02-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0135974445">&#8220;Agile Software Development: Principles, Patterns, and Practices&#8221;</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=thcodu02-20&amp;l=as2&amp;o=1&amp;a=0135974445" border="0" alt="" width="1" height="1" /> by the one and only, <a href="http://bit.ly/c9CPQn">Uncle Bob</a> (the previous is <a href="http://www.codelord.net/2010/01/12/every-coder-should-read-tdd-by-example/">&#8220;TDD by example&#8221;</a>, which gets 5 stars from me too).</p>
<h6>It&#8217;s like coding with the Uncle himself</h6>
<p>The thing I liked the most about the book, is the way it walks through (relatively) huge amounts of code. Uncle Bob shows several programming problems and walks through his design process and the implementation of the interesting parts. Reading it (even though it was written almost a decade ago) you can&#8217;t miss the fact the author has so much experience. Whenever I tried coding a solution myself before reading on, I later found out exactly where I went wrong because he somehow managed to cover every decision I made.</p>
<p>When I say it&#8217;s like coding with him, I really mean it. I don&#8217;t know how, but whenever I looked at a code sample I didn&#8217;t like for some reason, I was astonished to read &#8220;You may be wondering why I did X&#8221; the next paragraph. And, maybe less fun, is when I read something, totally agreed with it, and he went on to explain why it sucks.</p>
<p>The feeling throughout reading the book is that you get to pair with one of the best software craftsmen ever.</p>
<h6>You get experience in every paragraph</h6>
<p>A big part of the book is dedicated to talking about XP and design patterns. I&#8217;ve read several books about both and yet I didn&#8217;t find those parts in the book redundant. The reason is because Uncle Bob has managed to put a few grains of experience into whatever he talked about. Even though I&#8217;ve coded my fair share of Factories, he made me realize a few interesting concepts about them. And although I&#8217;ve done Visitors, I suddenly am a bit in love with them (which means I have to fight myself extra-hard not to introduce them everywhere).</p>
<p>If you don&#8217;t have people around you that care about coding a lot (enough to send out awesome <a href="http://bit.ly/aPug4e">Clean Code wristbands</a>, one of which I own) you&#8217;ll quickly grasp what I&#8217;m talking about. The whole writing is of an experienced mentor (which might explain why his company is called &#8220;Object Mentor&#8221;).</p>
<h6>It simply changes the way you look at coding</h6>
<p>Having gone through the <a href="http://bit.ly/bs003B">SOLID principles</a>, my whole designing process and way of thinking has changed. I can&#8217;t think of a sane developer that will refuse to put his hands on a set of principles that the best coders of the past decades have deemed as necessary for quality code.</p>
<p>Do yourself a favor and get your hands on this piece of software-craftsmanship gold-mine!</p>
<p style="direction: ltr;">Stay tuned for the next part of this series, Uncle Bob&#8217;s <a href="http://www.amazon.com/gp/product/B001GSTOAM?ie=UTF8&amp;tag=thcodu02-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B001GSTOAM">Clean Code</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=thcodu02-20&amp;l=as2&amp;o=1&amp;a=B001GSTOAM" border="0" alt="" width="1" height="1" />!</p>
<p>You should <a href="http://twitter.com/avivby">follow me</a> on twitter and subscribe to my <a href="http://feeds.feedburner.com/TheCodeDump">RSS feed</a>, it&#8217;s free!
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F05%2F02%2Fagile-software-development-you-will-never-code-the-same-again%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F05%2F02%2Fagile-software-development-you-will-never-code-the-same-again%2F&amp;source=avivby&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codelord.net/2010/05/02/agile-software-development-you-will-never-code-the-same-again/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>nose doesn&#8217;t discover tests on Solaris</title>
		<link>http://www.codelord.net/2010/03/03/nose-doesnt-discover-tests-on-solaris/</link>
		<comments>http://www.codelord.net/2010/03/03/nose-doesnt-discover-tests-on-solaris/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 14:05:31 +0000</pubDate>
		<dc:creator>abyx</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[techie]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.codelord.net/?p=138</guid>
		<description><![CDATA[Note: this is a technical post, to help poor souls that google this  
When using nose on Solaris machines, simply running nosetests without specifying the file names will not work if you are the root user. To fix this, you must either not be root, or pass nose the argument --exe. That&#8217;s it.
Gory details: [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Note:</strong> this is a technical post, to help poor souls that google this <img src='http://www.codelord.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>When using <em>nose</em> on Solaris machines, simply running <em>nosetests</em> without specifying the file names will not work if you are the root user. To fix this, you must either not be root, or pass <em>nose</em> the argument <code>--exe</code>. That&#8217;s it.</p>
<p>Gory details: by default, <em>nose</em> ignores executable files. Each file it encounters it checks with <em>os.access(test_file, os.X_OK)</em> to see if it&#8217;s executable. Problem is that Solaris&#8217; <em>access</em> function always returns success for root, regardless of actual file permissions. This is discouraged by POSIX, but known behavior.</p>
<p>I hope this saves someone the 3 hours it wasted for me <img src='http://www.codelord.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F03%2F03%2Fnose-doesnt-discover-tests-on-solaris%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F03%2F03%2Fnose-doesnt-discover-tests-on-solaris%2F&amp;source=avivby&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codelord.net/2010/03/03/nose-doesnt-discover-tests-on-solaris/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Avoid the perils of coder customers</title>
		<link>http://www.codelord.net/2010/02/20/avoid-the-perils-of-coder-customers/</link>
		<comments>http://www.codelord.net/2010/02/20/avoid-the-perils-of-coder-customers/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 19:44:29 +0000</pubDate>
		<dc:creator>abyx</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.codelord.net/?p=132</guid>
		<description><![CDATA[﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿Coders are the worst customers ever. The sooner you wrap your head around that, the better. Actually, any customer that&#8217;s technical is a bad customer, but nothing trumps coders. That fact is not intuitive, or at least wasn&#8217;t for me, but it can be really painful to find it out by yourself. So here, I [...]]]></description>
			<content:encoded><![CDATA[<p>﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿Coders are the worst customers ever. The sooner you wrap your head around that, the better. Actually, any customer that&#8217;s technical is a bad customer, but nothing trumps coders. That fact is not intuitive, or at least wasn&#8217;t for me, but it can be really painful to find it out by yourself. So here, I just saved you some agony.</p>
<p>Why are coders bad customers? First, let me say that even though coder-customers are a hard group to work with, they usually have really interesting problems to solve. After all, if it was simple they&#8217;d usually do it themselves. But, being coders, they think it&#8217;s acceptable to tell you how to do your job.</p>
<p>When you work with coders, the usual ticket/email/water-cooler chat will be of the form &#8220;you need to add an option for specifying X of type Y instead of the current options&#8221;. At this point they&#8217;ll usually start telling you how to implement that and how easy it is. If you&#8217;re like me, at this point your instinct will be to crank out the code and make your customer happy. Resist that urge like the plague!</p>
<p>Whenever I receive such a ticket, I dismiss everything in it. What I do next is come up to whoever suggested it, and ask &#8220;<strong>What is it that you&#8217;re trying to do?</strong>&#8221; Usually, this will result in exactly the same technical do-this-and-that explanation. Take a deep breath and ask the question again. This will usually be enough, but sometimes may require a couple more tries. That&#8217;s how you&#8217;re supposed to gather requirements &#8211; <strong>understand the problem at hand</strong>.</p>
<p>The main advantage of being a pain-in-the-ass and making sure you understand what it is you&#8217;re supposed to implement is because every coder should know exactly what his code is doing. A lot has been said about understanding the domain you&#8217;re working in, and simply implementing things handed to you is not the way to become knowledgeable in your domain.</p>
<p>Furthermore, once you hear what people are trying to do you might think of a better way of doing it, you being fully immersed in the existing code. Actually, more often than not you&#8217;ll see it&#8217;s actually already possible to do it! And best of all, you might simply decide that&#8217;s not a fair use of your code, and reject the ticket. How could you have made such a decision without knowing the actual problem you were asked to solve? No way.</p>
<p>Saying &#8220;no&#8221; to features is one of the most important design skills to master, and a tricky one. After all, turning to your keyboard, hacking the code and saying &#8220;presto!&#8221; is more fun at first. But that way of working leads to a code-base that you don&#8217;t really know. I&#8217;ve seen systems that were driven this way by technical users. 3 years later, there were rogue database fields that no one knew why there were being updated, and weird log files in awkward formats. Whenever someone tried removing one of those he found out it broke some dusty cron-job that seemed to use it instead of doing something sane (and do I really need to mention the code was a tangled, convoluted mess?).</p>
<p>Ask why, mindfully consider and then decide. There&#8217;s no really other way, unless you&#8217;d like to meet Code Cthulhu.</p>
<p>You should follow me on <a href="http://bit.ly/aU2CaB">twitter</a>.
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F02%2F20%2Favoid-the-perils-of-coder-customers%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F02%2F20%2Favoid-the-perils-of-coder-customers%2F&amp;source=avivby&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codelord.net/2010/02/20/avoid-the-perils-of-coder-customers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Stop Coding in the Middle Ages</title>
		<link>http://www.codelord.net/2010/02/16/stop-coding-in-the-middle-ages/</link>
		<comments>http://www.codelord.net/2010/02/16/stop-coding-in-the-middle-ages/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 06:41:35 +0000</pubDate>
		<dc:creator>abyx</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.codelord.net/?p=126</guid>
		<description><![CDATA[Aren&#8217;t you sick of wasting your time, your team&#8217;s time and precious build cycles for finding the stupidest mistakes ever? I know I&#8217;m far more interested in solving the real problems at hand than chasing stupid syntax errors. And even if you don&#8217;t mind, you really shouldn&#8217;t let your teammates substitute for a decent tool.
Up [...]]]></description>
			<content:encoded><![CDATA[<p>Aren&#8217;t you sick of wasting your time, your team&#8217;s time and precious build cycles for finding the stupidest mistakes ever? I know I&#8217;m far more interested in solving the real problems at hand than chasing stupid syntax errors. And even if you don&#8217;t mind, you really shouldn&#8217;t let your teammates substitute for a decent tool.</p>
<p>Up until 15 years ago, I think it was very common for people to hack away at code for a good length of time, and once they got enough done, they&#8217;d try and compile the damn thing and start correcting the syntax errors, import things they forgot to, etc. This probably was because 15 years ago is the middle ages in computer-land, and compiling constantly was something people couldn&#8217;t even dream about on the little PCs we used to code on.</p>
<p>Nowadays, you can&#8217;t find more than a handful of static-language coders that won&#8217;t use a full featured IDE. C, Java, C# &#8211; other than a few freaky kernel hackers, I doubt anyone does real development outside an IDE in those languages. Today&#8217;s IDEs will tell you that you made a mistake about 2 seconds before you did. I never stop being amazed at how smart Eclipse is &#8211; and the first time I had to whip up some Java code in Vim, I felt handicapped.</p>
<p>What I find puzzling, is that people that are using the best available languages today, have suddenly decided that using the proper tool isn&#8217;t that important. Dynamic languages like Python and Ruby are not as easy to write awesome IDEs for, and therefore there aren&#8217;t many around that are mature enough, which is why it&#8217;s very common to see people use Emacs/Vim for coding them. Now don&#8217;t get me wrong, I&#8217;ve tried a few Python IDEs, but I&#8217;m still sticking with my Emacs. But when you use dynamic languages, you have to keep in mind you are even more prone of errors that will slip by. Even if you TDD, and your test coverage is extremely high, a typo might still get past your tests. Do you really want a production failure because you forgot to import an exception? (And do you really want to <a href="http://bit.ly/cKRZAK">upset Agnes</a>?)</p>
<p>About 2 weeks into my decision to stick with Emacs I started searching for simple tools that will protect me from my stupidity. It takes 10 minutes to find and install flymake with pyflakes (Python tool) support. Presto! No more typos in variable names, no more useless imports lying around. What surprised me is that a lot of my teammates, which I have respect for and are good programmers, did not use any of these. Time and time again our continuous integration system will report an error on a file and once I opened the file Emacs would show me the bad line marked with red, with no way of not noticing it.</p>
<p>I don&#8217;t like wasting my time, and I&#8217;m sure you don&#8217;t either. Stop being lazy (in the bad way). Stop making me angry. Get out of the middle ages. Yesterday we got everyone on my team to add pyflakes to their vim. Took 3 minutes to install. The problem is that it took more time to get them to install. &#8220;Nah, Vim already highlights syntax, there&#8217;s no need for more&#8221;. Oh really? After 10 minutes of searching I found a file that pyflakes showed a real problem in, and another, and another. &#8220;Hmmm, where do I download that plugin?&#8221; Win!</p>
<p>Do yourself, your team and your build slaves a favor, and start using some modern tools. I promise it will be worth it, money-back-guarantee. And remember, if your team is still churning butter, <a href="http://www.codelord.net/2009/04/04/sometimes-all-it-takes-is-a-little-push/">sometimes all it takes is a little push</a> (and sometimes you can plant bugs in their files).</p>
<p>You should follow me on <a href="http://bit.ly/aU2CaB">twitter</a>.
<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F02%2F16%2Fstop-coding-in-the-middle-ages%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.codelord.net%2F2010%2F02%2F16%2Fstop-coding-in-the-middle-ages%2F&amp;source=avivby&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codelord.net/2010/02/16/stop-coding-in-the-middle-ages/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
