Java

Spring versus Guice

I am a bit of a heretic in my frameworks in that I don’t really like Spring. I don’t like it at all, in fact. I do recognise that it does a genius bit of work in providing an Enterprise framework for Web Container based applications and that it has created a huge and much needed kick up the ass for enterprise frameworks in general but I don’t like it.

For a start I don’t really get it. As it’s grown it seems to have acquired all the traits of the J2EE frameworks it set out to replace. It has those weird sprawling configuration files, it has loads of modules that all do different things in similar ways, it has a high learning curve.

Using Guice has put all my peeves about Spring into a context. Guice is lightweight, it is written in Java, its configuration can be traced through IDE tools. It only does one thing and it does that in an intuitive and powerful way.

Spring 2.5 have been released recently with the all important Annotation support. I tried to take a look at it again but ended up huffing off once again. I am certain that my problem is documentation, almost all of it is written in the form: “Just add this to your web.xml and you’re good to go!”. Great, but I just want to try the damn thing!

The terminology is also clunky, compare Guice’s @Inject to Spring’s @Autowired. I think they do the same functional job but I don’t really know as I don’t know what Autowired is meant to mean.

Spring is so ubiquitous that I expect I will have to learn it at some point but at the moment I am happy for that moment to come to me.

Standard
Java

Guicing Struts 2

Look how deceptively easy the Guice User Manual makes adding Guice to a Struts 2 app appear. Look, it says, just add one jar and all your dependency injection needs will be meet. Of course what it fails to tell you is that in addition to adding the plugin JAR, you also need the base jar, the servlet jar and if you want it to work you need to download a fixed plugin jar. At one point it was moaning about commons-logging as well!

With all that done though, it does indeed work as advertised.

Standard
Macbook, Software

Music for the Mac

When I switched to OSX I was surprised to find that the “just works” system had no support for Ogg or FLAC. I also missed the simplicity and power of programs such as CDEx and MusikCube. I have had a look at all kinds of replacements but recently I was delighted to find a two programs that fill exactly the same niche on OSX. Max is a ripping program with a more elaborate interface than CDEx, this makes simple ripping a little more involved but it is possible to set up different encoding outputs for each rip so that once the track has been ripped it can then be encoded to different formats. You could produce a lossless FLAC version and a radio quality MP3 version for a small flash player. I haven’t been able to produce different encoding settings for the same output format and I am not sure that is supported.

Of course having encoded the music you also need something to play it on and finding a decent player on OSX is hard due to the smothering presence of iTunes. Cog is a player with a lot of features and decent format support that has a clean and simple interface. It is now my player of choice on the Mac and I would highly recommend it.

Standard
Java, Software

XWiki

I downloaded XWiki and gave the standalone application a whirl. I’m in the market for a simple wiki, I have used JSP Wiki before and it is fine but it can be a pain to setup correctly and I would also need to figure out how to secure editing offline first (as this is meant to be a public-read, private-edit wiki). My first impression is simply one of sluggish performance. It has a lot of nice features and it does arrive locked down but viewing and editing the pages is very lethargic and the Ajax is painfully slow. This could be the server but other servers are proving snappier.

Interestingly it seems to create a database in memory and import/export the data to file on startup/shutdown. I’m not sure what the advantage of that is, it seems counter-intuitive. Looking at options for a standalone database I am unsurprised to find a not saying that Hibernate does not play well with Derby. The lack of support between products built for either Derby and HSQLDB is annoying and seems unnecessary. However from past experience I know not to try and swim against the tide on this. If the developer worked exclusively on one or the other than chances are it is going to work better with the intended platform.

I also spotted a release note about a bug that requires Tomcat Security to be switched off. That doesn’t seem to be something you want to ship with. It’s not exactly the way you play with others.

Standard
Celeb Spotting, London

Paul Whitehouse and Charlie Higson

Wandering past the Almeida, side by side, like they were friends in real life. Higson had a white paper bag, which given the location and the improbability that he was out seeking a crafty afternoon kebab suggests a bite to eat at Ottolenghi. There is a certain odd couple quality to them, Whitehouse slightly brash and London; Higson diffident, quiet, very well-spoken. Both smartly dressed and not short a bob either.

Spotting them together must be extra points. Weird trivia: I am one of twenty people who have actually read Higson’s novel Full Whack. It is gruesome in parts, strange in others and is the only book I have read that features a dash along the M4 through Wales during which all narrative momentum is lost.

Standard
Java

Build it

This is a brilliant article that I have been using all last month on my work projects and it is both immensely powerful and very practical. It has made testing much easier and saved a phenomenal amount of time. However Nat doesn’t quite explain fully why it is so brilliant. What I have found is that once I have configured a Builder then actually I tend to use the same base object with minor alterations. If I am testing a sales catalogue for example and I want to have a test chocolate bar, then chances are I actually want three or four of them, all pretty much identical except for an id code and name. Using this technique makes it a doodle to knock out several objects in as many lines.

When I started I was conscientious about trying to provide a readable and complete API, later I realised “why bother?”. You need to find some sensible defaults for the necessary fields in the object but once you have you only need to implement the API surrounding the testing you are doing. Once you realise that then you get faster again. A lot of my work involves refactoring an old application and I am constantly surprised how few fields are actually used in the various beans and value objects. Often if you supply the “key” fields (the uid and anything else unique) then nothing else matters.

Standard
Java

Upgrade everything now

Okay so having got my PC working I foolishly did two things. One I tried to resize my disk partitions (hey in 2003 10Gb was all I would ever need for the C: partition), two I tried to re-install Windows XP after a house move. I got XP to install but couldn’t find my license key. So I decided to bite the bullet and buy Vista Home Premium instead and just get everything done in one go.

So Vista arrived this morning and this evening I stuck in the USB external DVD drive I use and… heard the DVD drive grind uselessly on the DVD for a while. Quickly chucking in a normal DVD I confirmed that that wasn’t a problem and headed over to Microsoft support. In the advice about unrecognised media it mentioned checking Firmware revisions on DVD players. Well, so be it, after all the drive is a couple of years old now, and so onto the Samsung website. They have a little updater program, that only runs on Windows… so now I am going to have to take my external DVD drive into work along with the Vista disk. Try the firmware upgrade with the disk and order CD copies of Vista if it still doesn’t work. Why should I do the latter? Well because Microsoft’s site for ordering alternative media doesn’t work with Firefox.

How come some many tech problems can only be solved by having a working platform in the first place?

Standard
Java

The Agony of being a PC Home Builder

My PC did not survive my housemove. When I booted it the BIOS screamed that there was a processor fault and that the gig was up. Dismantling the motherboard revealed no obvious faults or damage with the system but there it is; the PC was not going to boot. So one postal strike and shorted order later a new Intel Dual Core and Asus P5B-Plus (Vista Edition) arrive. With the normal sense of dread associated with assembling and dissembling PCs I set to work this weekend. I marvelled at how easy the new clip together processors and heatsinks are to installed. I worried that I’d screwed the memory by accidentally installing backwards and then I screwed the assemblage back together and thumb-screwed the case into one piece. Having completed I actually thought the whole experience wasn’t so bad. Buying an expensive Coolermaster case certainly made assembly easier than it had ever been and the rest of it was mostly clipping pieces together.

So I decided to boot, first boot works okay and I get to Windows but I need to set the BIOS to it’s defaults and I can’t use any port on the back of the motherboard. So I reboot, enter setup, hit the defaults and then restart. And I get a very cryptic error message that says Intel CPU uCode error. That’s it. Apart from a message that says “F1 to resume”. When you press F1 it reboots and does the same thing. Woe begins to fill my heart and tears creep into the edges of my eyes. What the hell is this about?

Well Googling didn’t really explain much other than people who bought the Asus P5B motherboard often have this problem and it is related to the processor. Every post recommends a BIOS flash. This is a brand new motherboard, sold as being Vista compatible, with an E6550 Intel processor which is listed as being compatible with the board. Why the hell do I have to flash the BIOS just to make the damn thing work?

There is however little choice; surveying my options I can create a bootable floppy; if I had a floppy of course, or a disk drive. Thankful this being the new millennium and all motherboard manufacturers have realised that perhaps people are not stashing obsolete hardware away in case they find a manufacturer unable to ship a motherboard which allows to use one of the most standard processors to have hit the market in years. So instead you can use the USB flash drive update.

This involves: downloading the ROM image, unzipping it to your flash drive. Sticking the drive into a functioning USB port (in my case my USB bracket was fully functional), then booting. When you hear the beep press the Del key. Then hit Alt + F2 before the BIOS boot trainwrecks on the same uCode problem. With that done you should be in the EZ Update program. Select your USB drive from the DOS-like menu and select your ROM image. The application will then read and verify it and you can zap your BIOS and get on with wondering why Creative’s MediaSource software doesn’t recognise the Creative soundcard you just installed when everything else sees it just fine thank you.

As you might have guessed finding the right BIOS flashing process took some trial and error. Seriously ASUS UI guys, what was happening at the meeting where you decided that the way people should access your new “easy” flash utility would be to hit Del, followed by Alt + F2 in quick succession? All of which has to be done exactly as otherwise you have to hit the reset button and kick off the process again.

These kind of problems make you wonder why you ever bother putting together your own kit, why not just leave the agony to Dell?

Standard