Tuesday, 28 June 2011

Fallen Dragon

by Peter F. Hamilton
ISBN: 978-0330480062

This is the first Peter F. Hamilton book I have read. It's a big book and proper science fiction. I liked it a lot. In fact bits of it I thoroughly enjoyed. However, it's nothing special and really quite predictable. Although I didn't see the final little twist right at the end coming. From what I had heard I expected a bit more from Peter F. Hamilton, but I will certainly be reading his other books.

The characters are superb. I really related to them, especially the young Laurence when he met, loved and lost Roslyn. I spent the whole book wanting him to get her back. I won't tell you if he did or not. I found Laurence's disgust at the idea of real food interesting on a couple of levels. First there is all the aversion to processed food in modern society and then I remembers the children in James Follett's Earth Search entering puberty when they finally stopped eating the processed food provided by the Angels.

Wednesday, 22 June 2011

Spring Roo at Skills Matter

I've just got back from a fantastic presentation on Spring Roo from Jan Machacek of Cake Solutions. It was hosted at Skills Matter by Barry Cranford of the London Java Community. I came away totally understanding what Spring Roo is for.

In a few words, it's code a generator that gives you a boost when creating Java and Spring MVC based web applications. It uses a lot of Aspect Orientated Programming (AOP) to take away a lot of the boiler plate code, such getters and setter on beans and persistence, that are required for CRUD web applications. If, after the application is completed, you want to stop using Sprig Roo, you can. If you want to keep using it to generate more of the application, you can and it examines the code every time you build to see if it can generate more helpers from your changes. It's not a silver bullet or a golden hammer thought, it's another tool in a Java web application developers arsenal.

One draw back for me is that Spring Roo requires Maven (quite possibly one of the roots of all evil) and I don't yet know know enough Grails to know if Spring Roo provides greater advantages for web development.

Jan Machacek is a excellent speaker, very clear and enthusiastic as well as knowledgeable without being arrogant. He clearly understands Spring Roo inside out and was able to answer all of the questions asked. The only frustrating thing was that every time I thought of a question, it was answered a few slides later.

You can see the video here.

Thursday, 9 June 2011

Working Effectively with Legacy Code Project


The ACCU Mentored Developers have recently started a project based on Working effectively With legacy Code (ISBN: 978-0131177055) by Michael Feathers. The project members are reading about a chapter a week, starting on Monday 13th June 2011. Each week a project member will publish a review of a chapter and the group will discuss the chapter and the review on an email distribution list. This all happens under the watchful eye of the book's author, Michael Feathers.

The project is only open to ACCU members, but you can join very cheaply and there are other benefits including an ACCU Conference discount and journals. The project schedule can be viewed here and project distribution list is here.

Tuesday, 7 June 2011

Execute Around Exception

I have a lot of UI controller code that looks like this:

try
{
// Do something that might throw is is probably a single line of code
}
catch (Exception e)
{
// Notify the user of the problem.
}

This is 8 lines of code for a single line operation. The common code that notifies the user of the error, commonly just a message box, can easily be refactored into a single method. The problem is the try/catch block. So I started wondering if I could reduce it somehow. I would be so much nicer if I could write:

ExecuteSafely(delegate
{
// Do something that might throw is is probably a single line of code
});

where ExecuteSafely takes care of the boiler plate code. I started playing around with Execute Around Method ideas and came up with this:

public class ExecuteAroundException
{
private readonly Action<Exception> exceptionHandler;

public ExecuteAroundException()
: this(delegate { })
{
}

public ExecuteAroundException(Action<Exception> exceptionHandler)
{
this.exceptionHandler = exceptionHandler;
}

public void ExecuteSafely(Action action)
{
try
{
action();
}
catch (Exception e)
{
exceptionHandler(e);
}
}
}

The default exceptionHandler does nothing. It just swallows the exception. The chances of you wanting to use it are therefore slim. However you can provide a delegate that handles the exception:

ExecuteAroundException x = new ExecuteAroundException(delegate(Exception e)
{
// Notify the user of the problem.
});

And then you can use it like this:
       
x.ExecuteSafely(delegate
{
// Do something that might throw is is probably a single line of code
});

The only two scenarios where this is worth while is when the ExecuteAroundException instance is created once at class scope or created in a factory method. Otherwise you end up with almost as much code.

Monday, 6 June 2011

Cerebral Bore

I buy a lot of music so I don’t often get a chance to blog about it. However Cerebral Bore are really something else. Hailing from Scotland and with a singer from Holland they’re the best death metal band I’ve discovered since Annotations of An Autopsy. I originally read about them in Metal Hammer, where they were described as concerned no one would take them seriously as they are a death metal band with a female vocalist. After the success of Arch Enemy I really couldn’t believe it would be a problem, so I bought their debut album Maniacal Miscreation and I wasn’t disappointed.