Distributed Agile

I know well what agile development is.  Nothing in the world gives better working environment for creating marvelous new systems, than a well formed XP team – your pair programming buddy will definitely tell you if you are on a wrong track. The atmosphere is great, the team is One. Match that with a rigoristic approach to testing, visibility and user involvement, and you have a bullet proof recipe for producing word class software.

But distributed agile – whats that? After having met the dutch-indian company Xebia at JAOO 2008, which claims to have mastered the tricks and secrets of Distributed Agile Development, so that a team can be distributed around the globe, and still experience this very special atmosphere of hyperproductivity, I was intrigued and determined to find out.


I happened to bump into the Indian Holi Holiday while co-locating

I happened to bump into the Indian Holi Holiday while co-locating

This should be obvious – you need  in the beginning of a project to see  each other in the eyes, the team has to be formed – thats called co-location.

We have a small project, 3 developers in total, so I buy a ticket to Delhi, and get a business visa in the passport.

The first thing that strikes me is the long office hours.

Second experience is the xtreme service.  For a poor european, used to ‘self-service’ the indian way of delivering service feels overwhelming. I counted over 100 people employed, just to make my morning commute to the office painless.

Third experience is a quiet yoga studio, with drop in-classes all the evenings.

I am thrilled to meet the team, we have been conversating a couple of times previously via Skype – it is such a heart warming feeling finally to meet them. After day 1 we have a good overview of the architecture, have filled walls, whiteboard and glasspanes with the mandatory UML diagrams, updated the electronic backlog and are ready to start work.

People are smiling, engaged, inquisitive. I am surprised by their level of proactiveness, and intelligent inquiries, foreseeing possible problems weeks in advance.

The team spirit starts to soar – yes, we can do it.

XP over the wire

All good, we have been co-located, but the whole idea behind distributed agile is … well, distributed.

Back in Denmark, days are passing by in a productive buzz.

I see a message blinking from Sunil. He is stuck and needs help on some configuration issue. We exchange code snippets back and forth, after a few minutes the problem is solved. Next day he has generalized the solution, and helped unstuck me.

Skype chat is on all the time when we work.

Each morning we have a video session on Skype to get updates, and plan next days work. The time difference gives the Indians a head start on the days tasks.

After a couple of days we discover, that we have accelerated development speed, and actually surpassed the sprints goals.

You wouldn’t be able to tell from velocity charts, that this team has been distributed.


  • Things take time.
  • Accommodate for Sprint 0
  • Set up good facilities for Skype calls … yes, Skype makes it possible
  • Try!

New Year starts with Scala

Slowly up to speed

New Year is here, smoke calming down after a couple of nights of excessess with fireworks (and some other stuff too).

I think tonight, the sky will be clear, and the air fresh again.

After lazying around with my family during the Christmas Break, its time to actually work again.

Preparing lecture for  JG.DKs annual conference

I am preparing my lecture for the Danish Java Groups Annual Conference, it will be held at Hindsgavl Castle on my Island (=Funen) in Denmark. The program is here.

My talk will be about a new language – Scala – which is bytecode compactible with Java, and runs smoothly on the JVM. I claim that Scala is going to give us back Object Oriented progamming – without having to do some of the awkward workarounds, that java is forcing us to do.

Out of the host of new languages that run on the JVM, like JRuby, Groovy and Jython – I really think Scala stands out.

What is so special about Scala?

It is a functional language. It is an object oriented language. It is a type strong language – exactly like Java.

It has traits – an ability to add methods to an interface – a language feature that we have been missing since

It is pure and well designed. Invented by Martin Odersky – who designed the Java generics.

Eventually, Java 7 or 8 will be patched with closures, and traits. But those will be patches. I am right now reading a book by Odersky, Spoon and Venners – Programming in Scala – highly recommendable.

Your hello world in Scala


Lets try Scala out.

First, lets get the convenient Eclipse plugin (you need Eclipse 3.4 + to make it work) from its update site:


Select New>Scala Project.

This gives you a … Scala project.

Now in the src folder, add a Scala Application (runnable):package application

object HelloWorld extends Application with FirstTrait{
override def main(args: Array[String]) {
println(“Hello, world from Scala!”)
println(“From trait ” + greet(“world”))
print(arg+” “)


Make your first trait:package application

trait FirstTrait {

def greet(name:String):String = “Hello “+name


Run the application (Run > Scala Application), to see the output:

Hello, world from Scala!
Now – hello from trait Hello world

Thats it – hello world in Scala.

Hello World in Scala

Screenshot from Eclipse: Hello World in Scala


I attended JAOO in Århus this year – what a fantastic experience, this conference has a special atmosphere. Denmark is such a small country, you keep meeting old colleauges, classmates, bosses – whatever.
This years buzz was all about functional languages – we finally need to decide what to do with side effects. One possible solution is to have the language give clear, big warning signs.
This is the old semantics vs syntax discussion: Giving clear names, typesafety etc doesn’t help to achieve the big golden dream of (finally!) having reusable software components. What we need to agree is semantics – what does it do, not syntax – how to call it.
I was enchanted by Bill Verner, and his Scala talk, and I am really looking forward to his newcoming Scala book. A typesafe dynamic language that runs on the JVM – I am kind of convinced that this is exactly what we need. To bad the book isn’t coming out before the conference is over – I would have loved a signed copy.
I also enjoyed Michael Nygards talk “Failure comes in flavors” almost without breath – his rant about patterns and antipatterns when time comes to deploying and keeping our applications alive was full of cliff-hangers. Respect. If you ever have a chance to hear this man talk – and if uptime is of any importance to your next web-app – don’t miss him.
I also spent some time discussing lean/agile architecture with James Coplien and his gang. He is promoting DCI – data, contexts, interaction, which is a new paradigm in structuring your applications architecture. James wants us all to move us away from class-oriented programming to true object oriented programming. We spend a couple of hours hanging out, discussing how to translate his example into different programming languages. I myself tried to convince James that you can do it -in Java too. Sitting together, 5 people, around a table, we discovered how we all have been searching for the same answer. Magic of coincidence, or is it the world allready moving in a new direction?

Sending html mails with embedded pictures, that Thunderbird can understand

Users of Thunderbird have for long known, that html messages with embedded content look “strange” – you see a list of attachments part1.1, part1.2 – when you click on one of them, you see the html text message, or the pictures that should have been embedded.

I have just discovered a way of sending html mails with embedded pictures, that Thunderbird can display correctly. I use Java 6, and the javax.mail package.

Basically, you need to build a mime message in the following format:

<multipart alternative>

<mimebodypart:empty text>

<multipart related>

<mimebodypart:html cid:picture_1, cid:picture_2, … >


</multipart related>

</multipart alternative>

Here is how to do it in Java code.

import javax.activation.DataHandler;
import javax.activation.URLDataSource;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

// ... some other stuff
public Message getAsMessage(Session session) {
try {
Message message = new MimeMessage(session);
// set subject
// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);

InternetAddress[] addressTo = new InternetAddress[to.length];
for (int i = 0; i < addressTo.length; i++) {
addressTo[i] = new InternetAddress(to[i]);
message.setRecipients(Message.RecipientType.TO, addressTo);

//create top multipart
MimeMultipart topMultipart = new MimeMultipart("alternative");

// prerprocess dynamic text

if( htmlTemplate != null ){
//create related multipart, wrap into bodypart, add html part
MimeMultipart relatedMultipart = new MimeMultipart("related");
MimeBodyPart relatedBodyPart = new MimeBodyPart();

//load html part
BodyPart htmlBodyPart = loadPartContent(htmlTemplate, null);
preprocesText( htmlBodyPart, HTML);
// htmlBodyPart.setHeader("MIME-Version" , "1.0" );
// htmlBodyPart.setHeader("Content-Type" , htmlBodyPart.getContentType() );

//fill up the related multipart with bodyparts for images
for (ImageContainer image : images) {
BodyPart imageBodyPart = loadPartContent(image.getUrl(), image.getContentId());
if( textAlternative != null){
BodyPart alternativeTextBodyPart = loadPartContent(textAlternative, null);
preprocesText( alternativeTextBodyPart, PLAIN);
//add first poormans alternative, later the related part of the message

if( topMultipart.getCount() == 0){
MimeBodyPart emergency = new MimeBodyPart();
emergency.setText("No content");
return message;
} catch (MessagingException e) {
if (Optimization.LOG && LOG.isWarnEnabled()) {
LOG.warn("Could not create the mail message for session "
+ this);
return null;

Normally, alternative is used to enable mail-clients that do not understand html to select the text alternative. By setting the sub-type of the alternative multipart as “mixed”, this trick is forcing Thunderbird to display both (the empty) text message, and the html message.

Here follows the example in code: