Lombok

Java developer? You feel class and method declaration is cumbersome? You want to follow Mr Bloch‘s advice but fret verbose boilerplate code? Look no further than Project Lombok!

Lombok helps you as a Java developer, with mundane tasks such as creating no-args constructors, getters/setters, toString/equals/hashCode-generation and more. All you need to do is to annotate your classes, as described in the manual.

For example, if you put the @Data annotation on your class, you’ll get generated toString, equals, hashCode, getter and setter methods, AND a constructor taking all required fields as parameters. Phew!

Behind the scenes, these are generated by code from the lombok jar-file, which must be on the classpath. Plugins exist for most IDE’s, so it’s easy to get going, here’s what you need for IntelliJ:

  1. Install the lombok plugin from the plugin repository.
  2. Add the maven dependency org.projectlombok:lombok version 0.11.6
  3. Annotate your data classes, and use them, example:
@Data
public class Person {
    private final String name;
    private int ageInYears;
}

public class PersonTest {
    public static void main(String[] args) {
        Person person = new Person("Christian Fogel");
        person.setAgeInYears(145);
        System.out.println(person.getName() + "," + person.getAgeInYears());
        System.out.println(person);
    }
}

The above would, surprisingly, not only compile but also print

    Christian Fogel,145
    Person(name=Christian Fogel, ageInYears=145)

Pretty neat isn’t it? As usual, don’t forget to read the fine print, test your classes thoroughly and beware the development status of the project (as indicated by the version number).

Just Read: The Two Second Advantage

Coincidentally, the topics in the book “The Two Second Advantage” by Vivek Ranadivé & Kevin Maney, are both interesting and fascinating out of an Agile perspective and I’ll discuss this here in my impression of the book.

The book tries to show how some parts of human talent comes from wiring the brain in such a way that it perceives things just a little bit ahead of time. Phenomenal individuals, such as hockey virtuoso Wayne Gretzky and pickup artist “Mystery” are brought forward as examples of humans having acquired such talent. The authors argue there a number of factors required for this wiring to take place along with the now famous 10 000 hours of deliberate practice. To be able to predict the future, or assess situations, very quickly, the authors argue that the brain does something called “chunking”. This means that the brain, upon repetition or practice, over time builds up a “chunk” of knowledge of a certain topic. It can then use this chunked, mental model for predictions instead of having to look at all available data stored in the brain’s neurons. Supposedly, this is partly due to the substance myelin building up along frequently used neurons.

All this is quite fascinating but has a focus on the human body and its capabilities. However, these topics are just the beginning of the book and the authors soon progress to transpose their arguments to the business world. Here it starts to get even more interesting for us in the software business. They talk about the data explosion going on in today’s connected world, and about how 20th century solutions to finding important statistics and other information from what is gathered in a company’s servers, are simply not enough anymore.

Conventional data mining and analysis has a couple of problems namely that it deals with how things used to be and not how they will be. With the amount of stored data growing, there are also situations where it simply cannot be mined fast enough.

So, what has all of this got to do with Agile? Well as I see it, companies taking the necessary steps to introduce forward looking software, to gain a prediction advantage over competitors will need to have an Agile organization. They will need this because when their new predictive system tells them what to do, they must be able to pivot, and quickly put the knowledge to use before it gets old and useless. If done right, that must be the nirvana of Agility. To have a brain-like software constantly mining the business related data to predict what customers or clients will want to have in the future, and have the organization and delivery procedures ready to carry out the necessary changes ahead of time, with exactness.

The book is short, on topic and connects the workings of the mind with 21st century business processes, as well as includes a vast amount of fascinating stories and references. You can say it gets your mind spinning, and it’s worth a read.