Review process for Test-Driven Development Teams – TDR

In my enterprise we recently introduced Test-Driven Development (TDD) as a programming technique for delivering robust and reliable software.

The lifecycle of tasks is the following:

  • To Do
  • In Progress
  • For Review
  • Verified
  • Done

Task lifecycle

The “To Do” and “In Progress” phases are self-explanatory. When a task goes in “For Review” the developer choose, with a round-robin approach, one of the team mates, and together they review the code in order to ensure quality (eg. check the code is clear, correct design and design patterns, high code coverage). Last but not the least it comes the “Verified” phase, during which the developer ensure that new features behave as expected in System Test.

There have been serveral attempts to make the “For Review” phase appealing, interesting and efficient. After some meeting and discussions we came up with the following check-list.

  • Functionality
  • Overall Design
  • Efficiency
  • Development Prctices
  • Test
  • Error Handling
  • Log

Even if we, in my humble opinion, perfectly described what should happen in a review phase, when we put it in practice, results were not so exciting as we were expecting.

What you really want to achieve in a code(peer)-review, is to ensure that the code is clear, well designed and correctly tested (in a TDD fashion!). What we were doing was to make the developer lead the review process and tell what the code was doing. Under these circumstances a reviewer would make zero or nearly no effort in understanding what the code was actually doing. Finally the “code coverage check” simply turned into a “check sonar code coverage %”. This could guarantee in really few circumstances that the quality and clarity criteria were met.

Since the TDD approach expects tests to be written before the actual code, why reviews should not be structured in the same way?

Few days after I finished to read the “Clean Code” book, I decided to play a game with a colleague for testing how well I learnt principles uncle bob explained in his book.

I asked him to guess, just reading from a bunch of test classes, what my code would have done. The result was surprising. With only a few variables and methods renaming, my colleague was able to correctly guess what my code was trying to do.

The review process honestly started very slowly because I, the developer, was giving as less hints as possible and was letting my colleague to progress alone as much as he could. Once sorted the initial naming incongruences, the review itself turned into a vivid and exciting conversation.

We agreed that

  •  the code was clear because he could guess with a little effort and nearly no suggestions what the code was trying to do.
  •  the code was well designed because class hierachies and patterns I used were thoughtful
  •  I correctly followed the TDD approach because I guaranteed a very high code coverage

What I learnt that day is that in order to understand whether or not you wrote clean and well tested code is to simulate somebody to work on your code in a day you’re off. If he/she’s able to do that without ringing you.. well.. you did a good job!

Thoughts on the review process

  1. Reviews have to be interesting. If the review process turns into something boring, it will not give results you expect. This can be achieved challenging your reviewer!
  2. In a review process the reviewer is the one who has to talk the most, if it is the developer, well, you have a smell there!

How to create a shortcut to copy a password to clipboard (so to be ready to be pasted)

Have you ever dreamed to have one or multiple password ready to be used just making use of a shortcut?

Well if you make use of ubuntu (even in a VM) here is the solution for you!

Install xclip

xclip is an Ubuntu app for dealing with stuff in the “clipboard”. I order to install it, please execute:

sudo apt-get install xclip

Once xclip has been installed you have to create a file that contains the password.


echo "the_password" > /home/[username]/.my_unix_password
Creating a shortcut

There is a Keyboard menu in Ubuntu.

  • On the 12.04 the menu is at: Applications > System Tools > System Settings > Keyboard

Steps are:

  1. Select the Shortcuts panel
  2. Select Custom Shortcuts subpanel
  3. Click the +
  4. Enter the name of the shortcut (eg Copy Linux Password to Clipboard)
  5. in the command field enter: “xclip -i /home/[username]/.my_unix_password -selection clipboard”
  6. Click Apply
  7. Right click on Disabled. It should change into New Accelerator
  8. Now press the combination of keys you want to use to copy your password to clipboard (eg. CTRL+ALT+P)
  9. Finally close the keyboard menu

Now open a text editor and press your magic key combination…. now try to paste!

Et voila!

Be Agile, don’t be frAgile

The last thing you want when you work in an agile environment, is to apply agile’s concepts wrongly or don’t apply them at all.
Agile methodologies require the whole organization to act in an agile way where cooperation and continuous feedbacks are the keys of the success.

Although it’s easier to give birth to an agile team at the very beginning of a project, is also true that there is hope to become agile for a team that is still working in archaic and old methodologies.

The journey is long but you will get there, eventually. The most important thing to become an excellent team, is to chase the main road and never pull out trying to get shortcuts that will, somehow, do the job.

For this reason, when the friend and colleague @castigliego came to me with the illuminating idea of collecting stories about “Fragile Software Development” and bad agile experiences, we decided to create the hashtag #fr_agile in twitter.

We would like to make #fr_agile a channel where people tell their experiences about bad application of agile concepts or misunderstanding of agile’s principles and, possibly, the way they got out of there.

This sharing activity might become an incredible source of ideas and knowledge so that readers might be able to identify a smell in their team and be able to get rid of it before it could possibly make some victims.

As in a perfect agile fashion, even in this case communicating and sharing are the keys.

Quick HSQLDB How To

HSQLDB is a 100% pure Java SQL database. I often make use of it when I’m working on proof of concepts or tests.

You can download it at

In order to run it, it’s required to have a JVM installed and the JAVA_HOME environmental variable pointing to it.

I recommend to create a folder in your home directory (or wherever else) where storing all the files required for your dbs.

In order to start a db instance, simply execute:

java -cp ../hsqldb.jar org.hsqldb.server.Server --database.0 file:mydb --dbname.0 db_name


  • ../hsqldb.jar is the path to the hsqldb library
  • mydb is the prefix of the file names that will be create
  • db_name is the name of the schema we will have to use when connecting

A very nice utility application that is shipped with the hsqldb binary is the DatabaseManagerSwing. It’s a simple one but it’s enough to navigate and query your freshly created db. Syntax for starting it is:

java -cp ../hsqldb.jar org.hsqldb.util.DatabaseManagerSwing

DatabaseManagerSwing remembers last connections you’ve created and helps to save plenty of time when you need to switch from a db to another.

This quick, nearly useless, tutorial will come in help with one of the next post I’m going to create.


Keyboard and mouse stop working in Virtualbox guest

If you ever experience your mouse and or keyboard not working in your Virtualbox guest OS and the only way to make them work again is rebooting, try to install the following packages:
sudo apt-get install scim-bridge-client-qt scim-bridge-client-gtk

How to mount a windows shared drive with a name containing spaces

If you are trying to mount a Windows shared folder that has its name containing spaces you can easily mount it sticking 40 instead the space character:

For example, if the box is at the address and the name of the shared folder is "Name with spaces" you can add the following line into your /etc/fstab

// /mnt/name-with-spaces bla bla bla


Execute a command via SSH and terminate the connection without waiting for the command to finish

A few days ago I was trying to update the script used to build the application on which I’m working. Together with the build I also wanted to integrate the script so to release the app on test boxes and restart the JBoss instance.

While the stop was working as a piece of cake, the restart of the server was keeping my ssh connection alive, and causing the release script to not finish.

After a bit of googling that the ssh syntax you’ll have to use if you want to send a command via ssh, redirect std out/err, and close the ssh connection:

ssh username@host “nohup command_to_execute > /dev/null 2>&1 > /../log_folder/log_file &”

Hope this will help someone of you out there 🙂



Meaning of load average of the top Linux command

Meaning of “load average” of the top Linux command

The “load average” information given by the top command is of fundamental importance. But how to correctly understand the meaning of it? Which value are bad? Which good?

This article is just simply brilliant in explaining how to interpret this value:



Mapping a many-to-many join table with extra column using JPA


It is not straightforward to realise a many-to-many association with JPA when in the join table there is at least an extra column. In this small tutorial I’m going to show how to design entity objects that will handle the many-to-many relation and which annotations are needed in order to fix a redundancy that we will see in the solution adopted in the following wiki.

This tutorial is a mix up of different sources. The first solution I’m going to show is the one suggested in a wiki.

Mapping a Join Table with Additional Columns (in a JPA pure style)


A frequent problem is that two classes have a ManyToMany relationship, but the relational join table has additional data. For example if Employee has a ManyToMany with Project but the PROJ_EMP join table also has an IS_TEAM_LEAD column. In this case the best solution is to create a class that models the join table. So an ProjectAssociation class would be created. It would have a ManyToOne to Employee and Project, and attributes for the additional data. Employee and Project would have a OneToMany to the ProjectAssociation. Some JPA providers also provide additional support for mapping to join tables with additional data.

Unfortunately mapping this type of model becomes more complicated in JPA because it requires a composite primary key. The association object’s Id is composed of the Employee and Project ids. The JPA spec does not allow an Id to be used on a ManyToOne so the association class must have two duplicate attributes to also store the ids, and use an IdClass, these duplicate attributes must be kept in synch with the ManyToOne attributes. Some JPA providers may allow a ManyToOne to be part of an Id, so this may be simpler with some JPA providers. To make your life simpler, I would recommend adding a generated Id attribute to the association class. This will give the object a simpler Id and not require duplicating the Employee and Project ids.

This same pattern can be used no matter what the additional data in the join table is. Another usage is if you have a Map relationship between two objects, with a third unrelated object or data representing the Map key. The JPA spec requires that the Map key be an attribute of the Map value, so the association object pattern can be used to model the relationship.

If the additional data in the join table is only required on the database and not used in Java, such as auditing information, it may also be possible to use database triggers to automatically set the data.

Example join table association object annotations

As you can see in this solution the ProjectAssociation class contains twice the information related to Employee and Project. As explained above, this is due to JPA specification. Googling I found another solution to this problem that allowed me to avoid the redundancy.

Hibernate annotations: The many-to-many association with composite key (in a pure JPA style without redundancy)


This post contains an evolution of another solution realized in 2006. Since things changed a bit in the meanwhile, the original solution was not the best.

Basically what the author is trying to do is to hold a relation between three item: Produc, Item and ProductItem.

Here is the last part of the post in which the author introduce the solution:

The database part is the same: we have three tables (item, product and product_item), two POJO classes, and two classes for a many-to-many association and its primary key. The main difference from Marsel’s solution is that I’m not using any kind of “fake” properties on ProductItem in order to reference Item and Product, but just a plain transient properties delegating to ProductItemPk.

Here is the source:

This solution is perfect from a model point of view. I used this solution in my project and together with Spring, Hibernate and Maven I’ve been able to generate the schema in an automatic fashion (hbm2dll plugin). The schema produced is exactly what you would expect. Unfortunately JPA doesn’t allow developer to use this configuration to work with inserts and updates. For instance if you have an Item object with few ProductItem and you perform an insert on the Item, ProductItem object contained in the list will not be inserted in the database. Same stuff happens for a Product and its ProductItem list. JPA in this case won’t help us anymore. The only way to make inserts and updates to work in cascade, we must recur to provider’s specific annotation. The source code below is the final evolution of the previous example. The JPA provider I used is Hibernate. Here is the code for the Product class, use the same annotation for the Item class as well and Hibernate will take care to insert/update ProductItem (if any) as well.

Since I only have experience with Hibernate I invite all the reader that have expertise with other JPA provider to reply to this post with the solution offered by other framework such as iBatis.

Thanks for have reading this tutorial and feel free to reply with comments.


If you think this article was usefull to you, please donate a few mBTC to 1D4Li5ckG81JLbBt3Kb2UT1wQqHZddVqEL 🙂

I gotta feeling

I think there will never be more perfect night to start my blogging activity.

First of all I really think there’s something wrong with myself. So far, every time I asked to someone to guess where I’m from they never guessed at the first shoot. I received the most various answers, from Romania to Egypt, Mexico, Lithuania and so on.

Only few times someone said “Italy”!

Let’s introduce myself now. My name is Giovanni, a very common Italian name. I’m from Naples and I’m a software developer. I resigned in 2008 to move to Ireland and check how the Irish tiger was. In this first Irish year, hundreds of things happened. Troubles in private life, successes at work, new friends, new habits, nights spent at discos and pints, pints and still more pints of beer.

Few days ago I was visiting a tech-y blog here on wordpress and I fell in love with the its style so I decided that soon or later I had to open my own blog and begin, from time to time, to share something about myself such as adventures, trips and wannabe technical articles on the Java world.

It’s time to lay back and get some rest. Tomorrow (or should I say “later”?!) I have go to visit Dun Laoghaire with some friends.

It’s funny how tonight begun and finished with “sweet dreams”… Few of you, or maybe no one, will understand this, but it’ll be handy for me to remember that the just finished night might have been the begin of a new chapter of my life.


The Bright Side of Java & Linux

Yet another Java blog


Bringing empathy into knowledge workers life

%d bloggers like this: