The House of Geek

It’s probably the first time I write about my personal life on this blog but don’t worry: no picture of my cats (I don’t have cats) nor of my latest knitting projects (even though knitting blogs and the like seem to pop up by millions everyday I don’t have the passion for it… who said “yet”?).

Three months ago the girlfriend and I moved to a new house. After 2 years in a 35 square meter apartment right in the city center, 4 years in 45 square meter just outside the city, we now have a 110 square meter house just for the both of us (a bit outside of the city center but a 20 minute bike ride can’t be that bad).

We moved to a house built in 2008 (and now the geek in me is back behind the keyboard) that has all the things I used to dream of while running cables all around the places I lived in: 14 Ethernet wall sockets around the house and a 100Mb fiber optic Internet access (for a bit less than $50 a month).

The cupboard under the stairs

The cupboard under the stairs, heart of the gigabit network

I just have one comment though: the switch could have been included with the house but I bought a Netgear ProSafe Ethernet Switch (GS116) and must say that I’m quite happy with it so far.

I have the NAS, the media player, a desktop, the printer, a Sonos Play:5 and even the Blu-ray disc player (I still don’t want to understand why a freaking movie player should need software updates) connected to it and they seem to all get along pretty well.

WordPress – simple links to share a post on…

For various reasons you sometimes don’t need or don’t want the JavaScript overhead that comes with the standard “Share On” buttons. I personally find those buttons annoying as they often take a lot of space on a page, are hard to style (alignment) and can be slow to load.

Here is a collection of HTML only links – the way they look in the content.php file of my WordPress template – that you can add to a WordPress post template for your readers to share on Twitter, Google+, Reddit, Flattr & Facebook.

the social media mess

Share on Twitter

<a href="http://twitter.com/home?status=Currently reading <?php the_permalink(); ?> @lroguet" title="Share on Twitter" rel="nofollow" target="_blank">Twitter</a>

Note: you probably want to change @lroguet with your own Twitter username.

Share on Google+

<a href="https://plus.google.com/share?url=<?php the_permalink(); ?>" title="Share on Google+" target="_blank" rel="nofollow">Google+</a>

Share on Reddit

<a href="http://www.reddit.com/submit?url=<?php the_permalink(); ?>" rel="nofollow" target="_blank" title="Share on Reddit">Reddit</a>

“Share” on Flattr

<a href="https://flattr.com/submit/auto?user_id=lroguet&url=<?php the_permalink(); ?>&title=<?php the_title(); ?>&language=en_GB&category=text" title="Flattr this post" target="_blank" rel="nofollow">Flattr</a>

Note: you probably want to change lroguet with your own Flattr username.

Share on Facebook

I don’t have a “Share on Facebook” link at the bottom of my posts because I believe that is not the audience I target with my blog (I might miss a couple of readers but I’m fine with that) but I could as well add one with this line of code.

<a href="https://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>&t=<?php the_title(); ?>" rel="nofollow" target="_blank" title="Share on Facebook">Facebook</a>

measure execution time using EJB3 interceptors

Once in a while I am involved in the recruitment process of Java developers (both junior & senior) and run the technical part of the first interview. After some time I realized that with just a handful of questions you can pretty much tell whether the candidate is trying to fool you or not.

To a candidate claiming 15+ years of experience with Java including the latest and greatest features of various frameworks, from Hibernate to EJB 3.1 (and the list looked quite long on the CV), I recently asked: “how would you measure the execution time of a method?”

Candidate: “Well, I’d get a timestamp at the beginning of the method, one at the end and then I’d print or log the difference.”

Me: “Alright (that’s the first answer you would expect from anyone). But what if you can’t (for any reason) modify the method’s body?”

Candidate after a minute or so: “You can’t. You would have to do it that way. It’s the only solution.”

I don’t pretend to be an expert of some sort but I was excepting a bit more from someone who five minutes earlier claimed to have extensive knowledge of EJB 3.

Here is what I was after (this might not be the best solution – and please comment on it – but it does work and answer the question).

First I would create an interceptor (a class with a single method that is going to wrap the call to the method we want to monitor).

public class MethodExecutionTimeInterceptor {
    
    @javax.interceptor.AroundInvoke.AroundInvoke
    public Object time(javax.interceptor.InvocationContext.InvocationContext ctx) throws Exception {

        Logger logger = LoggerFactory.getLogger(ctx.getMethod().getDeclaringClass());
        long start = System.currentTimeMillis();
        
        try {            
            return ctx.proceed();
        }
        finally {            
            logger.info("method " + ctx.getMethod().getName() + " executed in " + (System.currentTimeMillis() - start) + " milliseconds");            
        }
         
    }
    
}

And secondly I would just annotate the method I want to measure the execution time of with the @Interceptors annotation.

@Interceptors({MethodExecutionTimeInterceptor.class})
public List<String> getAllNames() {
   // do something here and return a list of String  
}

That’s it.

how to make good teams great – episode 2

Feed your brain

In a rapidly changing environment – as the IT world is – you want to stay on top of things and you can’t only rely on techniques, languages, frameworks & technologies you played around with at school or in your current projects.

You must feed your brain with new ideas, new cool stuff (even old cool stuff by the way) and there are various places you can get brain food: conferences (if you or your company can afford it), bar camps & user groups (often free), brown bag sessions over lunch at the office, …

Say “well done”

Give your co-workers credit for a well done job. It does not necessarily need to be for big accomplishments only and you should also communicate on smaller achievements. Kudos can be given via an email sent to the Kudos mailing list or can take the form of a small present you know will be appreciated (a chocolate bar for instance).

Keep in mind that not everyone likes to be a star (even for a minute) and it is important that one gets kudos only if she/he wants.

That was easy!

In my team we use one of those EASY buttons (that says “that was easy” when you press it) for telling the floor someone has achieved something (small or big). It is not exactly the same as saying “well done” but still is a nice way of showing some pride.

Eat your own dog food

As a developer you should already be familiar with the quick feedback that a suite of unit tests provides but that is still pretty “low level”. Feedback is important but quick feedback is even more important since it helps you catch bugs early and fix them early (at a lower cost).

So what about testing the software as a whole? What about using it yourself? Eating your own dog food is all about using the software you develop instead of simply developing, shipping the product to the testers and waiting for feedback. By doing so you also see your software with your end users’ eyes (may it be a tester – internal – or a customer – external) and have a better understanding of their needs.

Experimentation time – motivation through innovation

By giving the developers the opportunity – read time – to explore and implement new ideas a company is making an investment that may or may not pay back. But a lot of products were born during experimentation time (FedEx days at Atlassian, Google Fridays, …) and if a company can afford to set a couple of hours aside for their employees to think out of the box it should go for it.

“Do what you want” time

The “do what you want time” differs from “experimentation time” in the sense that it is more about assigning some time (like 20%) for the developers to improve or implement a feature not yet in the backlog in an existing project.

You can find the slides from Sven’s presentation at Jfokus here.

book circle @ work, my own little story

If there was only one thing I wanted to take with me when I changed job in May 2011 it definitely was the book circles a colleague of mine was organizing twice a year. I simply love books and everything that come with them: knowledge, stories, smells, bookshelves, …

But as I started to set such an activity up at my new work place I realized it was much easier to just wait for an email announcing the upcoming titles, pick one up and then attend the sessions than actually make it happen. As of today we are about to finish our second book and the third one is on the line. Time to reflect on my own little experience I suppose and share my dos and don’ts.

Work your plan

When presenting the idea to your manager you must come up with a strong case in order to justify both the time and the financial investments of the activity and you must show your manager you already have worked the why, when and how questions.

If knowledge sharing, skills development, team building activities are already in your company’s goals towards employees satisfaction things are going to be easier. If not those are three benefits from running a book circle you can for sure sell to any open minded manager.

One step at a time

In the best of world you would probably want to offer all employees in the company a large list of books to choose from and have everyone participate in the discussions. But that simply does not work out of the box.

Start small with 3 book titles and your team mates (8 persons is a pretty good number: you are pretty much sure you can run an interesting discussion even when a couple of your colleagues are home ill) and get things rolling with a couple of books, from choosing the title, ordering the books, reading them and discussing them, before targeting a bigger audience.

Take a step back

The biggest mistake I made (in my opinion) when I started up with the idea was to choose a book that I thought was a perfect match for a bunch of developers: “Seven Languages in Seven Weeks” from the Pragmatic Bookshelf.

But it turned out not to be a very good choice for a first circle. It was hard to get the discussion start and flow and even though the topics looked familiar and in line with a developer’s job I must admit discussing Erlang when no one in the room has experience with the language is a challenging tasks. I will probably bring the book back in a circle in the future when everyone – including myself – feels more comfortable with the ideas behind the book circle and has a better understanding of why we are doing it for and how.

Pragmatic Thinking & Learning

We gave up after 4 languages and had a fresh start with “Pragmatic Thinking & Learning” (also from the Pragmatic Bookshelf). From the first session (discussing chapters 2 and 3) we could already feel it was a better choice and it only got better chapter after chapter with nice and constructive discussions going on.

Set the rules

For the first circles you need to come up with a complete solution. You need to define a couple of book titles (3 is a good number), organize a vote, order a copy of the chosen book for everyone, work the reading schedule out and book sessions accordingly. You also need to act as a moderator during the discussions and have a set of points and topics you can use to get the conversation rolling.

Once everyone is familiar with the activity you can start involving others in the logistic, in the moderator role, … In the end you should be able to run several sessions in parallel on the same or different books. That’s what I am aiming for at least.

Current setup

  • Reading “Pragmatic Thinking & Learning“, one chapter a week
  • Discussion every second Friday over lunch (the company buys wraps or sandwiches)
  • One hour meeting starting with lunch and chitchat (10-15 minutes) and then discussion on the chapters
  • Participants (developers & manager) are adding interesting book titles to the wish list on the Wiki page I created for the activity

To be continued…

how to make good teams great – episode 1

As we are implementing new development processes in the department I work for teams are going through a lot of changes. Attending Sven Peters’ (@svenpet) talk on “7 things: how to make good teams great” at Jfokus was an obvious decision and I’m glad I went. It was really nice to hear that some of the actions we are taking right now have proven to be successful and appreciated by teams in other companies.

I’m not going to write about the 7 things at once but will break them down in a couple of posts. Let’s start with “It’s flow time” and “Report robot”.

It’s flow time

Ever heard of context switching? It is probably one of the biggest problem of so called knowledge workers who – according to various studies – waste 20% to 30% of their time switching from one context to another. And that problem is even more important in an open space where one can easily be disturbed: a colleague or a manager stopping by your desk for a “quick” question (notice the “quick” there: sounds familiar?), someone just walking by, …

Unfortunately there is no “quick” question or task and you will always waste those 20% to 30% of your time (that’s almost 3 hours of a normal day at the office) switching context.

To Not Disturb

In such work environments it is therefore all about finding the right balance between productivity and collaboration. Collaboration is the idea behind open offices but productivity is not and you need to build virtual fences in order to secure high productivity periods – as if you were working in a closed office – over the day or week.

  • do not disturb time – together with the team members agree on a day (or half a day) when it is not allowed for an outsider to break the flow. The team needs to communicate when it’s alright to disturb and when it’s not. It could be done with a red flag on the desks or with the team members all wearing the same and explicit t-shirt for instance. All you need is basically a visual clue that people can easily interpret.
  • support guy of the day - one of the team member is responsible for isolating the team from the outside world and handles all the questions, meetings and so on. It is a good idea to rotate among the team members so it’s not always the same person being disturbed.

Andy Hunt dedicates a whole chapter on the subject – Manage Focus – in “Pragmatic Thinking & Learning: Refactor Your Wetware” and suggests team to “establish rules of engagement to manage interruptions”.

Report robot

Constant feedback is one of the key factor of successful agile teams and there are a great deal of tools that can help feeding the team with relevant information.

In your day to day activities you probably use a wiki to share documentation and knowledge. You probably (and you better do) use a bug tracking system to manage the defects in the code your write. You also might use a build system to automate builds and deployments.

When you think about it the list is much longer than that and it is almost impossible for a single person to keep track of all the data the different tools provide. If your company (read manager) understands the issue and is willing to invest some money in it maybe it’s time to build information radiators!

Information radiators are central locations (a web page, a flat screen TV close to the team) where the feedback from all those tools can be presented in a concise and visual manner: charts, green and red lights, numbers, … for anything that adds value to the team productivity and spirit.

Jfokus 2012 | 13-15 February | Stockholm, Sweden

Going to a good conference usually makes me want to write and keep this notepad alive. Going to a very good – and Jfokus 2012 was a very good conference in my opinion – makes me do it.

Jfokus 2012

In the next couple of days (understand weeks) I will force myself to go through the notes I took during the last 3 days and come up with a couple of posts. I swear.

My schedule

Day 1

  • Spring into the Cloud by Josh Long & Chris Richardson
  • A Practical Introduction To Kanban by Marcus Hammarberg & Joakim Sundén

Day 2

  • Enterprise Java in 2012 and Beyond by Juergen Hoeller
  • Player Framework 2.0 by Peter Hilton
  • Maven vs Gradle, On your marks, get set, go! by Hardy Ferentschik
  • Unleash Your Domain by Greg Young
  • An Intro to Hadoop by Eva Andreasson
  • Application Security for Rich Internet Applications by John Wilander
  • The road to REST by Rickard Öberg

Day 3

  • 7 Things: How to make good teams great by Sven Peters
  • HTML5 with Play Scala, CoffeeScript and Jade by Matt Raible
  • Zero Downtime Continuous Deployment of Java Web Applications by Fabiane Bizinella Nardon
  • It Is Possible to Do Object-Oriented Programming in Java by Kevlin Henney
  • Scala in Action by Heiko Seeberger
  • We visualized, we saw, we changed by Leonard Axelsson
  • Cool Code by Kevlin Henney

getting started with CodeIgniter on Ubuntu Lucid Lynx (10.04)

As I am currently playing around with CodeIgniter (an open source PHP web application framework), I thought I could write down the few software installation steps one needs to go through in order to get started on a fresh Ubuntu box. And all you really need is a LAMP (Linux Apache MySQL PHP) setup that can be up and running in less than 10 minutes (assuming the OS is already installed of course).

Install Apache

sudo apt-get install apache2

Install MySQL

sudo apt-get install mysql-server

Install PHP (with MySQL support)

sudo apt-get install php5 php5-mysql

Enable the rewrite mod in Apache

This is only needed if you plan to get rid off “index.php” in your CodeIgniter application’s URLs.

sudo a2enmod rewrite
sudo gedit /etc/apache2/sites-available/default 
<!-- Edit the configuration and change AllowOverride None to AllowOverride All -->
<Directory /var/www/>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Order allow,deny
   allow from all
</Directory>

Add your site to your local web server

You could probably just extract the CodeIgniter archive into /var/www/ but you also could have your application in your home folder (/home/lroguet/www.mysite.com/ for instance). In that case, all you need to do is create a symbolic link in the Apache web directory pointing to your application folder.

cd /var/www
sudo ln -s /home/lroguet/www.mysite.com/ www.mysite.com 

Restart Apache

sudo /etc/init.d/apache2 restart

Here you go, just point your web browser to http://localhost/www.mysite.com/ and you should see the CodeIgniter example pages.

behaviour driven unit test design in Java

Writing unit tests is not that hard but writing good unit tests which, when they fail, tell you exactly and verbosely why and where it did not go right is not as trivial as it seems.

Let’s say we have a class that represents a square. The only operations we can perform on a square are: getting its surface and doubling the side length.

public class Square {

  private int sideLength;

  public Square(int sideLength) {
    this.sideLength = sideLength;
  }

  public int getSurface() {

    return this.sideLength * this.sideLength;

  }

  public void doubleSideLength() {

    this.sideLength = this.sideLength * 2;

  }
  
}

To test that piece of code, we could probably write a unit test that will look like:

public class SquareTest {

  public void testSurfaceWhenSideLengthIsDoubled() {
    
    Square a = new Square(5);
    Square b = a; b.doubleSideLength();
    
    assertEquals(a.getSurface(), b.getSurface() / 4);

  }

}

From a programmer’s point of view the code above perfectly makes sense but – even if the example is rather simple – it does not really tells us what scenario we want to test here. If this piece code would be read by a product manager, she would probably not understand it (oh well, in that case she probably will but unit tests can be a lot more complex than that).

What about making the code a little bit clearer and telling us a story? There are frameworks for that you could argue (like JBehave) but do we need a framework – and all the configuration, XML files that come with – for everything really? What if we just rewrite the test class so it is more narrative?

public class SquareTestEnhanced {

  private Square square;

  public void test_side_length_x_2_gives_surface_x_4() {
    
    when_doubling_is_done_on(new Square(5));
    then_surface_must_be_multiplied_by_4();

  }

  private void when_doubling_is_done_on(Square s) {

    this.square = s;

  }

  private void then_surface_must_be_multiplied_by_4() {

    Square s = this.square; s.doubleSideLength();
    assertEquals(this.square.getSurface() * 4, s.getSurface());

  }

}

Isn’t it enough? Can my product manager understand what we are testing between lines 5 and 10?