magpiebrain

Sam Newman's site, a Consultant at ThoughtWorks

Posts by samnewman

A meeting with more than six people in it can only hope to achieve one thing – to arrange more meetings.

* A huge supposition on my part, that 1. I’m going to come up with more than these ( It’s kind of like those bands that release “Best Of, Volume 1” – it’s just asking for trouble), and 2. that I’ll come up with so many that some kind of classification system is required.

During a pairing session today, we spotted some duplicated code and a period of refactoring ensued. The code in question related to some simple DB queries – the code for getting a connection, returning results and cleaning up was duplicated, with only the query and the exact part of the result set required being duplicated. We already had some code which could be used to remove this duplication – previously someone had written a DB visitor which was being used internally in a test class.

Extracting the visitor code out into a class in its own right was trivial. What was not was replacing the repeated code. After 10 minutes of head-scratching we had to ask ourselves the question “is this still refactoring”?

Let’s look at what we had done – we’d extracted out our visitor code to make it an object. The existing code using the visitor still worked. We couldn’t get other code using our visitor happily quickly. We decided to leave it and move on – the rational being that refactoring should be something quick you do in the normal test-code-refactor process. If you can achieve a quick win that improves code outside the scope of what you are working on, then great – but when improving code outside the purview of your current task takes too long, it feels like going off at a tangent.
Continue reading…

I have just discovered the delight that is pluggable search implementations in Firefox. Click on the Google icon to the left of your firefox search box, then click @Add engines…@. You are presented with a (rather ugly) page presenting a multitude of search plugins for everything from “amazon”:http://www.amazon.com, “imdb”:http://www.imbd.com, “SamSpade”:http://www.samspade.org and most importantly “AllMusic”:http://www.allmusic.com. Best of all you don’t even have to restart your browser to pick up your newly installed plugins.

I’ve been running a parallel feed produced by “FeedBurner”:http://www.feedburner.com/ for a few weeks now, and have been so impressed with the results that I’ve decided to replace my feed with the FeedBurner produced one. Anyone subscribing to my “feed”:http://www.magpiebrain.com/index.xml shouldn’t have to change anything – I’ve set up a redirect rule so you’ll get my new RSS feed complete with del.icio.us links spliced in, a “nice display”:http://feeds.feedburner.com/Magpiebrain of the feed if you load it in a browser (at least on IE – a Mozilla/Firefox XSLT issue spoils things a little), and it will even optimise the content for specific aggregators.

Teasers of the recent Batman film sent me scurrying off to re-read Frank Miller’s Dark Knight Returns, only to find that I couldn’t, well, find it. Sitting back (and scratching my chin in a position that I hope makes me look thoughtful, but I suspect makes me look like I’ve got a itchy beard) I wondered about what else I’d lost. A quick brainstorm later, and I had the following list:

# The Dark Knight Returns
# Muse’s Origin Of Symmetry
# Beat Takeshi’s Sonatine
# Fear and loathing in Las Vegas (Region 1 DVD)
# The tweezers from my Swiss Army Knife
# The desk-clip for my angle-poise lamp
# Dandy Warhol’s “You drive fast, I’ll do the drugs” T-Shirt. (I think my girlfriend threw this out)
# Black Books season 1 (DVD)
# An IKEA dressing gown, which I bought and never opened

If anybody finds any of this stuff, let me know will you? Alternatively, if you’ve lost anything give me a yell – I’ve got all kinds of crap sitting around that I have no idea how I got in the first place…

A laptop malfunction this week caused me to re-evaluate my backup strategy. I’ve decided against the “don’t back anything up” approach, in favour of the “backing things up is actually quite useful” approach. The laptop was fixed thanks to our helpful admin guy, however I’ve taken the hint.

The most important thing I had to consider when planning my back strategy is that I’m lazy – really lazy. If I have to even push a button to start a backup, chances are it isn’t going to get done very often. A quick poke around the hardware sites turned up the “Linksys Network Storage Link”:http://www.tomsnetworking.com/Reviews-155-ProdID-NSLU2-1.php (NSL). Simply put, the NSL lets you plug a couple of external USB drives in, and allows you network access via the wonders of Samba. The front end admin console lets you schedule backups of networked computers, which sounded right up my alley – now all I have to do is remember to leave my laptop turned on overnight (which is still asking a lot). I’ve ordered one from “EBuyer”:http://www.ebuyer.com along with a “Maxtor external drive”:http://tinyurl.com/2s3km, which should arrive next week. I’ll let you know how it goes.
Continue reading…

A largely unenjoyable couple of hours was spent tracking down a nasty little issue surrounding classpaths in cygwin. First a little background. On Windows, if you want to specify a classpath, @java@ expects it to be a series of semi-colon separated paths, like so:

set CLASSPATH=c:libsome.jar;c:classes;.;

On Unix, @java@ expects a colon separated list:

export CLASSPATH=/usr/lib/some.jar:/home/export/myarea/;.

I’m playing around with using a shell script to run my app on windows, however I’m using cygwin as I hate writing bat files. This is a bit of a problem however – cygwin expects Unix format paths, but we’re still running a Windows version of @java@. Once I’d worked out that this is what was causing the strange ClassNotFoundExceptions, a quick google turned up @cygpath@, which can translate from Windows to UNIX paths (and vice versa). So, when invoking @java@ in my shell script I just changed:


java -classpath $MYCLASSPATH org.package.MyClass

to:


java -classpath `cygpath --path --windows $MYCLASSPATH` org.package.MyClass

Next up, I can change my script to work on Unix by conditionally invoking @cygpath@ only if I’m running in a cygwin bash shell.

No posts from me in a while which has mostly been down to playing sys admin at my current client – more on this in a while no doubt. In lieu of anything of greater interest, I thought I’d remind you of two upcoming events for your calendar, if you happen to be in London in the next couple of weeks.

Firstly, the monthly “Java meetup(London Java Meetup – 23 August 2004)”:http://web1.2020media.com/j/jez/javanicuscom/londonjava/ will be on the 23rd of August. I’m hoping for something a little more laid back than last months mammoth affair as I hardly got to talk to anyone. No real topic, but expect talk on Java, beer, blogging and state machines.

Running both this and next Wednesday, is Geek Night London. More of a techy affair than the Java meetup – and non-Java specific too, it involves a bunch of us working on Open Source stuff, talking about it, and normally eating pizza. I’ll be working on either “JBehave”:http://jbehave.codehaus.org/ or “DamageControl”:http://damagecontrol.codehaus.org/ depending on how I feel. If you want to pop by for either this or next week, then stick your name down “on the Wiki”:http://geeknight.thoughtworks.com/index.php/GeekNightLondon.

I’m hoping to have another successful GeekNight tonight. It’ll be more development focused I expect – I’ll be working on a UI for JBehave (with a view to creating an IDEA plugin) and no-doubt others will be doing development they’d appreciate help with. If you fancy coming along, pop over to the wiki and “put your name down”:http://geeknight.thoughtworks.com/index.php/GeekNightLondon28July2004. More details can be found “here”:http://geeknight.thoughtworks.com/index.php/GeekNightLondon.