So 2007 is nearly soooooo last year, and yet another year begins. 2007 really did fly by and it reminds me of a quote from Ferris Bueller's Day Off (one of my favourite films of all time!)
Monday, 31 December 2007
Goodbye 2007, Hello 2008
Wednesday, 21 November 2007
I'm a Software Developer, but I don't work with computers reprinted on JavaLobby
I arrived at work this morning to find a familiar face staring back at me. I received an email over the weekend, asking if I would like to have my last article reprinted in this Tuesday's Javalobby News weekly newsletter. They needed a photo to go with the article, but I haven't got any on this computer. The only camera I had to hand was on my mobile phone, so I'll have to apologise in advance for the picture :-). I'm amazed how many people have viewed the article so far and I just want to thank every that has taken the time to vote or comment on this!
Check it out: http://www.javalobby.org/nl/archive/jlnews_20071120o.html
Monday, 12 November 2007
I'm a Software Developer, but I don't work with computers
Let me set the scene for you. You're at a friends party and you meet up with some new people. After the opening pleasantries, the conversation soon comes around to your day job. So I start off with the obvious, "I'm a software developer." This usually leaves people quite puzzled so I try a different approach, "I write computer software." And it's at this point you hear those words you dread so much, "ahhhh you work with computers!".
I've always imagined it's the same situation in lots of professions. You're a doctor and someone asks you to have a look at a worrying mole they've just found. You're a shop worker and someone wants to know if you'll be able to get them a discount. You're an airline worker and someone wants to know if you can get them a free upgrade to business class. You're a psychologist and someone wants you to guess what they are thinking.
Now it just so happens that if you work with computers, you know everything about anything electrical.
So I try to explain a little about what I actually do. It's usually at this point I get polite nodding and smiling, I can feel the other person losing interest. After a little more explanation, I can feel the inevitable elephant in the room rearing it's head and I really don't want to let the other person speak. But eventually I have to take a breath, and that's when you hear those dreaded words, "you might be able to help me, I have a problem with my computer at the minute".
I do have a computer, I do know how they work, I know what all the parts are and what the acronyms stand for, I can build one and I also have an uncanny knack of being able to break mine on a regular basis. But, this isn't really what I do for a day job. I really don't enjoy doing it and I genuinely find it very frustrating when mine blows up. The last thing I want to do is try and fix someone else's computer, only to receive a phone call three years later proclaiming that the computer isn't working. As I was the last person to touch it, I must have obviously done something to break it (true story). I might try this approach with my mechanic when my car needs fixing again (think it will work?). Needless to say, fixing computers really isn't my thing!
I really take my hat off to the people that do sort out hardware issues for a day job. I know I wouldn't like to do it, and I really don't envy their position when they meet new people, they really are "the computer guy". No problem is beyond their supreme skills, and they usually can't say no when someone asks them for help. You don't have to talk to "the computer guy" between computer problems, so it's quite an easy relationship to maintain. They obviously have too much spare time on their hands anyway as they'll always come round to fix your computer problems. Best of all they'll never charge you for taking up all of their spare time!
So next time I meet someone new, I'm going to try a new approach. I know nothing about moles, I can't get you a discount or a free upgrade to business class and I really don't know what you are thinking. I can't fix a video recorder, a DVD player, a Sky+ box or tell you how to use SpongeBob SquarePants print studio. I did finish a four year Software Engineering degree and I really did attend some of the lectures, but I'm really not "the computer guy". I'm a software developer, but I don't work with computers.
Wednesday, 7 November 2007
RefactorMyCode.com: Will it work?
I recently stumbled across a new site called RefactorMyCode.com. The strapline reads:
![[image]](http://mowser.com/img?url=http%3A%2F%2Fbp2.blogger.com%2F_Uz0bqG2PRjE%2FRzIk7nx8lMI%2FAAAAAAAAAB8%2FbtTa3gejxYA%2Fs400%2FRefactorMyCode.jpg)
That doesn't all sound like refactoring, but I'm always interested in new resources so I thought I'd have a look.
I do have a few niggling issues with all this though. Refactoring code is an essential skill developers need to understand and practise, does it really make sense to let others do it for you? IDE's automate most of the common refactorings developers perform, so do other people really want to perform these mundane tasks and post the results? Is it wise idea to post your companies intellectual property on a public forum? Is it possible to stop the site just becoming another "write my code for me" sites?
I do really like the concept of this site. I like the concept of community support, so the idea of other developers giving me ideas about better ways to structure my code is very appealing. It's also nice to get a critique from someone who's not working on your team. A fresh perspective can really help to shed some new light on your code. I also work on the perspective that lots of developers out there are better than me, so the idea of getting some of these to make suggestions about my code is quite exciting.
RefactorMyCode.com is a really new site, so there are currently a limited number of posts. It's too early to see if the site will indeed work, or simply descend into another DoMyJobForMe.com. It is an interesting idea though, and I really hope it does succeed. Once there are a few more posts on there I'd be interested in trying out my skills and seeing if I can attain one of those top refactorer badges ;-).
Tuesday, 6 November 2007
Unit Test Assertions: What could possibly go wrong?
Lots of my development effort is taken up writing unit tests. These tests form a nice warm security blanket for the code that I've developed. If the code is broken, typically these tests are the first feedback that something is wrong. Although some people fear the little red bar, it's become a common part of development. So with this in mind, it's vitally important that when a test fails, is crystal clear what really went wrong.
Over the past few weeks, I've been reading xUnit Test Patterns (review to follow in another post), which covers making tests easier to write, understand and maintain. One important issue it discusses, is the use of assertion methods.
Assertions are a fundamental part of writing unit tests, and are typically very simple to use. Within each test, the expected outcome is expressed using assertions, each of which is boolean expression. The assertion should evaluate to true, so if the evaluation of the assertion instead returns false, the test will be failed. JUnit provides the Assert class to handle various types of common assertion. Although Assert provides a number of very simple methods, I've seen these frequently used inappropriately, causing unit test failures to be unnecessarily difficult to track down.
Assertion Selection
When reviewing unit tests, one of the typical activities is to ensure that assertions are being used appropriately. When developers first start to write unit tests, assertions are often used inappropriately and as such reviews can become very time consuming. Tools play a major part in development and can automate many of these kind of manual review activities. PMD is one such tool, and it provides a rule set to deal with the common JUnit problems.
One of the most common selection problems is the use of the stated outcome assertion instead of the equality assertion. When the equality assertion evaluates to false, it includes information about the two objects that should have been equal in the failure message. This information allows a developer to quickly get an idea what went wrong in the test. If the developer had used a stated outcome, (such as assertTrue), no information would have been recorded about the object state. This typically leads to extra log statements being added, or the developer has to being debugging the test.
Ensuring that the appropriate assertion is used within each unit test, is a very simple thing to do, but it gives very clear feedback about failures and allows developers to quickly track their cause.
// assertTrue("code worked", true);
// this should be removed as it serves no purpose
// assertTrue("code didn't work", false);
// Fails a test with the given message.
fail("code didn't work");
// assertTrue("actual is not empty", !actual.isEmpty());
// Asserts that a condition is false.
assertFalse("actual is not empty", actual.isEmpty());
// assertTrue("object is null", actual == null);
// Asserts that an object is null.
assertNull("object is null", actual);
// assertTrue("object is not null", actual != null);
// Asserts that an object isn't null.
assertNotNull("object is not null", actual);
// assertTrue("objects are the same", expected == actual);
// Asserts that two objects refer to the same object.
assertSame("objects are the same", expected, actual);
// assertTrue("objects are not the same", expected != actual);
// Asserts that two objects do not refer to the same object.
assertNotSame("objects are not the same", expected, actual);
// assertTrue("objects are equal", expected.equals(actual));
// Asserts that two objects are equal.
assertEquals("objects are equal", expected, actual);
Assertion Configuration
The equality assertion method provides a very simple contract, requiring the expected and the actual value. Although the contract is simple, one of the most common problems I have encountered, is that the arguments passed in to the method are in the wrong order (e.g. the expected value argument is actually the actual value and vice versa).
Although this is a trivial issue to correct, I have seen developers waste large amounts of time trying to work out what's wrong with the code when a unit test fails. The developer immediately start to scratch their head as the values don't seem to make sense. Without reviewing the unit test, they dive into the code to solve the problem.
I have seen this happen countless times, and every time it happens, the developer in question can't believe they didn't have a look at the unit test first. The equality assertion isn't difficult to use, you just have to remember; expected, actual.... expected, actual.... expected, actual.... expected, actual....
// assertEquals("objects are equal", actual, expected);
// Asserts that two objects are equal.
assertEquals("objects are equal", expected, actual);
Assertion Messages
xUnit Test Patterns provides an great discussion about the assertion message pattern. Most developers I've spoken to, do add assertion messages to their tests, and I also personally find them very useful. I completely agree with Meszaros when he says;
// assertTrue(actual.startsWith(expected));
// Asserts that a condition is true.
assertTrue( "Actual should start with expected but actual was '" + actual + "' and expected was '" + expected + "'", actual.startsWith(expected));
Conclusion
If you are writing unit tests, spend a couple of minutes reading over the reference manual to see what assertion methods you have to work with. xUnit Test Patterns breaks down the types of assertion into; Single Outcome, Stated Outcome, Expected Exception, Equality, Fuzzy Equality. Understand what each assertion does and more importantly, understand when and where to use assertion. Test failures become much easier to track down, when it's clear what went wrong. Use the right assertion, use the assertion correctly and give it a meaningful message. It really is a simple as that, what could possibly go wrong?
Tuesday, 23 October 2007
8,000th Spring Forum Post
Just over a year ago, I started posting on Spring Forum. I started off by answering the odd question and very quickly I started clocking up quite a number of posts. I've just noticed that I've crept over the 8,000th post mark. I've never really contributed anything back to open source software before, so I've found it really rewarding to try and help out a few people. Hopefully I've done that, and I've also learned a great deal along the way!
I was introduced to Spring back in 2004 by our team leader. The project I'd been working on had been dogged with problems since it's conception. It began with a very long and drawn out big up front design. Next a homegrown architecture was developed, this quickly became came very cumbersome, requiring numerous classes to implement even the simplest feature and also lots of XML. There were to be no dependencies on third-party software, so pretty much everything was developed from scratch. Deadlines were sailing by with small changes taking longer and longer to implement.
Overtime small parts of the system were restructured and the components in the code base started to show some synergy. This process of restructuring continued over several months, with a very slow and measured approach. Once the bones of the system were exposed, we felt we had a pretty good chance of turning the system around.
We started by introducing Spring and Hibernate into the system in a very structured manner, picking off little pieces at a time. It became clear very quickly that this combination of projects were a good fit for what we were trying to achieve. The size of the code base started to decrease very quickly, and we started to see what the system was really about. After a short while, it was visibly apparent the project was going to be successful (some would say it ended up being a little too successful, but that's another story) and the system was at last a pleasure to work with.
The project was great fun and actually came in ahead of schedule (which was a surprise to everyone). At the same time, we leveraged Spring's support for remoting, Quartz, Hibernate and also replaced the existing security solution with Acegi. The finished product removed the legacy cost of the homegrown solutions we had developed and turned the focus to solving the core business goals. This led to huge improvements in all aspects of development, but most importantly, we could focus on getting the most important parts of the system right.
After this project, I've used Spring a number of times on various; mini-projects, proof of concept demonstrations and my own personal evening projects. Some of these projects only used Spring as an IoC container, others used a great number of the features it has to offer. This has always been one of my favourite parts of the Spring, it's al á carte approach to using as much or as little as I require. I also love the fact the that it's possible and also often encouraged (have a read of the reference manual for more information) to have no dependencies on Spring in the actual code. Likewise, if you don't mind these you are free to use annotations to reduce the amount of XML required. Spring really does provide great choice for developers.
So Spring has helped me a great deal with my work, but so have a number of other open source products, so why help out on Spring forums?. There are a few reasons for this. I've read a number of forums for various projects, but the content and tone of Spring forum was one of the most professional I have seen. It's a pretty friendly place, without the abuse and negativity you sometimes get with community support. If people can help they do and if they can't, they can usually suggest somewhere else you might be able to find help. There are also a huge number of subjects covered on Spring forum. It's not just Spring that is discussed, the Data Access and Architecture forums, cater for lots of non-Spring matters. Lastly as the Spring portfolio has grown, the forum has become even more interesting, and seems to be evolving towards becoming a general enterprise Java forum.
I've helped out quite a bit on Spring forum over the past year, but I've also learnt a great deal in return. As far as I can see it's been a win win experience. Erwin Vervaet contacted me after seeing my name popping up on Spring Forum and invited me to be one of the technical reviewers of his new book Working with Spring Web Flow. I've also been contacted by a number of people working on both open source and commercial projects, asking if I would be interested in participating in some capacity. I've also met a number of very intelligent and talented individuals who have not only helped me, but also given me some great ideas. None of this would have happened without my forum contributions.
I'm not currently using Spring on a day-to-day basis, but I do have a number of side-projects that use various parts of the Spring portfolio. Since I first started using Spring, there have been a number of milestone releases and the project has gathered a great deal of momentum. I'm eager to see the future direction of the entire Spring portfolio, I'm sure we are in for an interesting ride!
Thursday, 18 October 2007
Parleys.com: My new favourite site
For the past few months, I've been spending most of my lunch breaks viewing the plethora of content available on Parleys. I first heard about Parleys courtesy of Marten Deinum, during a conversation on Spring Forum. Back then it seemed to be a well kept secret, but according to it's website, 45,000+ people have now visited the site.
For those of you who haven't had the pleasure of visiting Parleys and don't know what it is, the home page describes it as:
The Parleys.com site wants to become the premier Java e-learning site where you can listen and subscribe to many Java related podcasts or view the flash talks, hopefully all resulting in improving your Java skills.
![[image]](http://mowser.com/img?url=http%3A%2F%2Flh5.google.com%2Fkarldmoore%2FRxezN0JuZVI%2FAAAAAAAAABM%2F-ahbRVkq5BQ%2Fs400%2Fmain-page.jpg)
There's a wide array of presentations available (over 100 at last count), so there should be something there to interest you. Each presentation gives you a handy overview of the content, the running time and also the votes that have been cast. All of these together, make it very easy to choose something to fill your lunch break.

The presentations provide audio, video and also slides to accompany it. It's great to be able to leave the presentation going in the background whilst I'm do something else. If I really have nothing to do, it's great to be able to view the additional content the slides provide. One feature I've found invaluable however, is the ability to skip through the agenda. When you have to get back to work, it's so nice to be able to carry on watching from where you left off when you get home.

If you haven't already used Parleys, I would thoroughly recommend a visit. I've found Parleys to been an invaluable tool for learning about new technologies and techniques. Over the past few months, I've seen a large number of presentations on topics that I previously knew virtually nothing about. There are typically new presentations added at least every couple of weeks, so I'm looking forward to seeing what content is added next. And lastly don't forget to vote for the presentations, it's great to know what other people did or didn't enjoy!


