More Readable Test Names

We put in a JUnit hack into our latest project that allows us to produce more readable test names.

@Override public String getName() {
    return getClass().getSimpleName().replaceAll("Test$", "")
        + super.getName().substring(4).replaceAll("([A-Z])", " $1").toLowerCase();
}

Turning testTellsMeHowMuchInterestIEarnInAYear() from the BankManagerTest into Bank Manager tells me how much interest i earn in a year..

Note the disclaimer: Tests in IntelliJ are no longer clickable afterwards but the stack traces still are

An Eye Opening Open Source Evening

Thanks to Carlos, Monday night was spent at Guanabara, an excellent Brazillian club in the middle of London (and just around the corner from the office). Organised by a London society called Cybersalon, Guanabara held a fairly decent sized crowd to listen to a couple of guest speakers.

The evening was about demonstrating what initiatives the Brazilian Ministry of Culture were doing that involved OSS. Gilberto Gil, the Minister of Culture, and Claudio Prado, the Digital Policy Coordinator for the Ministry of Culture talked about the hotspot initiative that empowered existing groups to share their culture leveraging OSS on old computer hardware. The Ministry provides free internet and some levels of equipment to enable groups to distribute their cultural activities to a wide audience and delivers education to allow them to do this in a self-sustaining manner.

For me it was a fantastic evening to hear about the different attitude and the compelling reason why OSS is so important to countries such as Brazil. I found it extremely refreshing to hear about the use of OSS from people with completely good intentions and without the excessively strong opinions of some OSS zealots, which can be so offensive at times. I think the key success to the Hotspot initiative is that the importance lies in the value for empowering people, and not the technology.

The evening was topped off by a top performance by Gilberto Gil (who is also a famous musician and has produced songs under the Creative Commons License) and my small part in a table football championship for charity.

Be Online, Be Broadband

So here I am configuring my wireless router on a late Thursday/early Friday morning. Why? Because after getting back from the pub, I found my 24Mbps DSL2 had finally been activated. I was surprised to see how quickly it was connected, after all, I had only placed my order for DSL from Be Unlimited last Thursday and had heard nightmare stories (sorry Karl) about other ISPs (i.e. Bulldog) where people have been waiting for more than 6 weeks to get connected.

I must admit that customer service so far has been fantastic. After signing up (on quarterly terms) I got emails telling me what I would expect. One told me that my wireless router was supposed to arrive Thursday (but arrived Wednesday) and I would be connected by Tuesday. On Monday, I received an email saying because of reasons outside of their control, the connection was postponed for a couple of days… and now here I am connected What a bargain! Now all I have to do is learn how to configure this router to make it a little bit more secure. By the way, let me know if you want to get connected. 🙂

Impressed by Hibernate Annotations

I have been a big fan of Hibernate for some time and I have only used Hibernate 2.x in the past. Most recently I jumped right to the cutting edge and have been using Hibernate Annotations on my current project. Even though Hibernate Annotations are only in a beta release, everything worked fairly seamlessly and any issues we had were only minor inconveniences. My conclusion is that it is definitely worth moving to Hibernate Annotations if you are on a project or about to start a project based on Java 5.

There are many great reasons to use Hibernate Annotations and my list includes:

  • Reducing your dependencies on XML for configuration files
  • Increase the speed of your development loop as annotations become part of your application and you don’t have to worry about copying files into your classpath
  • Removes the complexity of ensuring that your code and XML files become out of sync (though XDoclet eases this a little, you still have to make sure the generated files end up in your classpath)
  • Modern IDEs (specifically IntelliJ and I think Eclipse) makes adding, changing, and automagic completion of annotation information an easier task that looking up document references.

I have always been pretty impressed by the amount of documentation for Hibernate (it is such a rarity for many open source projects) and the same level of diligence has been applied to the documentation for Hibernate Annotations. The documentation takes you through pretty much the same detail as the normal Hibernate reference and is enough to satisfy most needs. I am sure that we will be seeing another version of Hibernate in Action book coming soon when Hibernate Annotations release their final version.

Caveats for early users of Hibernate Annotations

  1. Lagging Tool Support – Like the lag there was (is?) when Java 5 was released, the same could be said for tool support for Hibernate when using annotations. At least of this writing, we had difficulty using the schema export task as it seemed to instantiate the wrong type of Configuration object, but a quick java snippet seemed to fix it for us.
  2. Strange Default Behaviours – As I have not really used Hibernate 3 in anger, I’m not sure if this is a Hibernate issue or a Hibernate Annotation issue but nevertheless strange. Annotations such as the field level @Id one does not default to the GeneratorType.AUTO by default.
  3. Half Hearted Lucene Integration – I’m beginning to become a really great fan of Lucene and was surprised to see that Hibernate Annotations now had an @Indexed annotation for Lucene support. Unfortunately it seems like what support was half-heartedly added demonstrated by minimal documentation on indexing objects, but not necessarily about retrieving them. Upon closer inspection the index created by the Annotations is useful if you are using a different or custom Lucene Analyzer upon reading it and there is no way of configuring it.

Tips for migrating to Hibernate Annotations

Obviously I have been fairly lucky to be using Hibernate Annotations on a new project. For those that are on an older version there is likely to be more effort in migrating. The documentation seems to imply that the guys have given much though to people migrating from declarative Hibernate mappings and it is good to know that you can mix and match Hibernate Annotations and normal Hibernate configuration files and specify which configuration will override the other (although you cannot use both on the same entity hierarchy). A suggested migration path would involve:

  1. Migrate from Hibernate 2.x to Hibernate 3.1
  2. Introduce Hibernate Annotations in replacement of configuration files for a few of your domain objects and test that your build and release process continues to operate
  3. Continue to replace configuration files for Hibernate Annotations for the rest of your domain.

Ignorance Is Not Bliss

Internet access in the hotel I’m currently staying at is ridiculously expensive (at £0.50 per minute) so until I actually start work tomorrow, I’ve been using public Internet cafes. The best value ones I have found in London so far are the £1 all day ones somewhere on Oxford or Regent Streets. I’m not excessively worried about computers that I have control of, but I am always concerned when using public computers, especially when you are logging into various accounts (email, blog, photo albums, and most particularly bank accounts).

I am not surprised that the computers in the Internet cafes are windows based, meaning that it already is more susceptible to certain security issues. The bigger thing that concerns me is that these computers allow anyone to install anything they like. This worked to my benefit, allowing my to install Skype, Firefox and to run Putty from my flash disk, but opening up this privilege also means that more malicious people could install any sort of sniper software, collecting passwords and account information, and potentially sending them to the user. One may have to be even wary of the owners of the café who could be harvesting this information for themselves (beware of what you pay for).

Fortunately I am informed enough to work out whether or not there is malicious software running before I give any login names and passwords, and where you should go to clean up traces of login names and passwords, but I wonder about those that are ignorant to the fact their identity could easily be stolen?

Leaving Footprints

Writing software for businesses usually has some balance of perfectionism versus writing enough to get the job done. Other people refer to the latter as pragmatism. I think most good developers tend to sway from one extreme to another, as being extreme on either end is likely to either not deliver a system, or leave a very unmaintainable one.

I tend to come more from the pragmatist camp, but would love to be an idealist in the real world (but then economic constraints of time and money come into play). Leaving footprints is something that I have been thinking of lately. It’s a term I think of when we make choices that are less than ideal, by leaving behind something (an impression in the sand) of what made me make that choice I did at the time. If I remove that condition (or series of them), then perhaps someone can make a better choice.

I currently tend to use two different techniques for “leaving footprints”, the first with being comments, and the second being automated tests. Focusing on the fact that I am leaving behind an impression of some sort has helped me in the past to really distinguish between the choices that I have to make and to really explain the forces behind them all.

Moving On

It really hit hard this week that everything was really happening. I felt a mixed bag of emotions leaving my current client yesterday, both excitement yet sadness. I had been there for almost 18 months, and had formed some great relationships with the people there. It had become a fun environment to work in, and the work itself was interesting.

In about four hours, I depart to work for the London office of my current company. It will be such a stark contrast from the small and disjoint Brisbane office that I have enjoyed working in since I joined. There will be over 25 times the number of employees in the office than what I am used to and will be thrilled to meet them all, especially those whose blogs I find myself reading.

From what I have read and heard from various people, the city of London offers so much more in a week than what you would get in a good month in Brisvegas and the travel opportunities to not so distant foreign cultures is just a few hours flight away. I’ve heard the food can be amazing, but I have prepared myself for the difficulty in getting some types of really fresh food. I’m looking forward to the music scene, and in one night being able to quickly compose a list for the rest of the year of such big name acts I’d be keen to see.

For the time being though, I’m looking forward to having a small break with a five day stop over in Dubai. I’ll try to post some pictures in my photo gallery, and some more stories depending on how easy it is to get access the Internet.