Monthly Archives: July 2009

En lynrask innføring i Scrum

This Norwegian language post talks a little about a quick intro to Scrum that I wrote for my employer

Jeg har forfattet en “3-minutters guide” til Scrum. Dette er en to siders lettlest artikkel som publiserer via min arbeidsgiver Steria. Denne har som mål å være tilgjengelig både for tekniske og ikke-tekniske prosjektdeltagere som gjerne vil forstå litt mer om hva Scrum dreier seg om.

Du finner artikkelen på Sterias arkiv over 3-minuttersguider. Du kan ta kontakt dersom du ønsker et eller flere eksemplarer av guiden trykket på solid papir.

Jeg regner med å lage flere iterasjoner av denne guiden, så tips om forbedringer mottas med takk.

Posted in Non-technical, Norsk, Software Development | 8 Comments

Unit testing tricks: Using unit tests to validate static code

In my current project, we use Flex as the user interface framework of choice. Flex has some nice features, but it takes a long time to build changes and start up, so it takes a while to validate our changes. Yesterday, we found a problem with one our UI components, and used JUnit to hunt down the same problem all over our code.

The problem was with tables. We had a table where we had set the percentage width of each column, but the total did not add up to 100%. This table looked fine initially, but when we resized it, the column widths went berserk. The result was hilarity and frustration.

In Flex, components are defined using MXML, which is an XML language. In order to 1) find out how much we needed to adjust the column widths, 2) verify that we had made the change correctly, and 3) check all other tables for the same error, we wrote a unit test that uses dom4j to parse the XML-file, reads through all column definitions and collects the percentage width attribute. The test then verifies that the total adds up to 100%.

This way, we could take the problem one place, find everywhere else it occurred, and make sure it never happens again.

We have written similar tests to make sure that all names of resource bundle strings are defined in our properties file and to make sure that classes that are transfered from the server (written in Java) to the client (written in Flex) don’t have know serialization problems. We have started using the library metaas to parse ActionScript for some of these tests (sadly, metaas has a few bugs in it’s antrl-grammar and it is not currently maintained).

In order to make it super easy to deal with the problems, we want the test failure to contain the missing code. So, for example:

StringBuilder missingProperties = new StringBuilder();
 
Properties properties = new Properties();
properties.load(new FileInputStream(flexResourceBundle));
 
SAXReader reader = new SAXReader();
Document document = reader.read(mxmlFile);
Element columnsDeclaration = document.getDocumentRoot()
        .element("columns");
for (Object columnObj : columnsDeclaration.elements()) {
    Element column = (Element)columnObj;
    String resourceKey = getResourceKey(column);
    if (properties.getProperty(resourceKey) == null) {
        missingProperties.append("\n" + resourceKey + "=");
    }
}
 
assertTrue("Cut, paste and edit the following into "
    + flexResourceBundle + ": " + missingProperties,
    missingProperties.length() > 0);

As the turnaround time with Flex is fairly high, it takes much less time to run a JUnit test that verifies source code than it does to fire up the application and try it out. A similar approach can be used to verify other things you wish the compiler would check.

Posted in English, Java | Leave a comment

Book review: Breaking the Spell

Why do all societies we know of practice some form of religion? Either religion must be “true”, or there must be some sort of natural explanation for this universal phenomenon.

Breaking the Spell
Breaking the Spell

Breaking the Spell” by Daniel Dennett presents avenues of research into these explanation. He does not profess to have the answers to this question, or even the right question. He merely sets out to prove that the questions are important ones and ones that we can hope to gain insight into.

Dennett is a philosopher, and he has explained the role of philosophers with an analogy: A philosopher watching a magician sawing a lady in two offers an explanation: “You see, the magician is not really sawing the lady in two. He merely makes it appear as if he is sawing her in two.” When asked, “so how does he do that”, the philosopher answers “I’m sorry, that’s somebody else’s department.”

This story undersells Dennett and his books, of course. I have been a fan of Dan Dennett for over ten years. His accessible books “Darwin’s Dangerous Idea” and “Consciousness Explained” have radically shaped my understanding of evolution and the brain. “Breaking the Spell” does the same with religion.

So, if religion has a natural explanation, what could this explanation be? Obviously, something in our evolutionary history has made us religious. Does this mean that religion is good for us, or rather, that it helped our ancestors survive? Not necessarily. Dennett shows how certain traits that could’ve been good for us, like susceptibility to the placebo effect and a disposition to interpret events to be caused by an actor, could’ve made the human mind susceptible to other ideas, or memes as well. As long as these ideas don’t cause the “host” fatal damage and they can spread to other “hosts”, such ideas would become widespread, even if they were (moderately) harmful to those who bear them.

This hypothesis is also explored by Dennett in one of his several talks for the TED-conference:

The question for the final part of the book, then, is what effect religion has on it’s adherents and society at large. When does it help us and when does it harm us? Dennett suggests experiments that could further explore this subject, but doesn’t offer definite evidence for any hypothesis.

The weakness of the book is that it spends quite a bit of time excusing itself to hypothetical fundamentalist readers. Even if you believe your religion is true, Dennett points out, you must wonder where all the other religions came from. Even if you believe your religion is true, you must wonder what effect other religions have on society.

I wish the book had spent more time exploring the issue at hand (why religion might exist, what effect it has) and less time excusing the validity of the question. But it’s an enjoyable read and gave plenty of food for thought.

Dennett remains my favorite philosopher author.

Be sure to check out Dennett’s great presentations on the web:

Posted in Books, English, Non-technical | 6 Comments

Book review: Predictably Irrational

Summer is starting
Summer is starting

“Predictably Irrational” is a perfect book for lazy summer days on the beach or, in this case, while enjoying a beer from top of Oslo’s tallest office building.

Dan Ariely is on a bit of a crusade against traditional economics, with it’s idea of rational behavior from everyone in the marketplace. Instead of this (strawman) economics, he uses experiments to explore what he calls “behavioral economics”. The book is focuses particularly on how our behavior often is not at all rational.

The book is enjoyable, and Dan Ariely’s style is easy to digest. However, the free online videos of him talking are even more enjoyable.

Some of my favorite sections:

The Context of Our Character

The experiments that first made me aware of Dan Ariely is those that explore what makes people cheat more and what makes people cheat less. This is the subject of a great TED-talk, titled “Why we think it’s OK to cheat and steal (sometimes)”:

The Cost of Zero Cost

The Cost of Zero Cost talks about how “zero” is a very special price. The experiment: If you let people choose between a good chocolate at 14 cents and a cheap chocolate for free, traditional economics predicts that preferences will be the same in a choice between a 15 cent good chocolate or a 1 cent cheap chocolate. Ariely demonstrates how this is not the case.

The effect of zero cost has been discussed lately by the likes of Seth Godin and Malcolm Gladwell. This particular discussion springs out of Chris Anderson’s recent book Free.

The price of zero has been one of YouTube’s great strengths. However, as Malcolm Gladwell points out, it is also carries a slight downside: YouTube doesn’t make any money.

The Verdict

The book was a pleasant little read, but ultimately, disappointing. Let me explain:

Before I bought the book, I watched all the videos I found about the subject on YouTube. After having seen these, the only area which the book gave me any further insight was that of zero price.

Ironically, the book suffers from Malcolm Gladwell’s skepticism about “Free”: Giving away information for free will give you a lot of attention, but might undercut the reason for people to give you money.

If you want a pleasant read on the beach, “Predictably Irrational” might be for you. If you just want to learn about “behavioral economics”, watch Dan Ariely’s videos instead:

Posted in Books, English, Non-technical | 1 Comment