<?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>Valtech UK &#187; Sandro Mancuso</title>
	<atom:link href="http://blog.valtech.co.uk/author/sandro/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.valtech.co.uk</link>
	<description>Aggregated works of Valtech UK consultants</description>
	<lastBuildDate>Mon, 30 Jan 2012 12:23:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Re-drawing my own map: A new milestone</title>
		<link>http://blog.valtech.co.uk/craftsmanship/re-drawing-my-own-map-a-new-milestone/</link>
		<comments>http://blog.valtech.co.uk/craftsmanship/re-drawing-my-own-map-a-new-milestone/#comments</comments>
		<pubDate>Tue, 17 May 2011 03:38:00 +0000</pubDate>
		<dc:creator>Sandro Mancuso</dc:creator>
				<category><![CDATA[Craftsmanship]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[For every step you take towards mastery, your destination moves         two steps further away. Embrace mastery as a lifelong endeavour. Learn         to love the journey.--George Leonard, MasteryIt is with a mixture of sadness and excitement that I wo...]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.valtech.co.uk%2Fcraftsmanship%2Fre-drawing-my-own-map-a-new-milestone%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://blog.valtech.co.uk/craftsmanship/re-drawing-my-own-map-a-new-milestone/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.valtech.co.uk/craftsmanship/re-drawing-my-own-map-a-new-milestone/"  data-text="Re-drawing my own map: A new milestone" data-count="horizontal" data-via="valtech">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><blockquote>
<div class="epigraph">
<div id="ch03_id2376911">For every step you take towards mastery, your destination moves two steps further away. Embrace mastery as a lifelong endeavour. Learn to love the journey.</div>
<div class="attribution" style="text-align: right;">&#8211;<span class="attribution">George Leonard, <a class="link" title="Mastery: The Keys to Success and Long-Term Fulfillment" href="http://www.amazon.co.uk/Mastery-Plume-George-Leonard/dp/0452267560/ref=sr_1_1?ie=UTF8&amp;qid=1305590628&amp;sr=8-1"><span class="emphasis"><em>Mastery</em></span></a></span></div>
</div>
</blockquote>
<p>It is with a mixture of sadness and excitement that I would like to announce that, after over five years, I&#8217;m leaving <a href="http://valtech.co.uk/">Valtech</a> on the 18th of May. The decision was not an easy one and took me months to figure out what the next step in my <a href="http://apprenticeship-patterns.labs.oreilly.com/ch03.html#the_long_road">long road</a> would be. As I said in a <a href="http://craftedsw.blogspot.com/2011/04/working-for-consultancy-companies.html">recent interview</a>, I love working for consultancy companies and that&#8217;s the main reason I spent over ten years (two-thirds of my career) working as a consultant.  </p>
<h2><strong>Working for Valtech</strong></h2>
<p>Valtech is a fantastic company to work for and had a huge impact in my personal and professional life. During my time there I had the opportunity to work on a great variety of projects, different companies, different industries and different technologies. Most importantly, I had the opportunity to meet and work with a lot of great people that helped me to become a much better professional.</p>
<p>If there is one thing that I will never complain about Valtech is that I did not have recognition for the work I&#8217;ve done. I have started at a Valtech in a relatively junior role, according to Valtech&#8217;s grade scheme, and bit by bit, with a lot of support and trust from my colleagues I was given more and more responsibility and gradually climbed my way up to one of the most senior positions. </p>
<p>There is no such a thing as a perfect company but if I had to point out the best thing about Valtech, I would say that, beyond the shadow of a doubt, it is its people. People that I learnt a lot from, that helped me to feel at home in the UK, that helped me with personal issues, people that challenged me, that pushed me to my limits, that gave me constructive criticism, that trusted me and empowered me to do my job, people that helped me to be better.</p>
<p>I may not be in the office or in a client site full time any more but I will always be around. As it happened before (I took a year off to work on a startup idea and came back) I&#8217;ll always be around for drinks and events.</p>
<h2><strong>Special Thanks</strong></h2>
<p>I would like to thank you everyone at Valtech that had to put up with me for all this time. I know I can be a pain in the neck <span style="text-decoration: line-through;">quite often</span> sometimes. <img src='http://blog.valtech.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
<p>It&#8217;s always tricky to mention names since there is always the risk of people left out feeling a bit upset but I feel that I need to thank some people in a more personal level, so apologies for the ones I did not mention. In no particular order: <a href="http://twitter.com/tobymckenzie">Toby Mckenzie</a> for caring about me and every single consultant during tough times, all his herculean effort to keep every one happy, finding us good projects; <a href="http://twitter.com/david_draper">David Draper</a> for challenging many of my beliefs and opinions, for the many advices, for supporting my involvement with user groups and events and for the effort in making Valtech a place of excellence; <a href="http://twitter.com/mashooq">Mashooq Badar</a> for the fantastic time we had together in many projects, for all the things I learnt from him and for making me open my mind about so many things. Ah, and for all the <em>Blazing hot!</em> moments; <a href="http://twitter.com/philghall">Phil Hall</a> for the support and keeping the doors open to me and <a href="http://www.meetup.com/london-software-craftsmanship">LSCC</a>; Kevin Harkin (I can&#8217;t believe he does not use twitter) for the fun we had together, for his friendship, advices, ranting sessions and memorable nights at the pub; <a href="http://twitter.com/anderew">Andrew Rendell</a> for his professionalism, trust and for being a great role model for every Valtech consultant; And last but not least, <a href="http://twitter.com/akbarzamir">Akbar Zamir</a>, for pushing me and challenging me to be better, for all the advice, trust, knowledge and help, for being a great career manager and most important of all, for being a great friend. </p>
<p>Thanks for the great five years that I spent there. It was an absolute pleasure to work with all of you and be part of this great company.</p>
<h2><strong>The Future</strong></h2>
<blockquote>
<div class="epigraph">
<div id="ch03_id2378143">It’s not just a question of conquering a summit previously unknown, but of tracing, step by step, a new pathway to it.</div>
<div class="attribution" style="text-align: right;">&#8211;<span class="attribution">Gustav Mahler, musician and composer</span></div>
</div>
</blockquote>
<p>I&#8217;m joining <a href="http://www.ubs.com/">UBS</a> as a senior developer at a director level, starting on the 23rd of May. Due to <a href="http://www.londonswcraft.com/">my involvement</a> with the software craftsmanship movement, this came as a surprise to many people, including myself, mainly because investment banks tend to be almost a hostile environment for agile and software craftsmanship initiatives. When I started <a href="http://apprenticeship-patterns.labs.oreilly.com/ch03.html#draw_your_own_map">re-drawing my own map</a>, investment banks were an avenue that I was not considering to explore.</p>
<p>As I said before, choosing my next step was not easy. I had a few things in mind that were non-negotiable: I wanted different challenges, that means, things that I haven&#8217;t done before, keep having fun and loving my job, a potential long term commitment where I would have time enough to put into practice many ideas and beliefs and most importantly, have a long term career as a software developer but with a lot of space to keep growing as a professional.</p>
<p>I was fortunate to have had many opportunities during this time but the majority of them could not satisfy all the items above. I was determined to keep doing what I had been doing throughout my entire professional life that is just to work for companies that I really want to work for, I mean, companies that would be able to offer me what I was looking for at that point in time. For me, that&#8217;s the best way to keep fuelling the passion that I have for what I do. Joining a company just because of money is and always has been totally out of question. </p>
<p>UBS came along with a very interesting proposition. They want to improve the quality of their software and recognise that agile and software craftsmanship are a great way to get there. They were interested in people with no previous investment bank experience, what is very unusual for an investment bank. They want people that can think different, that are passionate and can help them drive this transformation. I had five interviews and was very pleased to see so many people striving to be and do better.</p>
<p>As far as I understand, my main role will be to work as a hands-on developer, embedded in a team, helping to improve quality, leading by example and mentoring other developers. They also expect me to give internal talks, training, promote events, disseminate passion and promote the craftsmanship values and techniques. In the future I&#8217;ll be working with other teams in the UK and in other offices around the world. But make no mistake. I&#8217;ll have a hell of interesting and tough challenges ahead of me and I hope to live up to all their expectations.</p>
<p>Besides that, I&#8217;ll keep running the <a href="http://www.londonswcraft.com/">London Software Craftsmanship Community (LSCC)</a> alongside my friend <a href="http://twitter.com/activelylazy">David Green</a> and try my best to give something back to the wider and great community of software developers out there that some many times I benefited from.</p>
<p>Thanks everyone for being part of <a href="http://apprenticeship-patterns.labs.oreilly.com/ch03.html">long road</a> journey.</p>
<div class="blogger-post-footer"><img src="https://blogger.googleusercontent.com/tracker/8424060401701893376-1099002307899451851?l=craftedsw.blogspot.com" alt="" width="1" height="1" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.valtech.co.uk/craftsmanship/re-drawing-my-own-map-a-new-milestone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My first code retreat</title>
		<link>http://blog.valtech.co.uk/craftsmanship/my-first-code-retreat/</link>
		<comments>http://blog.valtech.co.uk/craftsmanship/my-first-code-retreat/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 00:46:00 +0000</pubDate>
		<dc:creator>Sandro Mancuso</dc:creator>
				<category><![CDATA[Craftsmanship]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Yesterday I went to my first code retreat, in Winchester UK. In the past I had been sceptical about code retreats since I had doubts if I would really learn something. However, after speaking to a few developers that had been to one before, I was total...]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.valtech.co.uk%2Fcraftsmanship%2Fmy-first-code-retreat%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://blog.valtech.co.uk/craftsmanship/my-first-code-retreat/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.valtech.co.uk/craftsmanship/my-first-code-retreat/"  data-text="My first code retreat" data-count="horizontal" data-via="valtech">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Yesterday I went to my first <a href="http://coderetreat.com/how-it-works.html">code retreat</a>, in Winchester UK. In the past I had been sceptical about code retreats since I had doubts if I would really learn something. However, after speaking to a few developers that had been to one before, I was totally convinced that I should give it a go. I thought, even if I don&#8217;t learn much, at least I&#8217;ll have a whole day of fun writing code, catching up with some friends and meeting other developers. That was more than enough for me to be convinced that it would be a great day.</p>
<p><span style="font-size: large;"><strong>Summary of the day</strong></span></p>
<p>There were around 20+ developers. After introductions and explanation of the problem (<a href="http://en.wikipedia.org/wiki/Conway's_game_of_life">Conway&#8217;s game of life</a>), we started our first session. Throughout the day, we had 6 or 7 sessions. I can&#8217;t even remember exactly because it was so enjoyable, intense and fun that even if it had been 20 I wouldn&#8217;t have noticed.  I&#8217;ve paired with some people that I knew before (although never worked with) and some people that I had just met. After each session, we shared what we have learned, approaches we took, problems we faced, etc. If I recollect well, different languages were used and tried including Java, C#, JavaScript, Ruby, Scala and I think Python as well (I&#8217;m sure I&#8217;m forgetting something).</p>
<p>The first two sessions we just sat down and tried to solve it, without any constraints, besides TDD, that was mandatory for all sessions. This was good so everyone could get familiar with the problem. From the third session onwards, we were asked to try different approaches, like not using if statements, <a href="http://gojko.net/2009/02/27/thought-provoking-tdd-exercise-at-the-software-craftsmanship-conference/">TDD as if you meant it</a>, OOP to the extreme and the best code we could possibly write. At the end of each session, the code is deleted.</p>
<p>We had a good break for lunch and went to the local pub in the evening.</p>
<p><span style="font-size: large;"><strong>Things I learned and experienced</strong></span></p>
<ul>
<li>No matter how much you <em>think</em> you know, it is still not much and not enough.</li>
<li> Pair-programming with other developers exposes you to different ways of thinking and opens your mind for new ideas.</li>
<li>Seeing and using different languages, makes you see software development with different eyes, giving you a much broader understanding and helps clearing up misconceptions you may have.</li>
<li>You are not alone. Like yourself, there more talented and passionate developers out there willing to share ideas and learn from each other.</li>
<li>I definitely learned a lot and feel I got back from there a better developer.</li>
<li>Besides all the technical learning, it was really great to meet so many talented developers.</li>
</ul>
<p><span style="font-size: large;"><strong>Thank you</strong></span></p>
<p>Firstly I would like to thank <a href="http://twitter.com/despo">Despo</a> and <a href="http://twitter.com/sermoa">Aimee</a> for organising it and <a href="http://twitter.com/ecomba">Enrique</a> for running it (and the great chat in the pub). I also would like to thank all the developers that I paired with for helping to make me a better developer. Finally, I would like to thank all the developers that were there for reinforcing my belief that software development is a great profession, full of talented, bright and passionate people and that we can really make a difference in moving our industry forward.</p>
<p>I wish you all have a great <a href="http://blog.nexwerk.com/2011/02/16/the-long-road/">long road</a> ahead of you and I&#8217;m looking forward to meeting you again any time soon.</p>
<p><span style="font-size: large;"><strong>Links</strong></span></p>
<p><ul>
<li><a href="http://coderetreat.ning.com/events/coderetreat-winchester-uk-1">Official site for the Winchester Code Retreat</a></li>
<li><a href="http://www.meetup.com/london-software-craftsmanship/">London Software Craftsmanship Community &#8211; LSCC</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.valtech.co.uk/craftsmanship/my-first-code-retreat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Readable Tests: Separating intent from implementation</title>
		<link>http://blog.valtech.co.uk/craftsmanship/readable-tests-separating-intent-from-implementation/</link>
		<comments>http://blog.valtech.co.uk/craftsmanship/readable-tests-separating-intent-from-implementation/#comments</comments>
		<pubDate>Fri, 10 Dec 2010 00:41:00 +0000</pubDate>
		<dc:creator>Sandro Mancuso</dc:creator>
				<category><![CDATA[Craftsmanship]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[DSL]]></category>
		<category><![CDATA[fluent]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Very recently, I was working on a test class like this:public class AnalyticsExpirationDateManagerTest extends TestCase { private static final long ONE_HOUR_TIMEOUT = 1000 * 60 * 60; private static final long TWO_HOUR_TIMEOUT = ONE_HOUR_TIMEOUT * 2;  p...]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.valtech.co.uk%2Fcraftsmanship%2Freadable-tests-separating-intent-from-implementation%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://blog.valtech.co.uk/craftsmanship/readable-tests-separating-intent-from-implementation/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.valtech.co.uk/craftsmanship/readable-tests-separating-intent-from-implementation/"  data-text="Readable Tests: Separating intent from implementation" data-count="horizontal" data-via="valtech">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>
This article is packed full of code examples. For this reason it does not render nicely on our front page. To read the article please follow the link below.</p>
<p>
<span id="more-410"></span></p>
<p>Very recently, I was working on a test class like this:</p>
<pre class="brush:java">public class AnalyticsExpirationDateManagerTest extends TestCase {

 private static final long ONE_HOUR_TIMEOUT = 1000 * 60 * 60; private static final long TWO_HOUR_TIMEOUT = ONE_HOUR_TIMEOUT * 2;

 private Map&lt;Parameter, Long&gt; analyticsToTimeout; private long defaultTimeout;

 private Parameter minTimeoutParam; @Mock private CacheKeyImpl&lt;Parameter&gt; cacheKey;

    @Override    protected void setUp() throws Exception {     MockitoAnnotations.initMocks(this);

     this.minTimeoutParam = new Parameter("minTimeout", "type");

     when(cacheKey.getFirstKey()).thenReturn(minTimeoutParam);

     this.analyticsToTimeout = new HashMap&lt;Parameter, Long&gt;();     this.defaultTimeout = 0;    }

 public void testGetExpirationDateWhenAnalyticsToTimeoutsAndCacheKeyAreEmpty() {  AnalyticsExpirationDateManager&lt;Long&gt; manager =     new AnalyticsExpirationDateManager&lt;Long&gt;(analyticsToTimeout, defaultTimeout);  Date date = manager.getExpirationDate(cacheKey, 0L);  assertNotNull(date); }

 public void  testGetExpirationDateWithMinimunTimeoutOfOneHour() {  this.analyticsToTimeout.put(this.minTimeoutParam, ONE_HOUR_TIMEOUT);  Collection&lt;Parameter&gt; cacheKeysWithMinTimeoutParam = new ArrayList&lt;Parameter&gt;();  cacheKeysWithMinTimeoutParam.add(this.minTimeoutParam);  when(this.cacheKey.getKeys()).thenReturn(cacheKeysWithMinTimeoutParam);

  AnalyticsExpirationDateManager&lt;Long&gt; manager =    new AnalyticsExpirationDateManager&lt;Long&gt;(analyticsToTimeout, defaultTimeout);  Date date = manager.getExpirationDate(cacheKey, 0L);

  assertNotNull(date);  Calendar expirationDate = Calendar.getInstance();  expirationDate.setTime(date);

  Calendar currentDate = Calendar.getInstance();

  // Check if expiration date is one hour ahead current date.   int expirationDateHour = expirationDate.get(Calendar.HOUR_OF_DAY);  int currentDateHour = currentDate.get(Calendar.HOUR_OF_DAY);  assertTrue(expirationDateHour - currentDateHour == 1); }

 public void  testGetExpirationDateWhenCacheKeyIsNullAndDefaultTimeoutIsOneHour() {  CacheKeyImpl&lt;Parameter&gt; NULL_CACHEKEY = null;  AnalyticsExpirationDateManager&lt;Long&gt; manager =    new AnalyticsExpirationDateManager&lt;Long&gt;(analyticsToTimeout, ONE_HOUR_TIMEOUT);  Date date = manager.getExpirationDate(NULL_CACHEKEY, 0L);

  assertNotNull(date);  Calendar expirationDate = Calendar.getInstance();  expirationDate.setTime(date);

  Calendar currentDate = Calendar.getInstance();

  // Check if expiration date hour is the same of current date hour.  // When cache key is null, system date and time is returned and default timeout is not used.  int expirationDateHour = expirationDate.get(Calendar.HOUR_OF_DAY);  int currentDateHour = currentDate.get(Calendar.HOUR_OF_DAY);  assertTrue(expirationDateHour - currentDateHour == 0); }

 public void  testGetExpirationDateWithDefaultTimeout() {  // Default timeout is used when no time out is specified.  Collection&lt;Parameter&gt; cacheKeysWithoutTimeoutParam = new ArrayList&lt;Parameter&gt;();  cacheKeysWithoutTimeoutParam.add(new Parameter("name", "type"));  when(this.cacheKey.getKeys()).thenReturn(cacheKeysWithoutTimeoutParam);

  AnalyticsExpirationDateManager&lt;Long&gt; manager =    new AnalyticsExpirationDateManager&lt;Long&gt;(analyticsToTimeout, ONE_HOUR_TIMEOUT);  Date date = manager.getExpirationDate(cacheKey, 0L);

  assertNotNull(date);  Calendar expirationDate = Calendar.getInstance();  expirationDate.setTime(date);

  Calendar currentDate = Calendar.getInstance();

  // Check if expiration date is one hour ahead current date.   int expirationDateHour = expirationDate.get(Calendar.HOUR_OF_DAY);  int currentDateHour = currentDate.get(Calendar.HOUR_OF_DAY);  assertTrue(expirationDateHour - currentDateHour == 1); }

 public void  testGetExpirationDateWhenMinTimeoutIsSetAfterCreation() {  AnalyticsExpirationDateManager&lt;Long&gt; manager =    new AnalyticsExpirationDateManager&lt;Long&gt;(analyticsToTimeout, ONE_HOUR_TIMEOUT);  manager.setExpirationTimeout(this.minTimeoutParam.getName(), TWO_HOUR_TIMEOUT);

  Date date = manager.getExpirationDate(cacheKey, 0L);

  assertNotNull(date);  Calendar expirationDate = Calendar.getInstance();  expirationDate.setTime(date);

  Calendar currentDate = Calendar.getInstance();

  // Check if expiration date is two hour ahead current date.   int expirationDateHour = expirationDate.get(Calendar.HOUR_OF_DAY);  int currentDateHour = currentDate.get(Calendar.HOUR_OF_DAY);  assertTrue("Error", expirationDateHour - currentDateHour == 2); }

}</pre>
<p>Quite frightening, isn&#8217;t it? Very difficult to understand what&#8217;s going on there.</p>
<p>The class above covers 100% of the class under test and all the tests are valid tests, in terms of what is being tested.</p>
<p><span style="font-size: large;"><strong>Problems</strong></span></p>
<p>There are quite a few problems here:<br />
- The intent (what) and implementation (how) are mixed, making the tests very hard to read;<br />
- There is quite a lot of duplication among the test methods;<br />
- There is also a bug in the test methods when comparing dates, trying to figure out how many hours one date is ahead of the other. When running these tests in the middle of the day, they work fine. If running them between 22:00hs and 00:00hs, they break. The reason is that the hour calculation does not take into consideration the day.</p>
<p><span style="font-size: large;"><strong>Making the tests more readable</strong></span></p>
<p>Besides testing the software, tests should also be seen as documentation, where business rules are clearly specified. Since the tests here are quite messy, understanding the intention and detecting bugs can be quite difficult.</p>
<p>I&#8217;ve done quite a few refactorings to this code in order to make it more readable, always working in small steps and constantly re-running the tests after each change. I&#8217;ll try to summarise my steps for clarity and brevity.</p>
<p><strong>1. Fixing the hour calculation bug</strong></p>
<p>One of the first things that I had to do was to fix the hour calculation bug. In order to fix the bug across all test methods, I decided to extract the hour calculation into a separate class, removing all the duplication from the test methods. Using small steps, I took the opportunity to construct this new class called <em>DateComparator</em> (yes, I know I suck naming classes) using some internal Domain Specific Language (DSL) techniques.</p>
<pre class="brush: java">public class DateComparator {

 private Date origin; private Date target; private long milliseconds; private long unitsOfTime;

 private DateComparator(Date origin) {  this.origin = origin; }

 public static DateComparator date(Date origin) {  return new DateComparator(origin); }

 public DateComparator is(long unitsOfTime) {  this.unitsOfTime = unitsOfTime;  return this; }

 public DateComparator hoursAhead() {  this.milliseconds = unitsOfTime * 60 * 60 * 1000;  return this; }

 public static long hours(int hours) {  return hoursInMillis(hours); }

 private static long hoursInMillis(int hours) {  return hours * 60 * 60 * 1000; }

 public boolean from(Date date) {  this.target = date;  return this.checkDifference(); }

 private boolean checkDifference() {  return (origin.getTime() - target.getTime() &gt;= this.milliseconds); }}</pre>
<p>So now, I can use it to replace the test logic in the test methods.</p>
<p><strong>2. Extracting details into a super class</strong></p>
<p>This step may seem a bit controversial at first, but can be an interesting approach for separating the <em>what</em> from <em>how</em>. The idea is to move tests set up, field declarations, initialisation logic, everything that is related to the test implementation (<em>how</em>) to a super class, leaving the test class just with the test methods (<em>what</em>).</p>
<p>Although this many not be a good OO application of the IS-A rule, I think this is a good compromise in order to achieve better readability in the test class.</p>
<p>NOTE: Logic can be moved to a super class, external classes (helpers, builders, etc) or both.</p>
<p>Here is the super class code:</p>
<pre class="brush: java">public abstract class BaseTestForAnalyticsExperationDateManager extends TestCase {

 protected Parameter minTimeoutParam; @Mock protected CacheKeyImpl&lt;Parameter&gt; cacheKey; protected Date systemDate; protected CacheKeyImpl&lt;Parameter&gt; NULL_CACHEKEY = null; protected AnalyticsExpirationDateManager&lt;Long&gt; manager;

 @Override protected void setUp() throws Exception {  MockitoAnnotations.initMocks(this);  this.minTimeoutParam = new Parameter("minTimeout", "type");  when(cacheKey.getFirstKey()).thenReturn(minTimeoutParam);  this.systemDate = new Date(); }

 protected void assertThat(boolean condition) {  assertTrue(condition); }

 protected void addMinimunTimeoutToCache() {  this.configureCacheResponse(this.minTimeoutParam); }

 protected void doNotIncludeMinimunTimeoutInCache() {  this.configureCacheResponse(new Parameter("name", "type")); }

 private void configureCacheResponse(Parameter parameter) {  Collection&lt;Parameter&gt; cacheKeysWithMinTimeoutParam = new ArrayList&lt;Parameter&gt;();  cacheKeysWithMinTimeoutParam.add(parameter);  when(this.cacheKey.getKeys()).thenReturn(cacheKeysWithMinTimeoutParam); }}</pre>
<p><strong>3. Move creation and configuration of the object under test to a builder class</strong></p>
<p>The construction and configuration of the <em>AnalyticsExpirationDateManager</em> is quite verbose and adds a lot of noise to the test. Once again I&#8217;ll be using a builder class in order to make the code more readable and segregate responsibilities. Here is the builder class:</p>
<pre class="brush: java">public class AnalyticsExpirationDateManagerBuilder {

 protected static final long ONE_HOUR = 1000 * 60 * 60;

 protected Parameter minTimeoutParam; private AnalyticsExpirationDateManager&lt;Long&gt; manager; private Map&lt;Parameter, Long&gt; analyticsToTimeouts = new HashMap&lt;Parameter, Long&gt;(); protected long defaultTimeout = 0; private Long expirationTimeout; private Long minimunTimeout;

 private AnalyticsExpirationDateManagerBuilder() {  this.minTimeoutParam = new Parameter("minTimeout", "type"); }

 public static AnalyticsExpirationDateManagerBuilder aExpirationDateManager() {  return new AnalyticsExpirationDateManagerBuilder(); }

 public static long hours(int quantity) {  return quantity * ONE_HOUR; }

 public AnalyticsExpirationDateManagerBuilder withDefaultTimeout(long milliseconds) {  this.defaultTimeout = milliseconds;  return this; }

 public AnalyticsExpirationDateManagerBuilder withExpirationTimeout(long milliseconds) {  this.expirationTimeout = new Long(milliseconds);  return this; }

 public AnalyticsExpirationDateManagerBuilder withMinimunTimeout(long milliseconds) {  this.minimunTimeout = new Long(milliseconds);  return this; }

 public AnalyticsExpirationDateManager&lt;Long&gt; build() {  if (this.minimunTimeout != null) {   analyticsToTimeouts.put(minTimeoutParam, minimunTimeout);  }  this.manager = new AnalyticsExpirationDateManager(analyticsToTimeouts, defaultTimeout);  if (this.expirationTimeout != null) {   this.manager.setExpirationTimeout(minTimeoutParam.getName(), expirationTimeout);  }  return this.manager; }

}</pre>
<p><strong>The final version of the test class </strong></p>
<p>After many small steps, that&#8217;s how the test class looks like. I took the opportunity to rename the test methods as well.</p>
<pre class="brush: java">import static com.mycompany.AnalyticsExpirationDateManagerBuilder.*;import static com.mycompany.DateComparator.*;

public class AnalyticsExpirationDateManagerTest extends BaseTestForAnalyticsExperationDateManager {

 public void testExpirationTimeWithJustDefaultValues() {  manager = aExpirationDateManager().build();  Date cacheExpiration = manager.getExpirationDate(cacheKey, 0L);  assertThat(dateOf(cacheExpiration).is(0).hoursAhead().from(systemDate)); }

 public void  testExpirationTimeWithMinimunTimeoutOfOneHour() {     addMinimunTimeoutToCache();    manager = aExpirationDateManager()      .withMinimunTimeout(hours(1))      .build();  Date cacheExpiration = manager.getExpirationDate(cacheKey, 0L);  assertThat(dateOf(cacheExpiration).is(1).hoursAhead().from(systemDate)); }

 public void  testExpirationTimeWhenCacheKeyIsNullAndDefaultTimeoutIsOneHour() {  manager = aExpirationDateManager()      .withDefaultTimeout(hours(1))      .build();  Date cacheExpiration = manager.getExpirationDate(NULL_CACHEKEY, 0L);  // When cache key is null, system date and time is returned and default timeout is not used.  assertThat(dateOf(cacheExpiration).is(0).hoursAhead().from(systemDate)); }

 public void  testExpirationTimeWithDefaultTimeout() {  doNotIncludeMinimunTimeoutInCache();  manager = aExpirationDateManager()      .withDefaultTimeout(hours(1))      .build();  Date cacheExpiration = manager.getExpirationDate(cacheKey, 0L);  assertThat(dateOf(cacheExpiration).is(1).hoursAhead().from(systemDate)); }

 public void  testExpirationTimeWhenExpirationTimeoutIsSet() {  manager = aExpirationDateManager()      .withDefaultTimeout(hours(1))      .withExpirationTimeout(hours(2))      .build();  Date cacheExpiration = manager.getExpirationDate(cacheKey, 0L);  // Expiration timeout has precedence over default timeout.  assertThat(dateOf(cacheExpiration).is(2).hoursAhead().from(systemDate)); }

}</pre>
<p><span style="font-size: large;"><br />
</span><br />
<span style="font-size: large;"><strong>Conclusion</strong></span></p>
<p>Test classes should be easy to read. They should express intention, system behaviour, business rules. Test classes should express how the system works. They are executable requirements and specifications and should be a great source of information for any developer joining the project.</p>
<p>In order to achieve that, we need to try to keep our test methods divided in just 3 simple instructions.</p>
<p><strong>1. Context</strong>: The state of the object being tested. Here is where we set all the attributes and mock dependencies. Using variations of the Builder pattern can greatly enhance readability.</p>
<pre class="brush: java">manager = aExpirationDateManager()                .withDefaultTimeout(hours(1))                .withExpirationTimeout(hours(2))                .build();</pre>
<p><strong>2. Operation</strong>: The operation being tested. Here is where the operation is invoked.</p>
<pre class="brush: java">Date cacheExpiration = manager.getExpirationDate(cacheKey, 0L);</pre>
<p><strong>3. Assertion</strong>: Here is where you specify the behaviour expected. The more readable this part is, the better. Using DSL-style code is probably the best way to express the intent of the test.</p>
<pre class="brush: java">assertThat(dateOf(cacheExpiration).is(2).hoursAhead().from(systemDate));</pre>
<p>In this post I went backwards. I&#8217;ve started from a messy test class and refactored it to a more readable implementation. As many people now are doing TDD, I wanted to show how we can improve an existing test. For new tests, I would suggest that you start writing the tests following the <em>Context</em> &gt;&gt; <em>Operation</em> &gt;&gt; <em>Assertion</em> approach. Try writing the test code in plain English. Once the test intent is clear, start replacing the plain English text with Java internal DSL code, keeping the implementation out of the test class.</p>
<p><em>PS: The ideas for this blog post came from a few discussions I had during the Software Craftsmanship Round-table meetings promoted by the <a href="http://www.meetup.com/london-software-craftsmanship/">London Software Craftsmanship Community (LSCC).</a> </em></p>
<div class="blogger-post-footer"><img src="https://blogger.googleusercontent.com/tracker/8424060401701893376-6729909628427981355?l=craftedsw.blogspot.com" alt="" width="1" height="1" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.valtech.co.uk/craftsmanship/readable-tests-separating-intent-from-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A basic ActiveRecord implementation in Java</title>
		<link>http://blog.valtech.co.uk/java/a-basic-activerecord-implementation-in-java/</link>
		<comments>http://blog.valtech.co.uk/java/a-basic-activerecord-implementation-in-java/#comments</comments>
		<pubDate>Tue, 07 Dec 2010 21:25:00 +0000</pubDate>
		<dc:creator>Sandro Mancuso</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Recently I was looking for different ways to develop applications in Java and thought that it would be interesting trying to use ActiveRecord in my persistence layer instead of implementing the traditional approach with a DAO. My idea is not to create ...]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.valtech.co.uk%2Fjava%2Fa-basic-activerecord-implementation-in-java%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://blog.valtech.co.uk/java/a-basic-activerecord-implementation-in-java/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.valtech.co.uk/java/a-basic-activerecord-implementation-in-java/"  data-text="A basic ActiveRecord implementation in Java" data-count="horizontal" data-via="valtech">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Recently I was looking for different ways to develop applications in Java and thought that it would be interesting trying to use <a href="http://en.wikipedia.org/wiki/Active_record_pattern">ActiveRecord</a> in my persistence layer instead of implementing the traditional approach with a DAO. My idea is not to create my own ActiveRecord framework but use the existing ones as a support for this approach.</p>
<p><strong>The scope:</strong> Write functional tests that could prove that the methods <em>save</em> and <em>delete</em> on an entity work. I&#8217;ll use an entity called <em>Traveller</em> for this example.</p>
<p><strong>The technology:</strong> I chose to use the following frameworks: Spring 3.0.5, JPA 2.0, Hibernate 3.5.3, AspectJ 1.6.9, JUnit 4.8.2, Maven 2.2.1, Eclipse Helios and MySQL 5.x</p>
<p>I&#8217;ll be omitting things that are not too important. For all the details, please have a look at the whole source code at:</p>
<blockquote><p><a href="https://github.com/sandromancuso/cqrs-activerecord">https://github.com/sandromancuso/cqrs-activerecord</a></p></blockquote>
<p><span id="more-411"></span>Let&#8217;s start with the test class:</p>
<pre class="brush: java">
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
        locations={"file:src/test/resources/applicationContext-test.xml", "file:src/main/resources/applicationContext-services.xml"})
@TransactionConfiguration(transactionManager = "myTransactionManager", defaultRollback = true)
@Transactional
public class TravellerActiveRecordIntegrationTest extends BaseTravellerIntegration {

 @Test public void  testTravellerSelfCreation() {  assertThereAreNoTravellers(named("John"), from("England"));

  Traveller traveller = aTraveller().named("John").from("England").build();  traveller.save();

  assertThereIsASingleTraveller(named("John"), from("England")); }

 @Test public void testTravellerEdition() {  Traveller traveller = aTraveller().named("John").from("England").build();  traveller.save();

  traveller.setName("Sandro");  traveller.setCountry("Brazil");  traveller.save();

  assertThereAreNoTravellers(named("John"), from("England"));  assertThereIsASingleTraveller(named("Sandro"), from("Brazil"));   }

 @Test public void  testDeleteTraveller() {  Traveller traveller = aTraveller().named("John").from("England").build();  traveller.save();

  traveller.delete();  assertThereAreNoTravellers(named("John"), from("England")); }

}
</pre>
<p>A few things to notice about this test class:<br />
- As this test is meant to insert and delete from the database, I set it to always rollback the transaction after each test, meaning that nothing will be committed to the database permanently. This is important in order to execute the tests multiple times and get the same results.<br />
- The test class extends a base class, that has the methods <em>assertThereAreNoTravellers</em> and <em>assertThereIsASingleTraveller</em>. The advantage of doing that is that you separate what you want to test from how you want to test, making the test class clean and focused on the intention.<br />
- Note that I also used the Builder pattern to build the traveller instance instead of using the setter methods. This is a nice approach in order to make your tests more readable.</p>
<p><strong>The Traveller entity implementation</strong></p>
<p>So now, let&#8217;s have a look at the Traveller entity implementation.</p>
<pre class="brush: java">@Entity@Table(name="traveller")@EqualsAndHashCode(callSuper=false)@Configurablepublic @Data class Traveller extends BaseEntity {

 @Id @GeneratedValue(strategy=GenerationType.AUTO) private long id; private String name; private String country;

}</pre>
<p>The <em>Traveller</em> class is a normal JPA entity as you can see by the <em>@Entity</em>, <em>@Table</em>, <em>@Id</em> and <em>@GenereratedValue</em> annotations. To reduce the boiler place code like getters, setters, toString() and hashCode(), I&#8217;m using <a href="http://projectlombok.org/">Lombok</a>, that is a small framework that generate all that for us. Just add a <em>@Data</em> annotation.</p>
<p>The real deal here is Traveller&#8217;s super class <em>BaseEntity</em> (for a lack of inspiration to find better name). Let&#8217;s have a look:</p>
<pre class="brush: java">
@Configurable
public abstract class BaseEntity {

 @PersistenceContext protected EntityManager em;

 public abstract long getId();

 public void save() {  if (getId() == 0) {   this.em.persist(this);  } else {   this.em.merge(this);  }  this.em.flush(); } 

 public void delete() {  this.em.remove(this);  this.em.flush(); }

 public void setEntityManager(EntityManager em) {  this.em = em; }

}
</pre>
<p>The BaseEntity class has quite a few things that can be discussed.</p>
<p><strong>The save() method</strong>: I&#8217;ve chosen to have a single method that can either insert or update an entity, based on its <em>id</em>. The problem with this approach is that, firstly, the method has more than one responsibility, making it a bit confusing to understand what it really does. Secondly it relies on the entities id, that needs to be a <em>long</em>, making it a very specific and weak implementation. The advantage is that from the outside (client code), you don&#8217;t need to worry about the details. Just simple call <em>save()</em> and you are done. If you prefer a more generic and more cohesive implementation, make the <em>getId()</em> method return a generic type and split the <em>save()</em> method into a <em>create()</em> and <em>update()</em> methods. My idea here was just to make it simple to use.</p>
<p><strong>EntityManager dependency</strong>: Here is where the biggest problem lies. For it to work well, every time a new instance of a entity is created, either by using <em>new EntityXYZ() </em>by hand or when it is created by a framework (e.g. as a result of a JPA / Hibernate query), we want the entity manager to be injected automatically. The only way I found to make it work is using aspects with AspectJ and Spring.</p>
<p><strong>Configuring AspectJ and Spring</strong></p>
<p>My idea here is not to give a full explanation about the whole AspectJ and Spring integration, mainly because I don&#8217;t know it very well myself. I&#8217;ll just give the basic steps to make this example work.</p>
<p>First add <em>@Configurable</em> to the Entity. This will tell that the entity will be managed by Spring. However, Spring is not aware of instances of the entity, in this case, <em>Traveller</em>, being created. This is why we need AspectJ. The only thing we need to do is to add the following line to our Spring context xml file.</p>
<pre class="brush: java">&lt;context:load-time-weaver /&gt;</pre>
<p>This makes AspectJ intercept the creation of beans annotated with @Configurable and tells Spring to inject the dependencies. In order to the load-time weaver (LTW) work, we need to override JVM&#8217;s class loading so that the first time our entity classes are loaded, AspectJ can kick in, the @Configurable annotation is discovered and all the dependencies are injected. For that we need to pass the following parameter to the JVM:</p>
<pre class="brush: java">-javaagent:&lt;path-to-your-maven-repository&gt;/.m2/repository/org/springframework/spring-instrument/3.0.5.RELEASE/spring-instrument-3.0.5.RELEASE.jar</pre>
<p>The snippet above is what we must use if using Spring 3.0.x. It works fine inside Eclipse but apparently it has some conflicts with Maven 2.2.1. If you run into any problems, you can use the old version below.</p>
<pre class="brush: java">-javaagent:&lt;path-to-your-maven-repository&gt;/.m2/repository/org/springframework/spring-agent/2.5.6/spring-agent-2.5.6.jar</pre>
<p>Another thing that is a good idea is to add the <em>aop.xml</em> file to your project, limiting the classes that will be affected by AspectJ. Add the <em>aop.xml</em> to <em>src/main/resources/META-INF</em> folder.</p>
<pre class="brush: xml">

  &lt;include within="com.lscc.ddddemo.model.entity.*" /&gt;  &lt;include within="com.lscc.ddddemo.model.entity.builder.*" /&gt;  &lt;exclude within="*..*CGLIB*" /&gt;</pre>
<p><strong>NOTE</strong>: The exclude clause is important to avoid some conflicts during the integration test. AspectJ sometimes tries to do some magic with the test classes as well causing a few problems and the exclude clause avoids that.</p>
<p><strong>Making the integration test work</strong></p>
<p>I&#8217;ll be using MySQL, so I&#8217;ll need a database with the following table there:</p>
<pre class="brush: sql">CREATE TABLE `traveller` (`id` int(11) NOT NULL AUTO_INCREMENT,`name` varchar(45) NOT NULL,`country` varchar(45) NOT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB</pre>
<p>As I&#8217;m using JPA 2.0, we need a <em>persistence.xml</em> that must be located at src/main/resources/META-INF</p>
<pre class="brush: xml">        com.lscc.ddddemo.model.entity.Traveller
            &lt;property name="hibernate.show_sql" value="true" /&gt;            &lt;property name="hibernate.format_sql" value="true" /&gt;

            &lt;property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" /&gt;            &lt;property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/lscc-ddd" /&gt;            &lt;property name="hibernate.connection.username" value="root" /&gt;

            &lt;property name="hibernate.c3p0.min_size" value="5" /&gt;            &lt;property name="hibernate.c3p0.max_size" value="20" /&gt;            &lt;property name="hibernate.c3p0.timeout" value="300" /&gt;            &lt;property name="hibernate.c3p0.max_statements"                    value="50" /&gt;            &lt;property name="hibernate.c3p0.idle_test_period"                    value="3000" /&gt;</pre>
<p>In our Spring configuration, we also need to tell Spring how to create an EntityManager, providing the EntityManager Factory:</p>
<pre class="brush: xml">
            &lt;property name="persistenceUnitName" value="testPU" /&gt;    

    &lt;tx:annotation-driven transaction-manager="myTransactionManager" /&gt;

            &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;</pre>
<p>In order to separate unit tests and integration tests in my Maven project, I&#8217;ve added a different profile for the integration tests in my <em>pom.xml</em>:</p>
<pre class="brush: xml">   with-integration-tests    

      org.apache.maven.plugins      maven-surefire-plugin             always       -javaagent:/Users/sandro.mancuso/.m2/repository/org/springframework/spring-agent/2.5.6/spring-agent-2.5.6.jar            2.5      true                     integration-tests
integration-test                 test                                   **/common/*                            **/*IntegrationTest.java</pre>
<p>So now, if you want to run the integration tests from the command line, just type:</p>
<pre class="brush: java">mvn clean install -Pwith-integration-tests</pre>
<p>If running the tests from inside Eclipse, don&#8217;t forget to add the <em>-javaagent</em> paramenter to the VM.</p>
<p><strong>Conclusion</strong></p>
<p>So now, from anywhere in your application you can do some thing like:</p>
<pre class="brush: java">Traveller traveller = new Traveller();traveller.setName("John");traveller.setCountry("England");traveller.save();</pre>
<p>The advantage of using the ActiveRecord:<br />
- Code becomes much simpler;<br />
- There is almost no reason for a DAO layer any more;<br />
- Code is more explicit in its intent.</p>
<p>The disadvantages:<br />
- Entities will need to inherit from a base class;<br />
- Entities would have more than one responsibility (against the <a href="http://craftedsw.blogspot.com/2010/06/object-oriented-design-principles-part.html">Single Responsibility Principle</a>);<br />
- Infrastructure layer (EntityManager) would be bleeding into our domain objects.</p>
<p>In my view, I like the simplicity of the ActiveRecord pattern. In the past 10 years we&#8217;ve been designing Java web applications where our entities are anaemic, having state (getters and setters) and no behaviour. So at the end, they are pure data structures. I feel that entities must be <a href="http://craftedsw.blogspot.com/2010/05/empowering-your-entities_24.html">empowered</a> and with techniques like that, we can do it, abstracting the persistence layer.</p>
<p>I&#8217;m still not convinced that from now on I&#8217;ll be using ActiveRecord instead of DAOs and POJOs but I&#8217;m glad that now there is a viable option. I&#8217;ll need to try it in a real project, alongside with Command Query Responsibility Segregation (CQRS) pattern to see how I will feel about it. I&#8217;m really getting sick of the standard Action/Service/DAO way to develop web applications in Java instead of having a proper domain model.</p>
<p>By the way, to make the whole thing work, I had loads of problems to find the right combination of libraries. Please have a look at my pom.xml file for details. I&#8217;ll be evolving this code base to try different things so when you look at it, it may not be exactly as it is described here.</p>
<blockquote><p><a href="https://github.com/sandromancuso/cqrs-activerecord">https://github.com/sandromancuso/cqrs-activerecord</a></p></blockquote>
<p>Interesting links with more technical details:<br />
<a href="http://nurkiewicz.blogspot.com/2009/10/ddd-in-spring-made-easy-with-aspectj.html">http://nurkiewicz.blogspot.com/2009/10/ddd-in-spring-made-easy-with-aspectj.html</a><br />
<a href="http://blog.m1key.me/2010/06/integration-testing-your-spring-3-jpa.html">http://blog.m1key.me/2010/06/integration-testing-your-spring-3-jpa.html</a></p>
<div class="blogger-post-footer"><img src="https://blogger.googleusercontent.com/tracker/8424060401701893376-2732083154762428592?l=craftedsw.blogspot.com" alt="" width="1" height="1" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.valtech.co.uk/java/a-basic-activerecord-implementation-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bad Code: The Invisible Threat</title>
		<link>http://blog.valtech.co.uk/craftsmanship/bad-code-the-invisible-threat/</link>
		<comments>http://blog.valtech.co.uk/craftsmanship/bad-code-the-invisible-threat/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 21:41:00 +0000</pubDate>
		<dc:creator>Sandro Mancuso</dc:creator>
				<category><![CDATA[Craftsmanship]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[One of the first things said by the non-believers of the software craftsmanship movement was that good and clean code is not enough to guarantee the success of a project. And yes, they are absolutely right. There are innumerable reasons which would mak...]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.valtech.co.uk%2Fcraftsmanship%2Fbad-code-the-invisible-threat%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://blog.valtech.co.uk/craftsmanship/bad-code-the-invisible-threat/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.valtech.co.uk/craftsmanship/bad-code-the-invisible-threat/"  data-text="Bad Code: The Invisible Threat" data-count="horizontal" data-via="valtech">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p><span class="value">One of the first things said by the non-believers of the <a href="http://craftedsw.blogspot.com/2010/09/software-craftsmanship.html">software craftsmanship</a> movement was that good and clean code is not enough to guarantee the success of a project. And yes, they are absolutely right. There are innumerable reasons which would cause a project to fail ranging from business strategy to competitors, project management, cost, time to market, partnerships, technical limitations, integrations, etc. </span></p>
<p><span class="value">Due to the amount of important things a software project may have, organisations tend not to pay to much attention to things that are considered <em>less</em> important, like the quality of the software being developed. It is believed that with a good management team, deep hierarchies, micro management, strict process and a large amount of <em>good</em> documentation, the project will succeed. </span></p>
<blockquote><p><span class="value">In a software project, the most important deliverable is the software itself. Anything else is secondary. </span></p></blockquote>
<p><span class="value">Many organisations see software development as a production line where the workers (developers) are viewed as less skilled than their <em>high-qualified</em> and much more well paid managers. Very rarely companies like that will be able to attract or retain good software developers, leaving their entire business on the hands of mediocre professionals. </span><br />
<span class="value"><span id="more-391"></span></span><strong><span class="value">Look after your garden</span></strong></p>
<blockquote>
<div style="text-align: right;">Rather than construction, programming is more like gardening. &#8211; <a href="http://amzn.to/b0mtSQ"><em><span class="value">The Pragmatic Programmer</span></em></a></div>
</blockquote>
<p><span class="value">Code is organic, not mechanical. Like a garden, code needs constant maintenance. For a garden to look nice all year round, you need to look after its soil, constantly remove weeds, regularly water it, remove some dead plants, replant new ones, trim or re-arrange existing ones so they can stay healthy and look nice as whole. With basic regular maintenance, the garden will always look great but if you </span>neglect it, even if for a short period, the effort to make it nice again will be much bigger. The longer you neglect it, the harder it will be to make it look nice again and you may even loose some or all of your plants.</p>
<p><span class="value">Code is no different. If code quality is not constantly looked after, the code starts to deteriorate. Bad design choices, lack of tests and poor use of languages and tools will make parts of the codebase rot. Bit by bit other parts of the code will also be contaminated up to the point that the whole code base is so ill that it becomes extremely painful to change it or add new features to it.</span></p>
<p><span class="value"><strong>The Invisible Threat</strong> </span></p>
<p><span class="value">When starting a greenfield project, everything is great. With a non-existent code base, developers can quickly start creating new features without the fear of breaking or changing any existing code. Testers are happy because everything they need to test is new, meaning that they don&#8217;t need to worry about regression tests. Managers can see a quick progress in terms of new features added and delivered. What a fantastic first month the team is having. </span><br />
<span class="value"> </span><br />
<span class="value">However, this is not a team of <a href="http://craftedsw.blogspot.com/2010/09/beyond-manifesto-software-craftsmanship.html">craftsmen</a>. This is a team of average developers structured and treated like unskilled production line workers. </span><br />
<span class="value"> </span><br />
<span class="value">As time goes by, things are getting messier, bugs start to appear (some with no apparent explanation) and features start taking longer and longer to be developed and tested. Very slowly, the time to deliver anything starts to stretch out. But this is a slow process. Slow enough that it takes months, sometimes over a year or two to be noticed by the management. </span><br />
<span class="value"><br />
</span></p>
<div class="separator" style="clear: both; text-align: center;"><a style="margin-left: 1em; margin-right: 1em;" href="http://2.bp.blogspot.com/_ONTWYUiOUvw/TJ_onxsne5I/AAAAAAAAAKQ/yxxarqwpMbE/s1600/Quality_vs_Time.png"><img src="http://2.bp.blogspot.com/_ONTWYUiOUvw/TJ_onxsne5I/AAAAAAAAAKQ/yxxarqwpMbE/s320/Quality_vs_Time.png" border="0" alt="" width="320" height="152" /></a></div>
<p><span class="value">It&#8217;s very common to see projects where, at the beginning of a project, a feature of size X takes N number of days to be implemented. Over the time, as more bad code is added to the application, the same feature X (or a feature of the same size) takes much longer to be implemented than it used to take at the beginning of the project N + M. As the quality of the code decreases, the amount of time to implement a new feature, fix a bug or make a change increases. The lower the quality, the higher the number of bugs, the harder is to test and less robust and reliable the application becomes. </span></p>
<blockquote><p><span class="value">Some people say that they just don&#8217;t have time to do it properly but, in general, a lot more time and money is spent later on on tests and bug fixing. </span></p></blockquote>
<p><span class="value"><strong>Hostage of your own software</strong></span><span class="value"> </span></p>
<p><span class="value">When the code base gets into the situation where changes or additional features take too long to be implemented or worse, developers and managers are scared to touch existing code, an action must be taken immediately. This is a very dangerous situation to be in since business progress is being impeded or delayed by the software instead of being helped by it. </span></p>
<blockquote><p><span class="value">To keep business progress, schedule and budget under control, high quality code needs to be maintained at all costs.</span><strong><span class="value"><br />
</span></strong></p></blockquote>
<p><span class="value"> </span><br />
<span class="value">Organisations may need to cancel the implementation of some features or postpone changes just because of the amount of time and money that they may cost to be built. Having poor quality of code responsible for it is totally unacceptable. </span></p>
<p><span class="value">The biggest problem here is that bad code is invisible to everyone besides developers. Other members of the team will just realise that something is wrong when it is too late. This means that it is the developers responsibility to look after the quality of the code. Some times, developers expose the problem to project managers but the request for having some time to &#8220;<em>re-factor</em>&#8221; the code is often ignored for various reasons, including a lack of understand of the impacts of bad code and the inability of developers to explain it. On the other hand, when developers come to a point where they need to ask for some formal time to do refactoring, this means that for one reason or another, they neglected the code at some point in the past.</span></p>
<p><span class="value"><strong>Hire craftsmen not average developers</strong><br />
<strong> </strong></span><br />
<span class="value">With the amount of literature, tools, technologies, methodologies and the infinite source of information available on the web, it is just unacceptable to have a team of developers that let the code rot.</span></p>
<p><span class="value"><a href="http://craftedsw.blogspot.com/2010/09/beyond-manifesto-software-craftsmanship.html">Craftsmen</a> are gardeners and are constantly looking after the code base, quickly refactoring it without fear since they are strongly backed by a good battery of tests that can test the entire application in just a few minutes. Time constraints or change in requirements will never be used as excuses for bad code or lack of tests due to the good design principles and techniques constantly used throughout the application.</span></p>
<p><span class="value">Having an empowered team of craftsmen can be the difference between success and failure of any software project.</span></p>
<blockquote><p><span class="value"><strong>Quality of code may not guarantee the success of a project but it can definitely be the main invisible cause of its failure. </strong></span></p></blockquote>
<div class="blogger-post-footer"><img src="https://blogger.googleusercontent.com/tracker/8424060401701893376-780338124898600545?l=craftedsw.blogspot.com" alt="" width="1" height="1" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.valtech.co.uk/craftsmanship/bad-code-the-invisible-threat/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Beyond the manifesto: The Software Craftsmanship Attitude</title>
		<link>http://blog.valtech.co.uk/agile/beyond-the-manifesto-the-software-craftsmanship-attitude/</link>
		<comments>http://blog.valtech.co.uk/agile/beyond-the-manifesto-the-software-craftsmanship-attitude/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 22:19:00 +0000</pubDate>
		<dc:creator>Sandro Mancuso</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Craftsmanship]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Being an aspiring software craftsman goes way beyond than just saying it. I'll quote my own definition of software craftsmanship from my previous post. Software craftsmanship is a long journey to mastery. It's a lifestyle  where developers choose to be...]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.valtech.co.uk%2Fagile%2Fbeyond-the-manifesto-the-software-craftsmanship-attitude%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://blog.valtech.co.uk/agile/beyond-the-manifesto-the-software-craftsmanship-attitude/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.valtech.co.uk/agile/beyond-the-manifesto-the-software-craftsmanship-attitude/"  data-text="Beyond the manifesto: The Software Craftsmanship Attitude" data-count="horizontal" data-via="valtech">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p><span style="font-size: large;"><span style="font-size: small;">Being an aspiring software craftsman goes way beyond just saying it. I&#8217;ll quote my own definition of software craftsmanship from my <a href="http://craftedsw.blogspot.com/2010/09/software-craftsmanship.html">previous post</a>. </span></span></p>
<blockquote><p>Software craftsmanship is a long journey to mastery. It&#8217;s a lifestyle  where developers choose to be responsible for their own careers and for  improving their craft, constantly learning new tools and techniques. <span class="status-body"><span class="entry-content">Software  Craftsmanship is all about putting responsibility, professionalism,  pragmatism and pride back into software development</span></span>.</p></blockquote>
<p>Software craftsmanship is all about attitude. The attitude of <a href="http://manifesto.softwarecraftsmanship.org/">raising the bar of professional software development</a> starting with our own skills and professionalism.<span id="more-386"></span></p>
<p><span style="font-size: large;"><strong>The responsibility shift</strong></span></p>
<p>Not long ago, I was speaking to a developer and he was complaining about his company, saying that they didn&#8217;t have a good career plan, that he did not have any training, that he was not given the opportunity to learn new technologies and, of course, that he was not paid enough. Apparently, from his perspective, his employer was responsible for his career.</p>
<p>Imagine that we need a doctor. Would we pay a doctor to learn while he cut us open or give us a diagnosis? Would we pay an engineer to learn while he draws the plan for our new house? Would we go to a concert and pay the musician to learn how to play the guitar during the show? What about a chef in a restaurant?</p>
<p>So why is it the employer&#8217;s obligation to pay for training courses and pay us to learn new technologies and tools while we are working on a project? Should the employers be responsible for what we learn and what we don&#8217;t learn.</p>
<p><strong>Software development</strong><strong> is not a 9 to 5 profession</strong>. To be a <em>professional</em> software developer, we need to take our own time and money to keep learning and improving. As professionals, we should be paid for what we know, our ability to learn fast and for the quality of the work we do. We own our careers and are responsible for them. Working for a customer/employer that helps us with our career in terms of training, books, conferences, seminars, etc, is great but should be considered a bonus.</p>
<p><strong> </strong><br />
<span style="font-size: large;"><strong>&#8230; but how can we learn and keep ourselves up-to-date?</strong></span></p>
<p>Different developers have different preferences but here is a list of ways I find useful.</p>
<p><span style="font-size: large;"><strong>Literature</strong></span><strong> </strong></p>
<p><strong>Books, many books</strong>. Having your own library is essential. Books give you a good overview of a specific technology or subject quickly. No, it does not mean you will be proficient and next day you will be a specialist. What a book will give you is an understanding of what a technology or subject is about. It will be up to you then to decide if you want to practice what you&#8217;ve learned and become proficient. If you don&#8217;t have the habit, try reading 3 to 4 technical books per year. Once you get the habit, try one per month. The most common excuse is that you don&#8217;t have time. The cool thing about books is that you can read them during periods of  &#8220;dead&#8221; time, like on the tube, bus, in your dentist&#8217;s waiting room, on the bed before going to sleep, toilet, etc.</p>
<p><strong>Blogs</strong> are now one of my favourite types of reading. They tend to fit more the software craftsmanship model since they are much more personal and in general, related to personal findings, opinions, successes and failures. Reading blogs from more experienced professionals and subject matter experts is a good, quick and free way for apprentices and journeymen to learn from multiple master craftsmen at the same time. But don&#8217;t think that just experienced professionals should write blogs. Every software developer should write his or her own blogs, sharing their experiences and findings, helping to create a great <a href="http://manifesto.softwarecraftsmanship.org/">community of professionals</a>.</p>
<p><strong>Technical websites</strong> are also good in order to keep yourself up-to-date with what&#8217;s going in the market. New technologies, techniques, etc.</p>
<p><span style="font-size: large;"><strong>Practice, practice, practice</strong></span></p>
<p><strong>Pet projects</strong> are for me, by far, the best way to learn and study. A pet project is a <em>real</em> project but without the boring bits. There are no deadlines, does not need to make money, you control the requirements and most importantly, you use the technologies and methodologies you want, whenever you want, wherever you want. You are the boss. Pet projects give something for you to focus on and help you to understand why and how you can use certain technologies. It gives you the experience you need to apply what you&#8217;ve learned to real projects. Pet projects are meant to be fun.</p>
<p>Contributing to <strong>open source</strong> projects can also be a great thing. There are thousands of them out there. Find a project that is related to what you want to learn or know more about and download the source code. Start running and reading the tests, if any. Inspect and debug the code. If you want to contribute, start small. Add some documentation and write some tests. Then, check the list of features to be implemented and pick a simple one and give it a go. You can also propose and implement a new and small one to start with.</p>
<p><strong>Pair-programming</strong> can be a great experience. Many developers are afraid to try or think they will feel uncomfortable. That&#8217;s what I thought as well before I tried. Today I really enjoy it. Pair-programming gives you an opportunity to discuss your ideas, to learn new tricks and techniques from your pair and the resulting code is much better. Pairing with someone from your team is good but pairing with someone that you barely know can be a very interesting experience.</p>
<p>If learning a new language or new technique like TDD / BDD or trying different approaches to OOP or functional programming, try a <strong>code kata</strong>. Code kata is a small exercise that in general can be solved in a few minutes or in a few hours. Code katas were created to help developers to focus on a problem while improving their skills. You can find a good source of code katas at <a href="http://codingkata.org/">codingkata.org</a> and <a href="http://codekata.pragprog.com/">codekata.pragprog.com</a></p>
<p><strong><span style="font-size: large;">Community and Events</span></strong></p>
<p><span style="font-size: large;"><span style="font-size: small;"><strong>Be part of your local community. </strong></span><span style="font-size: small;">Software craftsmanship is all about a <a href="http://manifesto.softwarecraftsmanship.org/">community of professionals</a>, learning and sharing with each other and elevating the level of professionalism and maturity of our industry. Join your nearest user groups and participate in their events. User groups are the best way for making contacts, sharing ideas and learning things. Many user groups promote free talks, coding activities and social events. A great aspect of being part of a community is the feeling that you are not alone. There are many people out there having the same problems you&#8217;ve got and many others that will happily share their solution to it.</span></span></p>
<p><span style="font-size: large;"><strong>Raising the bar</strong></span></p>
<p>The main changes proposed by the <a href="http://craftedsw.blogspot.com/2010/09/software-craftsmanship.html">software craftsmanship movement</a> are related to the developers attitude. In summary, it&#8217;s about being proud about your work, the code you produce and the software you create. It&#8217;s about constantly trying to improve your skills and learn new ones.</p>
<p>An aspiring software craftsman is intolerant of bad code will constantly apply the <a href="http://programmer.97things.oreilly.com/wiki/index.php/The_Boy_Scout_Rule">Boy Scout Rule</a>.</p>
<blockquote><p><span class="status-body"><span class="entry-content">If you find that the  good code you wrote one year ago is still good enough today, it means you  didn&#8217;t learn anything during this period and this is unacceptable.</span></span></p></blockquote>
<p><strong>Productive partnerships </strong></p>
<p>The attitude of a software craftsman goes beyond good code. The relationship between a software craftsman and his or her customer (or employer) is of a <a href="http://manifesto.softwarecraftsmanship.org/">productive partnership</a> and not employer / employee. As a productive partnership, it&#8217;s our role to constantly question the requirements and propose improvements and new features. It&#8217;s our job to warn our customers about the problems we see. Due to the knowledge of the code and technology, developers are well positioned to help their customers improve their business.</p>
<p>However, sometimes some customers or employers don&#8217;t want or don&#8217;t see the advantages of this partnership and will treat developers as production line workers that should just do what they are told. Coding monkeys. In cases like that, any aspiring software craftsman should move on and find another job. Staying in a place where your skills are not appreciated is career suicide.</p>
<p>Raising the bar of our industry is in our own interest. The better we become in writing code and delivering valuable software, the better our lives will be, professionally and financially.</p>
<p><span style="font-size: small;">PS: If  you are in London or nearby, join the <a href="http://www.londonswcraft.com/">London Software Craftsmanship Community</a>. </span></p>
<div class="blogger-post-footer"><img src="https://blogger.googleusercontent.com/tracker/8424060401701893376-8346000483478607958?l=craftedsw.blogspot.com" alt="" width="1" height="1" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.valtech.co.uk/agile/beyond-the-manifesto-the-software-craftsmanship-attitude/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Software Craftsmanship</title>
		<link>http://blog.valtech.co.uk/craftsmanship/software-craftsmanship/</link>
		<comments>http://blog.valtech.co.uk/craftsmanship/software-craftsmanship/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 16:40:00 +0000</pubDate>
		<dc:creator>Sandro Mancuso</dc:creator>
				<category><![CDATA[Craftsmanship]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[So what is software craftsmanship?&#160;A better metaphor: In a very simplistic way, we can say that software craftsmanship is a better metaphor for software development than software engineering, as I wrote in a previous post. Software craftsmanship s...]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.valtech.co.uk%2Fcraftsmanship%2Fsoftware-craftsmanship%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://blog.valtech.co.uk/craftsmanship/software-craftsmanship/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.valtech.co.uk/craftsmanship/software-craftsmanship/"  data-text="Software Craftsmanship" data-count="horizontal" data-via="valtech">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p><strong><span style="font-size: large;">So what is software craftsmanship? </span></strong></p>
<p><strong>A better metaphor</strong>: In a very simplistic way, we can say that software craftsmanship is a better metaphor for software development than software engineering, as I wrote in a <a href="http://craftedsw.blogspot.com/2010/08/software-engineering-process-vs-people.html">previous post</a>. Software craftsmanship sees software as a craft and compares software developers to the medieval blacksmiths. Apprentices would work with more experienced blacksmiths, travelling from place to place, working with and for different masters, learning different tools and techniques, improving their craft until the point they were good enough to become master themselves. (There is more to it, but let&#8217;s keep it simple for now).<br />
<span id="more-387"></span><br />
<strong>Wikipedia Definition</strong>:  is an approach to software development that emphasizes the coding skills  of the software developers themselves. It is a response by software  developers to the perceived ills of the mainstream software industry,  including the prioritization of financial concerns over developer  accountability. (<a href="http://en.wikipedia.org/wiki/Software_craftsmanship">read in full</a>)</p>
<p>I personally don&#8217;t like too much the Wikipedia&#8217;s definition. It&#8217;s very dry and I don&#8217;t think it captures the essence of what being a software craftsman means to a software developer.</p>
<p><strong>A more personal definition</strong>: Software craftsmanship is a long journey to mastery. It&#8217;s a lifestyle where developers choose to be responsible for their own careers and for improving their craft, constantly learning new tools and techniques. <span class="status-body"><span class="entry-content">Software  Craftsmanship is all about putting responsibility, professionalism,  pragmatism and pride back into software development</span></span></p>
<p>A software craftsman cares and is proud of his or her work and is extremely professional and pragmatic when it comes to its implementation.</p>
<div class="separator" style="clear: both; text-align: center;"><a style="margin-left: 1em; margin-right: 1em;" href="http://3.bp.blogspot.com/_ONTWYUiOUvw/TH70f-RTkbI/AAAAAAAAAJ0/JM-0EmWb2go/s1600/violinmaker.jpg"><img src="http://3.bp.blogspot.com/_ONTWYUiOUvw/TH70f-RTkbI/AAAAAAAAAJ0/JM-0EmWb2go/s320/violinmaker.jpg" border="0" alt="" /></a></div>
<p><span style="font-size: large;"><strong>The Software Craftsmanship Movement </strong></span></p>
<p>The software craftsmanship movement is basically an evolution of ideas that started probably in the late 90ies, early 2000 with the publication of <a href="http://en.wikipedia.org/wiki/The_Pragmatic_Programmer">The Pragmatic Programmer</a> by Andy Hunt and Dave Thomas (1999) and <a href="http://www.amazon.co.uk/Software-Craftsmanship-Imperative-Pete-McBreen/dp/0201733862/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1283437984&amp;sr=1-1">Software Craftsmanship: The New Imperative</a> by Pete McBreen (2001). In 2008, <a href="http://en.wikipedia.org/wiki/Robert_Cecil_Martin">Uncle Bob</a> proposed &#8220;Craftsmanship over Execution&#8221; (originally Craftsmanship over Crap) as the fifth value for the <a href="http://agilemanifesto.org/">Agile Manifesto</a>. In 2009, the <a href="http://manifesto.softwarecraftsmanship.org/">Manifesto for Software Craftsmanship</a> was created, defining the values of the movement and international Software Craftsmanship conferences emerged in the US and UK.</p>
<p>In the <a href="http://manifesto.softwarecraftsmanship.org/">manifesto</a>, the essence of software craftsmanship is captured in its subtitle: <strong>Raising the bar</strong>. The manifesto was idealised by very experienced developers that had had enough of project failures mainly caused by poor management, ill processes and, of course, badly-written code.</p>
<p>Developers are taking the matter into their own hands and are trying to  change how the industry sees software development not just proposing new and revolutionary processes but showing customers that they care about  what they do and that they want to work together with their customers in order to  produce great and long-lived software.</p>
<p><span style="font-size: large;"><strong>The values of the Software Craftsmanship Movement</strong></span></p>
<blockquote>
<div class="right"><em>Not only working software, but also <strong><span class="value">well-crafted software</span></strong></em></div>
</blockquote>
<div class="right">
<p><span class="value">Working code is not good enough. Think of a 5 year old application (it could be 2 or 10) where we are scared to change some of its parts (fix bugs, add new features, etc.) because we don&#8217;t understand how it works and have no confidence that we will not break anything else. This application is <em>working software</em> but is it good enough? Well crafted software means that regardless of how old the application is, developers can understand it easily, side effects are well known and controlled, high test coverage, clear design, business language well expressed in the code and adding or changing features does not take longer that it used to take at the beginning of the project, when the code base was small. </span></p>
<p><span class="value">The <strong>code must be maintainable</strong> <strong>and predictable</strong>. Developers must know what is going to happen when changing the code and must not fear changing it. Changes should be localised and not cause impact in other parts of the application. Tests will guarantee that nothing else was broken.</span></p>
</div>
<blockquote>
<div class="right"><em>Not only responding to change, but also <strong><span class="value">steadily adding value</span></strong></em></div>
</blockquote>
<div class="right">
<p><span class="value">This is not just about adding new features and fixing bugs. This is also about constantly improving the structure and cleanliness of the code. The software must be seen as an asset and the constant maintenance of it will make it more valuable during its lifetime, instead of letting it rot and devalue. </span></p>
<p><span class="value">The Boy Scout Rule (defined by <a href="http://en.wikipedia.org/wiki/Robert_Cecil_Martin">Uncle Bob</a>) states that we should <strong>always leave the code a bit cleaner than we found it</strong>. This is a paraphrase of Boy Scouts rule</span>: <em>leave the camp cleaner than you found it</em>.<span class="value"> </span></p>
<p><span class="value">If customers want to keep benefiting from adding and  changing features quickly, they will need high quality code to enable  them to do it. </span><span class="value"> </span><span class="value"><br />
</span></p>
</div>
<blockquote>
<div class="right"><em>Not only individuals and interactions, but also <span class="value">a <strong>community of professionals</strong></span></em></div>
</blockquote>
<div class="right">
<p><span class="value">This is somehow related to the idea of apprentices, journeymen and masters, where software craftsmanship masters will mentor apprentices and help them in their journey. The software craftsmanship community is responsible for training the next generation of professionals. Knowledge and ideas must be shared and discussed within the community in order to keep moving the software development industry forward. </span></p>
<p><span class="value"> </span></p>
</div>
<blockquote>
<div class="right"><em>Not only customer collaboration, but also <strong><span class="value">productive partnerships</span></strong></em></div>
</blockquote>
<p>Software craftsmen need successful projects to build their reputation and are proud of their achievements. Successfully delivering high quality software is essential for any software craftsman journey. With this in mind, software craftsmen will do whatever they can for a project to succeed. They don&#8217;t act like simple employees that just do what they are told to do. They want to actively contribute to the success of the project, questioning requirements, understanding the business, proposing improvements and productively partnering with their customers or employers. This is an interesting shift of perspective, if you like, and the advantages for the customer and for the project success are enormous. A well-motivated team has a much bigger chance to make any project succeed. However, if the customer is not prepared to have this partnership and sees software development as an industrial process and the least important part of the project, this customer will never have real software craftsmen working for him for too long. Not getting involved with the business, not questioning requirements, not proposing improvements and not knowing the customers needs is not a partnership. Real software craftsmen make the customer needs, their needs.</p>
<p><strong>Conclusion</strong></p>
<p>Recently, <a href="http://en.wikipedia.org/wiki/Robert_Cecil_Martin">Uncle Bob Martin</a> said during an <a href="http://www.azullo.com/blog/think-agile/interview-with-robert-c-martin-co-author-of-the-agile-manifesto/">interview</a>:</p>
<div style="text-align: left;">
<blockquote><p>The original torch of the Agile message has changed hands, and is now  being carried by the Software Craftsmanship movement.  These are the  folks who continue to pursue the technical excellence and professionalism that drove the original founders of the Agile  movement.</p></blockquote>
</div>
<p>The Software Craftsmanship Movement is another step forward towards better and healthier software projects. Instead of just focusing on processes, it focuses on the quality of the software that is produced and most importantly on the attitude and competence of the people involved.</p>
<p>Software Craftsmanship brings pride and professionalism into software development.</p>
<div class="blogger-post-footer"><img src="https://blogger.googleusercontent.com/tracker/8424060401701893376-6843022714284326854?l=craftedsw.blogspot.com" alt="" width="1" height="1" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.valtech.co.uk/craftsmanship/software-craftsmanship/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Software Engineering: The problem with the production line</title>
		<link>http://blog.valtech.co.uk/agile/software-engineering-the-problem-with-the-production-line/</link>
		<comments>http://blog.valtech.co.uk/agile/software-engineering-the-problem-with-the-production-line/#comments</comments>
		<pubDate>Sat, 02 Oct 2010 09:35:00 +0000</pubDate>
		<dc:creator>Sandro Mancuso</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[Agile Management]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Is software engineering the best approach for developing software? Does it apply for the majority of the software projects or just a very few of them?Software Engineering was an answer for the perceived "software crisis", back in 1968, in the First NAT...]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.valtech.co.uk%2Fagile%2Fsoftware-engineering-the-problem-with-the-production-line%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://blog.valtech.co.uk/agile/software-engineering-the-problem-with-the-production-line/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.valtech.co.uk/agile/software-engineering-the-problem-with-the-production-line/"  data-text="Software Engineering: The problem with the production line" data-count="horizontal" data-via="valtech">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Is software engineering the best approach for developing software? Does it apply for the majority of the software projects or just a very few of them?</p>
<p>Software Engineering was an answer for the perceived &#8220;<a href="http://en.wikipedia.org/wiki/Software_crisis">software crisis</a>&#8220;, back in 1968, in the First NATO Software Engineering Conference and it was created to solve the problems of extremely large NATO and U.S. Department of Defence projects. In the majority of these projects, the hardware was still being designed and with no hardware to test, there was plenty of time to investigate requirements and write the software specifications. Hardware controlled by the software was generally worth billions of dollars like in the case of <a href="http://www.fastcompany.com/magazine/06/writestuff.html%20">space shuttle</a> and the <a href="http://en.wikipedia.org/wiki/Safeguard_Program">Safeguard Ballistic Missile Defence System</a>. People&#8217;s lives and national security were also at stake.<span id="more-388"></span></p>
<p>The <a title="IEEE Computer Society" href="http://en.wikipedia.org/wiki/IEEE_Computer_Society">IEEE Computer Society</a>&#8216;s <em><a title="Software Engineering Body of Knowledge" href="http://en.wikipedia.org/wiki/Software_Engineering_Body_of_Knowledge">Software Engineering Body of Knowledge</a></em> defines &#8220;software engineering&#8221; as:</p>
<blockquote><p><em>Software engineering is the application of a systematic,  disciplined, quantifiable approach to the development, operation, and  maintenance of software, and the study of these approaches; that is, the application of engineering to software.</em></p></blockquote>
<p>Software Engineering can be very effective when developing safety critical systems like the one for the space shuttle as described on &#8220;<a href="http://www.fastcompany.com/magazine/06/writestuff.html">They Write The Right Stuff</a>&#8221; &#8211; Fast Company article, from 1996:</p>
<blockquote><p><em>The last three versions of the program &#8211; each 420,000 lines long &#8211; had just one error each. The last 11 versions of this software had a total of 17 errors. Commercial programs of equivalent complexity would have 5,000 errors.</em></p></blockquote>
<p>Of course that this looks really impressive but there is more to it:</p>
<blockquote><p><em>Money is not the critical constraint: The group&#8217;s $35 million per year budget is a trivial slice of the NASA pie, but on a dollars-per-line basis, it makes the group among the nation&#8217;s most expensive software organizations.</em></p></blockquote>
<p>Another extract from this same article when they were discussing the process:</p>
<blockquote><p><em>And the culture is equally intolerant of creativity, the individual  coding flourishes and styles that are the signature of the all-night  software world. &#8220;People ask, doesn&#8217;t this process stifle creativity? You  have to do exactly what the manual says, and you&#8217;ve got someone looking  over your shoulder,&#8221; says Ted Keller (senior technical manager). &#8220;The answer is, yes, the process does  stifle creativity.&#8221;</em></p></blockquote>
<p>Many of the NATO and US Department of Defence projects took years, some over a decade to complete. Many had hundreds of people involved and almost half of the time was spend in requirements and design specifications, with uncountable reviews and approval cycles. Of course, due to their reliability and quality, many are still in use today.</p>
<p><span style="font-size: small;"><strong>Software Engineering for the Masses</strong></span></p>
<p>More and more hardware became cheap and business of all sizes needed software in order to survive and be competitive. The difference was that a the big majority of these businesses couldn&#8217;t afford to pay $35 million dollars per year and neither wait for too many years to start benefiting from their software. Also, many of those software projects were not manipulating expensive hardware or dealing with <span class="sense_b "><span class="def parentof__def__is__sense_b">life-threatening situations.</span></span> <a href="http://yourdon.com/about/">Edward Yourdon</a>, in his book Rise and Resurrection of the American Programmer, wrote:</p>
<blockquote><p><em>I&#8217;m going to deliver a system to you in six months that will have 5,000 bugs in it &#8211; and you&#8217;re going to be very happy!</em></p></blockquote>
<p>It was clear that software engineering processes had to be adapted in order to satisfy a more impatient and lower budget legion of businesses.</p>
<p><strong>The &#8220;Good Enough Software</strong>&#8221; <strong>Era</strong></p>
<p>Over the decades, many new software engineering processes and methodologies were created in order to make software development faster and cheaper. The most adopted were the ones based on <a href="http://en.wikipedia.org/wiki/Iterative_and_incremental_development">iterative and incremental development</a> that evolved into <a href="http://en.wikipedia.org/wiki/Agile_software_development">agile software development</a>.</p>
<p>Agile software development and &#8220;good enough software&#8221; were an amazing improvement in bringing costs down, mitigating risks with quicker feedback and much faster time to market.</p>
<p>Regardless the methodology or process used, software projects are still failing. Some fail because they go over-budget, others because they are not delivered on time, others fail to satisfy the requirements and business goals, et al.</p>
<p>The main problem is that for decades, software development was seen as a production line. That&#8217;s the software engineering perspective of software development. Processes and methodologies are generally much more focused on making this production line more productive, creating different management and organisational styles than actually trying to make the employees more capable. Developers are treated as mere brain-damaged programmers and are at the bottom of the food chain.</p>
<p><strong>Good enough is not always good enough</strong></p>
<p>Using agile, lean or any methodology is not enough. It is all about the people involved in the project and their willingness to succeed and be proud of what they produce. If developers are seen as the least important and cheapest members of a software project, the maximum that this team is going to produce is mediocre software, regardless of methodology.</p>
<p>A software project would have much better chances to succeed with &#8220;good people with a bad process&#8221; than &#8220;mediocre people with a good process&#8221;. Good people would always find a way to improve the process, be productive and produce something that they are proud of. Mediocre people accepts whatever is established, even when it is not good enough, and will produce just what they were asked for.</p>
<p>In a software project, if a company wants a good software, they will need <strong>good</strong> and <strong>empowered </strong>software developers. Instead of 10 mediocre people with a good process, it would be better to have 3 or 4 good people and empower them to deliver the project.</p>
<p>A process, imposed by managers and people that have no clue how to write software, will just guarantee that mediocre software is predictably delivered (if lucky). On the other hand, a team of self-organised and great developers would have a better shot at creating a more efficient way to produce great software, constantly trying to improve they way they work.</p>
<p>A process should never be more important than the people. Managers should facilitate the work of great software developers and not tell them what to do. It should always be harder to replace a good software developer than a manager since they are the ones that know the system inside-out. Managing a few well motivated, well paid and good professionals is always easier than managing many mediocre people.</p>
<p>Software development is a creative and highly skilled profession that takes years to master. While software development is treated like a production line, projects will continue to fail.</p>
<div style="background-color: white; color: #444444;"><strong>Source</strong></div>
<p><span style="font-size: small;">Software Craftsmanship: The New Imperative &#8211; ISBN 0-201-73386-2, 2002 </span><br />
<span style="font-size: small;"><a href="http://en.wikipedia.org/wiki/Software_engineering">http://en.wikipedia.org/wiki/Software_engineering</a></span><br />
<span style="font-size: small;"><a href="http://en.wikipedia.org/wiki/Software_crisis">http://en.wikipedia.org/wiki/Software_crisis</a></span><br />
<span style="font-size: small;">IEEE Standard Computer Dictionary, ISBN 1-55937-079-3, IEEE 1990</span><br />
<span style="font-size: small;">&#8220;They Write The Right Stuff&#8221;, Fast Company, <a href="http://www.fastcompany.com/magazine/06/writestuff.html">http://www.fastcompany.com/magazine/06/writestuff.html</a></span><br />
<span style="font-size: small;">Safeguard Program: <a href="http://en.wikipedia.org/wiki/Safeguard_Program">http://en.wikipedia.org/wiki/Safeguard_Program</a></span><br />
<span style="font-size: small;">Stephenson, W. E. &#8220;<strong>An analysis of the resources used in the SAFEGUARD system software development&#8221;</strong></span><br />
<span style="font-size: small;"><strong>Edward Yourdon  &#8211; <a href="http://yourdon.com/about/">http://yourdon.com/about/ </a></strong></span><br />
<span style="font-size: small;"><strong>http://en.wikipedia.org/wiki/Iterative_and_incremental_development </strong></span><br />
<span style="font-size: small;"><strong>http://en.wikipedia.org/wiki/Agile_software_development</strong></span></p>
<div class="blogger-post-footer"><img src="https://blogger.googleusercontent.com/tracker/8424060401701893376-8882835982301412199?l=craftedsw.blogspot.com" alt="" width="1" height="1" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.valtech.co.uk/agile/software-engineering-the-problem-with-the-production-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Which type of barista are you?</title>
		<link>http://blog.valtech.co.uk/craftsmanship/which-type-of-barista-are-you/</link>
		<comments>http://blog.valtech.co.uk/craftsmanship/which-type-of-barista-are-you/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 00:29:00 +0000</pubDate>
		<dc:creator>Sandro Mancuso</dc:creator>
				<category><![CDATA[Craftsmanship]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[A colleague from New Zealand once was telling me about a type of coffee that was originated there. It's called Flat White Coffee. We were discussing about the difference between this coffee and all the other types of coffee with milk. Eventually we sta...]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.valtech.co.uk%2Fcraftsmanship%2Fwhich-type-of-barista-are-you%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://blog.valtech.co.uk/craftsmanship/which-type-of-barista-are-you/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.valtech.co.uk/craftsmanship/which-type-of-barista-are-you/"  data-text="Which type of barista are you?" data-count="horizontal" data-via="valtech">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><div class="separator" style="clear: both; text-align: left;">A colleague from New Zealand once was telling me about a type of coffee that was originated there. It&#8217;s called <a href="http://en.wikipedia.org/wiki/Flat_white">Flat White Coffee</a>. We were discussing about the difference between this coffee and all the other types of coffee with milk. Eventually we started talking about the quality of the drink and what makes it be better or worse. He mentioned that, of course, the quality of the beans and milk are very important for a good coffee but what makes a good coffee an excellent coffee is the <a href="http://en.wikipedia.org/wiki/Barista">barista&#8217;s</a> ability.</div>
<div class="separator" style="clear: both; text-align: left;">What causes a coffee to be a rubbish coffee then? If the coffee grains are rubbish, you will have a rubbish coffee. However, for a flat white coffee, coffee is just one variable in the equation. There are other variables like how the grains are roasted, steaming the milk at the right temperature, not adding sugar, how the milk is poured, the microfoam on top of the drink, etc. See the <a href="http://en.wikipedia.org/wiki/Flat_white">distinction from cafe con leche for details</a>. Anyway, the point is, a rubbish (or careless) barista, with rubbish coffee will produce a rubbish coffee drink.</div>
<table class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td style="text-align: center;"><img style="margin-left: auto; margin-right: auto;" src="http://2.bp.blogspot.com/_ONTWYUiOUvw/TFtLv2MxYMI/AAAAAAAAAJM/G6R-sxn22UA/s320/RubbishFlatWhite.jpg" border="0" alt="" /></td>
</tr>
<tr>
<td class="tr-caption" style="text-align: center;">Rubbish Coffee</td>
</tr>
</tbody>
</table>
<p>Clearly a business that serves a rubbish coffee will not survive if their main business is to sell coffee drinks. Also, this business will never attract customers that really appreciate a good coffee.</p>
<div style="text-align: center;"><a style="margin-left: 1em; margin-right: 1em;" href="http://1.bp.blogspot.com/_ONTWYUiOUvw/TFtL0ybcCgI/AAAAAAAAAJU/bERxdV2Mv-c/s1600/AverageFlatWhite.jpg"></a></div>
<table class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td style="text-align: center;"><img style="margin-left: auto; margin-right: auto;" src="http://1.bp.blogspot.com/_ONTWYUiOUvw/TFtL0ybcCgI/AAAAAAAAAJU/bERxdV2Mv-c/s320/AverageFlatWhite.jpg" border="0" alt="" /></td>
</tr>
<tr>
<td class="tr-caption" style="text-align: center;">Average Coffee</td>
</tr>
</tbody>
</table>
<p>Producing an average coffee is easy. You buy average coffee grains, hire an average barista and, hey presto, you have an average coffee drink. There is nothing wrong with an average coffee drink if you are <strong>not</strong> in the coffee business. However, if you are in a coffee business, your business will be just another one. No one will remember you and chances are that you will have occasional customers, but not regulars.</p>
<table class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td style="text-align: center;"><img style="margin-left: auto; margin-right: auto;" src="http://2.bp.blogspot.com/_ONTWYUiOUvw/TFtL2vamkjI/AAAAAAAAAJc/K002UKBvm04/s320/GoodFlatWhite.jpg" border="0" alt="" /></td>
</tr>
<tr align="center">
<td class="tr-caption">Good Coffee</td>
</tr>
</tbody>
</table>
<p>Producing a good coffee is not that simple. However, it does not need to be expensive. You don&#8217;t need to buy the best quality ingredients to be able to make a good coffee. Best quality ingredients are expensive and inevitably will make your coffee drinks more expensive as well. You can mitigate this situation hiring a good barista, or maybe someone that has the potential and willingness to become a good one. Clearly, the barista that prepared the coffee above is trying his best to make a good coffee. It&#8217;s still not perfect (purely looking at the pattern on top of the drink) but it is definitely a much better coffee than the normal and average one that you get everywhere. It is clear that the barista cares about it and eventually he will be able to produce a very good coffee.If you are in the coffee business, producing anything less than a good coffee is just <strong>unacceptable</strong>.</p>
<table class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td style="text-align: center;"><a style="margin-left: auto; margin-right: auto;" href="http://3.bp.blogspot.com/_ONTWYUiOUvw/TFtL4QfosNI/AAAAAAAAAJk/mCdTpa0Ue-Q/s1600/ExcellentFlatWhite.jpg"><img src="http://3.bp.blogspot.com/_ONTWYUiOUvw/TFtL4QfosNI/AAAAAAAAAJk/mCdTpa0Ue-Q/s320/ExcellentFlatWhite.jpg" border="0" alt="" /></a></td>
</tr>
<tr>
<td class="tr-caption" style="text-align: center;">Great Coffee</td>
</tr>
</tbody>
</table>
<p>And then you have the great coffee, that is made with great coffee beans, carefully roasted, prepared in a very good coffee machine and by a great barista. Great baristas are proud of their ability to prepare a great coffee and they would not work for too long for a business where coffee making is not treated with the deserved respect.</p>
<p>Now imagine that you are the barista. But instead of coffee, you produce code. Imagine that the the coffee grains, milk and coffee machine are the  tools you use to produce your code like the computer language, the IDE,  the database, etc. Instead of serving coffee for your customers, you are producing software that will be used by your team mates, project sponsors, the company they (or you) work for, external clients, etc.</p>
<p>Like in the flat white coffee example above, of course that the tools we use are very important when producing a good software. However, more importantly, it is the quality of the software engineers that counts. A good barista can make a good coffee even when using average coffee grains, due to his or her ability to combine ingredients and prepare the drink. A bad barista can ruin the coffee even if he or she is using the best quality coffee beans. The biggest difference between the two baristas is how much they care about each cup of flat white coffee they prepare. Their pride and willingness to achieve the best pattern on top of each drink. The great feeling of achievement when they produce a great one. The happiness to see returning customers, queuing and waiting their turn to order the coffee that he, skilfully, prepares.</p>
<p>So, which type of barista are you?</p>
<div class="blogger-post-footer"><img src="https://blogger.googleusercontent.com/tracker/8424060401701893376-8342500768802005514?l=craftedsw.blogspot.com" alt="" width="1" height="1" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.valtech.co.uk/craftsmanship/which-type-of-barista-are-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One team, one language</title>
		<link>http://blog.valtech.co.uk/development/one-team-one-language/</link>
		<comments>http://blog.valtech.co.uk/development/one-team-one-language/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 11:52:00 +0000</pubDate>
		<dc:creator>Sandro Mancuso</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ubiquitous Language]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[On a previous post I was discussing, among other things, how code often doesn't represent the business properly. The code "satisfies" the business requirements but doesn't express them very well. The main reason for that is because we, developers, like...]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.valtech.co.uk%2Fdevelopment%2Fone-team-one-language%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://blog.valtech.co.uk/development/one-team-one-language/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.valtech.co.uk/development/one-team-one-language/"  data-text="One team, one language" data-count="horizontal" data-via="valtech">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>On a <a href="http://craftedsw.blogspot.com/2010/06/wolf-in-sheeps-clothing.html">previous post</a> I was discussing, among other things, how code often doesn&#8217;t represent the business properly. The code &#8220;satisfies&#8221; the business requirements but doesn&#8217;t express them very well. The main reason for that is because we, developers, like to abstract business terms and rules into technical implementations and patterns.</p>
<p>Very often, we discuss the user stories (requirement documents, use cases, whatever the methodology used is) with the &#8220;domain experts&#8221; and as soon as we understand what needs to be done, we map the requirements to a <a href="http://craftedsw.blogspot.com/2010/06/wolf-in-sheeps-clothing.html">technical design</a> (actions, services, entities, helpers, DAOs, etc) that is <a href="http://craftedsw.blogspot.com/2010/06/wolf-in-sheeps-clothing.html">completely meaningless</a> to the domain experts. Sometimes, even among developers themselves, different names and expressions are used to refer to the same thing. The main reason is that different developers talk to different domain experts and come up with different abstractions. As a result,  the usage of different terms to describe requirements leads to confusion, duplication of code and unpredictable behaviour in the system.</p>
<p>The first step towards an expressive and domain-focused design is to have a common language among ALL members of the team. ALL means ALL: developers, domain experts (business analysts, users, product owner, etc), testers, project manager and anyone else involved in the project.<span id="more-308"></span></p>
<p>Developers very often say that domain experts don&#8217;t understand objects and database and because of that, they need to &#8220;translate&#8221; business requirements into software design. However, we developers don&#8217;t understand the business as well as the domain experts do, what more often than not, leads to imperfect and confusing abstractions.</p>
<p><strong>The Ubiquitous Language</strong></p>
<blockquote><p><em>A language structured around the domain model and used by all team  members to connect all the activities of the team with the software.</em></p>
</blockquote>
<p><a href="http://domaindrivendesign.org/node/132">The Ubiquitous Language</a> is one of the most important things, if not the most, in <a href="http://domaindrivendesign.org/">Domain-Driven Design</a>. The main idea is that the whole team speaks a single language, that is the business language.</p>
<p> </p>
<div class="separator" style="clear: both; text-align: center;"><a style="margin-left: 1em; margin-right: 1em;" href="http://4.bp.blogspot.com/_ONTWYUiOUvw/TBgVFwNWmdI/AAAAAAAAAJA/2ADOaIfW-fc/s1600/ubiquitouslanguage.jpg"><img src="http://4.bp.blogspot.com/_ONTWYUiOUvw/TBgVFwNWmdI/AAAAAAAAAJA/2ADOaIfW-fc/s400/ubiquitouslanguage.jpg" border="0" alt="" width="400" height="182" /> </a></div>
<div class="separator" style="clear: both; text-align: left;">Business terms related to the software to be implemented must enter the ubiquitous language and each of these terms must be understood clearly by all members. During requirements gathering sessions and planning meetings, these terms must be captured and made available to everybody. Technical terms from the development team and business terms not relevant for the piece of software being implemented MUST NOT enter the ubiquitous language.</div>
<div class="separator" style="clear: both; text-align: left;"><strong>Capturing the ubiquitous language</strong></div>
<p>In order to capture the ubiquitous language, it is mandatory that you work on a iterative software development environment. Trying to capture the ubiquitous language up-front could straitjacket the whole process, inhibiting team members to make the necessary changes along the way. As the language is used to express the business requirements, it is natural that it evolves during the lifetime of the project, where new terms are added, deleted and also re-defined.</p>
<p>Methodologies like Extreme Programming (XP) says that the only documentation should be the code. Not even comments on the code are appreciated, since they can easily get out of sync with the code. The code should be the only documentation since it is the only one that represents exactly what the system does.</p>
<p>On the other hands, we have UML (Unified Modeling Language), that in theory, should be a great candidate to document the ubiquitous language since the whole purpose of UML was to document requirements and express them in a language that is common to developers and business people.</p>
<p>In summary, showing code during discussions with domain experts, testers and other members of the team during a design session is not exactly a fantastic idea. Also, using just UML, because of its bureaucracy, rules and details is also a bad idea. The whole UML notation could easily straitjacket the creative process during the exercise.</p>
<p>There are many discussions about what would be the best way to capture the ubiquitous language. My preferred way is to draw diagrams (boxes and arrows mixed with some well understood UMLish notation) where each box represent a &#8220;<strong>domain object</strong>&#8221; (aka domain concept). A domain object can be anything that is expressed by the business, like <em>client, organisation, product, route specification,  sales system</em>, etc. They would all be boxes. Add to it a few arrows linking the boxes and with just a couple of words explaining how they related to each other. Sometimes a mixture of a class and sequence diagram (or an active diagram) can be very helpful, but don&#8217;t get to picky about any notation. Preferably, draw on a white board, take a picture and store that on the wiki. For further sessions, just open the wiki and re-draw just the bit of the design that is important to the feature being discussed. Make the necessary adjusts on the white board, take another picture and stored it on the wiki again. There is much more to that, if you want to dive into <a href="http://www.agilemodeling.com/%20%20">agile modeling</a>, but I will leave it to another post.</p>
<p>This goes way beyond transforming nouns and verbs into classes and methods. Taking the examples above, for example, <em>client, organisation</em> and <em>products</em> could be transformed in entities; <em>route specification</em> could be a strategy class used by a <em>routing service</em> (that would also need to be added to the diagram and to the ubiquitous language); <em>sales system</em> would be an external system that we need to integrate to, etc.</p>
<p><strong>Making the code more expressive</strong></p>
<div class="separator" style="clear: both; text-align: left;">The code should reflect all concepts exposed by the model. Classes and methods should be named according to the names defined by the domain. Associations, compositions, aggregations and sometimes even inheritances should be extracted from the model.</div>
<div class="separator" style="clear: both; text-align: left;">Sometimes, during implementation, we realise that some of the domain concepts discussed and added to the model don&#8217;t actually fit well together and some changes are necessary. When it happens, developers should discuss the problems and/or limitations with the domain experts and refactor the domain model in order to favour a more precise implementation, without ever distorting the business significance of the design.</div>
<div class="separator" style="clear: both; text-align: left;">Ultimately, the code is the most important artefact of a software project and it needs to work efficiently. Regardless of what many experts in the subject say, code implementation will have some impact on the design. However, we need to be careful and very selective about which aspects of the code can influence design changes. As a rule, try as much as you can to never let technical frameworks limitations influence your design, but as we know, every rule has exceptions.</div>
<div class="separator" style="clear: both; text-align: left;">A common implementation problem that very often get in the way is mapping objects to databases using ORM tools. In this case, bending the model a little bit in favour of a more <em>realistic </em>relation among entities is not a bad thing. Just make sure that changes like that are represented in the model and understood by everyone involved.</div>
<div class="separator" style="clear: both; text-align: left;"><strong>DOs and DON&#8217;Ts </strong></div>
<ul>
<li>Don&#8217;t try to model everything.<strong> </strong>Focus on the core of your application. We are not working on a waterfall or Unified Process project here. </li>
<li>Try to model just the key concepts of the domain problem;</li>
<li>Do not clutter your models with too much details. Keep it focused on the main responsibilities;</li>
<li>Limit your discussions and changes in the model to the business concepts (domain objects) related to the user story being discussed;</li>
<li>Don&#8217;t add architectural concepts like DAOs, Actions, etc. We are not writing implementation diagrams. </li>
<li>As your application grows, break the application into multiple models (domains), explicitly defining the context and boundaries within which a model applies. This is called <a href="http://domaindrivendesign.org/node/91">Bounded Context</a> in Domain-Driven Design.</li>
<li>Avoid thinking purely on the implementation when designing your model. Understanding and modeling the business is the most important thing here. </li>
</ul>
<div class="separator" style="clear: both; text-align: left;"><strong>Challenges of a Model-Driven Design</strong><strong> </strong></div>
<div class="separator" style="clear: both; text-align: left;"><a href="http://domaindrivendesign.org/node/121">Model-Driven Design (MDD)</a> is more an art than a science. It takes a lot of practice and willingness to get it going and get it right. Refactoring towards deeper insights must be seen as a positive and essential part of the project development. TDD and continuous integration are also essential for any agile and domain-driven application.</div>
<div class="separator" style="clear: both; text-align: left;">The goal of <a href="http://domaindrivendesign.org/node/121">MDD</a> is having the software expressing a <a href="http://domaindrivendesign.org/node/101">deep</a> and <a href="http://domaindrivendesign.org/node/131">supple</a> design.<a href="http://www.blogger.com/goog_972650201"><br /></a></div>
<div class="separator" style="clear: both; text-align: left;"><a href="http://domaindrivendesign.org/node/101"><br /></a></div>
<div class="separator" style="clear: both; text-align: left;">Last buy not least, developers with good <a href="http://en.wikipedia.org/wiki/Object-oriented_design">Object-Oriented Design</a> skills are needed in the project. The lack of design skills could easily transform ANY software project in a total failure in the long term.</div>
<div class="separator" style="clear: both; text-align: left;"><a href="http://domaindrivendesign.org/node/101"><br /></a></div>
<div class="separator" style="clear: both; text-align: left;">Source</div>
<div class="separator" style="clear: both; text-align: left;"><a href="http://domaindrivendesign.org/">http://domaindrivendesign.org/</a></div>
<div class="separator" style="clear: both; text-align: left;"><a href="http://domaindrivendesign.org/node/91%7C">http://domaindrivendesign.org/node/91|</a></div>
<div class="separator" style="clear: both; text-align: left;"><a href="http://domaindrivendesign.org/node/132">http://domaindrivendesign.org/node/132</a></div>
<div class="separator" style="clear: both; text-align: left;"><a href="http://domaindrivendesign.org/node/121">http://domaindrivendesign.org/node/121</a></div>
<div class="separator" style="clear: both; text-align: left;"><a href="http://www.agilemodeling.com/">http://www.agilemodeling.com/</a></div>
<div class="blogger-post-footer"><img src="https://blogger.googleusercontent.com/tracker/8424060401701893376-2937834842513651382?l=craftedsw.blogspot.com" alt="" width="1" height="1" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.valtech.co.uk/development/one-team-one-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="" length="" type="" />
		</item>
	</channel>
</rss>

