Archive for the ‘Uncategorized’ Category

Say Goodbye, I won’t be Back

December 2, 2011

Yesterday was my first day in a new position. I’m now co-founder of a start-up called Mydosis. But this blog post is not about what’s coming, it’s about what I’m leaving behind.

I’m leaving behind a career as an Agile consultant. I used to call me “Agile coach” but nowadays I see Jerry Weinberg’s definition of consulting – “influencing people at their request” – a much better fit for what I had been trying to achieve during the last 10 years. Which gets me in the middle of my frustration with the idea of bringing Agile to the masses.

During the first years of Agile development, Agile promotion and Agile influencing was a source of joy and positive fulfilment for me. Most of the time I had to deal with developers and teams who actually embraced the “extreme” ideas I brought them. Sure, their managers were initially unwilling to accept two people working on one computer or the team insisting on doing the estimations themselves. But in the end every team member knew they personally were much better off – even if they had to make a few compromises to interface with the non-agile rest of the company.

Then the nature of my assignments changed. Suddenly it was the CEO or at least s.o. from upper management who initiated the “Agile transition” in order to “adapt faster to a changing market”. At the beginning I deemed that a good thing, since I had always been complaining about the lack of management support. However, the work itself got ever more frustrating and ever less rewarding, especially when dealing with teams who were pushed towards Agile and hadn’t had the chance to choose for themselves. From then on, I spent most of my time trying to convince somebody of something that he or she didn’t actually want to do. If this sounds to you like a depressing way to earn your money, it was. Even when showing very hands-on techniques – like TDD or refactoring – I felt the lack of enthusiasm; first in my clients but then more and more in myself.

Slowly it dawned on me: We, as Agile consultants, have been abused by management to do all the convincing and motivation for them. In my opinion it should be the most essential part of their job to bring the right people together for the new challenge, might it be a new product, a leaner approach for the old product or a complete turn around of the company. Instead they hired us to do the impossible: Change their employees in a way that suits their latest business strategy. Accepting such an assignment often made us violate the “first Agile commandment”: People over process.

“People over process” can – and often should – mean: not doing an agile transition at all. Human beings have a right to choose which changes they want to go through and when. There are many valid personal reasons for not doing TDD, not taking accountability and not moving into a common team room. Let’s accept those reasons without being contemptuous and without trying to manipulate. Heck! – it’s the managers’ task to align their employees’ personal goals with those of the company. The few successes and the many failures during my time as Agile consultant have taught me one thing: It needs different people to make a different company. Rare exceptions will only prove the rule.

So, my dear fellow-coaches, my dear friends, we had a good time together. Sometimes even a great time. We brought teams from being overwhelmed by bugs to a zero-defect continuous feature flow. We turned around a company who was under severe legal pressure by its customers to a +50 net promoter score. We convinced senior managers that giving up control will enhance their teams’ productivity. But, on the way, we made some people unhappy, maybe a few very unhappy, and sometimes didn’t even notice.

I hope to see you all around, but I won’t be back to the party.

Simplified Use of Locks in Groovy

October 25, 2011

I am currently writing an article about the challenges and pitfalls of concurrent programming for a German software magazine. Since the magazine’s readers come from all kinds of platforms and programming languages I’ve chosen Groovy as a concise means to present my examples. Groovy – together with its associated library GPars – comes with good support for easy synchronization and locking (e.g. @WithReadLock, @WithWriteLock and @Synchronized). However, I do not want to introduce the concept of AST transformations so I came up with a new way of using locks in Groovy – originally motivated by Chris Broadfoot. Here’s a short example:

class Shelf {
    final products = []
    final lock = new ReentrantLock()
    void putIn(Product product) {
        lock {
            if (isFull())
                throw new StorageException("shelf is full.")
            products << product
        }
    }
    boolean takeOut(Product product) {
        lock {
            return products.remove(product)
        }
    }
}

It looks like lock was a new keyword but actually I achieved that with a tiny bit of Groovy meta programming:

Lock.metaClass.useFor = { Closure operation ->
    lock()
    try {
        operation()
    } finally {
        unlock()
    }
}
Lock.metaClass.call = { Closure operation -> delegate.useFor(operation) }

Now that I used it in a couple of examples I suggest it should be considered for inclusion in GDK. What do YOU think?

P.S.: Don’t get me wrong about the usefulness of explicit locking. In most cases other concepts – like parallel collections, data flows and agents – should be preferred.

Tail Recursion Optimization with Groovy’s AST Transformations

February 11, 2011

The JVM is notorious for not being able to optimze tail recursive functions. Tail recursion is a special case of recursion which can be changed to iteration. In simple terms: If the call to itself is the last thing a function does before returning, then it’s tail recursive. Changing the actual execution model from recursive to iterative saves the runtime machine from putting the just finished funtion’s context on the stack. Among other advantages this saves you from getting the infamous java.lang.StackOverflowError when feeding large numbers into a recursive function in Java.

Let’s look at a classical example: Calculating the factorial of a number. A recursive – but not tail recursive! – solution is this:

int factiorial(int number) {
     if (number == 1)
          return 1;
     return number * factorial(number - 1);
}

We can see here that tail recursion is not about the recursive call being the last thing in the function’s source code but in the function’s control flow!

For many recursive problems there’s an easy way to transform it to a tail recursive solution. Often the trick is to introduce an aggregator, i.e. an additional parameter that takes the intermediate result of a calculation. Doing that our function becomes:

int factorial(int number, int aggregator) {
    if (number == 1)
        return aggregator;
    return factorial(number - 1, number * aggregator);
}

Using this function requires a start value for the aggregator, in this case factorial(10, 1) would evaluate to 3628800 which sound reasonable. So how can we translate this into an iterative version? Let’s see:

int iFactorial(int number, int aggregator = 1) {
    int _number = number;
    int _aggregator = aggregator;
    while(true) {
        if (number == 1)
            return _aggregator;
        _aggregator = _number * _aggregator;
        _number = _number - 1;
    }
}

The trick is to wrap our function into an endless loop, save the function args into local temps, replace all usages of the args with temps and replace recursive calls by setting the temps to the recursive call args. Sounds easy, eh? If the JVM won’t do that for usautomaticall why not build a recursion to iteration translator ourselves? Since Groovy is my favourite language on the JVM it seemed the perfect time and target to give my first shot at AST transformations. AST transformations are @nnotations that will be invoked at compile time to let you analyze and manipulate a programs abstract syntax tree. AST transformations can be used on different levels, in my case a local transformation seemed to suffice and I started my dive into the world of ASTNodes, expressions, statements and other weired things…

Actually, I don’t want to bother you with the details of how to test-drive AST transformations; I’m still at the very beginning of figuring things out. What I want to show you is my first prototype: tailrec 0.1. Look what we can do now:

import groovyx.transform.*
@TailRecursive
int factorial(int number, int aggregator = 1) {
    if (number == 1)
        return aggregator;
    return factorial(number - 1, number * aggregator);
}

assert factorial(10, 1) == 3628800
assert factorial(10) == 3628800

The code runs as is in Groovy’s console as soon as you add tailrec jar file to your classpath. As you can see, when making use of Groovy’s default arguments we even get rid of the clumsy aggregator initialization. To prove that tailrec really does what it promises try the next example with and without @TailRecursive:

import groovyx.transform.*
@TailRecursive //remove line to get StackOverflowError
def countDown(long from) {
    if (from == 0)
        return 0
    countDown(from - 1)
}

countDown(1000000)

So far tailrec only handles non static functions, i.e. instance methods that have some real (non-void) return type. Moreover, there are a few cases I can think of that tailrec should and could handle correctly but does not (think: ternary operator in return statement). And there are a few difficult problems where I have no current idea how to solve; consider for example the use of recursive calls within closures.

The current version is a proof of concept. I want you to experiment with it and give me your feedback. In my opinion tailrec should become part of standard GDK if it’s worth doing it at all.

Update:
The code has now moved to github. I’m actually planning to enhance and stabilize it since the groovy team encouraged me to. It meanwhile supports static functions as well and has many more tests to earn your trust.

Business Experiments

January 19, 2011

I’m currently running a triple experiment:

  • For the first time in my career I’m trying to organize a public workshop completely on my own. The topic is Advanced TDD and I’m very thrilled about the simulations and exercices I want to do there. The first run will be in German.
  • I’m auctioning one of the seats for this workshop on ebay. Let’s see how this turns out.
  • Since I’m very eager to reach the minimum participation of 4 as soon as possible, I’ll give a commission of 20 percent to anyone who’ll send me a customer until 4 seats are taken. Just tell the interested person to refer to you when they contact me.

Update
The first auction ended at 401 EUR. So I started a second one which resulted in 512 EUR. Not bad I’d say..

Update 2
I’m sold out 6 weeks in advance.

Should I renew my wordpress personal CSS?

March 17, 2010

Compare the following two screenshots.

This one shows how code samples are currently being displayed in my blog:

The second shows how code would be displayed if I wasn’t to renew my custom css option:

Is the difference worth 15 USD per year?


Follow

Get every new post delivered to your Inbox.