From Java to Groovy

Recently I’ve been playing with some old Java Swing applications and I found myself wishing that I could replace all the anonymous inner-classes with some clean Groovy closures. The job of converting a java source file to a groovy source file is pretty simple and eminently scriptable. Here’s my take on a python script to do just that: from optparse import OptionParser from subprocess import Popen, PIPE import os def rename(src, dest, use_svn): if use_svn: output = Popen(['svn', 'rename', src, dest], stdout=PIPE)....

Logging Guidelines

Logging - this is something we as developers do very badly - perhaps we need to ban the debugger. Unless you've worked in first-line support or in OPS, the only time you ever look at a log file is as a last resort. This is unfortunate, since the last resort may occur when you are trying to figure out why someone has lost money or when your company is about to be sued by a client (usually for losing their money, video, kids photo, etc)....

HTTP method primer for RESTful web services

The following is just a reminder to stop me from getting confused ;-) GET Used to fetch a resource. The server sends back a representation of the resource in the response body. Safe operation (see below). DELETE Used to delete a resource. The response from a server may contain a status message or nothing at all. It is usually nice to send back at least a 204 (No Content). Idempotent operation (see below)....

Reading code Vs searching code

Modern IDEs now allow you to search for a class or a file and go to it from the search results. On my last few projects I've seen developers using this feature almost exclusively rather than navigating their code tree. This is a very nice feature that I really enjoy using but does it have a dark side? I'm an old school hacker and I like to know how my_code is structured - its packages, dependencies, web root folders, output folders for the IDE and for automated build scripts, etc....

Concept To Cash Every Week

Turning on a sixpence - No excuses: Concept To Cash Every Week. Just saw this on InfoQ and it blew my mind. This is what I'm talking about when I mean that details matter and that there has to be a better way to deliver value to a customer. Have got to try the Pomodoro technique on my current project to see if it can improve pairing between developers (er, mostly between me and whomever is unlucky to be pairing with me)....

Using a Samsung TV as an external monitor

Here's a weird bug. I connected my macbook pro to my Samsung widescreen TV - it was detected but I had to select 59.9 as the refresh rate (rather than then autodetected 60) otherwise the TV just sat there with a message that I was using an unsupported display setting. That's fine but how to do this in clamshell mode as macs seem not to share monitor settings between dual monitor mode and clamshell mode (or for that matter a mac mini connected to the same TV)?...

Asynchronous HTML and HTTP

This post is to remind me that the next time that I am asked to consider using AJAX on a project to actually have a more careful think about the project's design and user interaction requirements. If I take the time to look at what I really need to retrieve dynamically then will AHAH do a better job more simply than AJAX & DOM manipulation? Will it make my application easier to test?...

JUnit tests and the file system

Writing unit tests for classes that operate on files has always been a little weird. Every developer & their dog has their own way of either abstracting themselves from the file system (ala Spring’s Resource types) or by creating some sort of a file system sandbox that is cleaned up at the end of the test - after all we don’t want to litter temp directories with files that will never be used again, do we?...

Another example J2EE application

I've uploaded to GitHub (http://github.com/tomcz/pico-webapp/tree/master) the web application that I use to teach people about dependency injection (using PicoContainer), post-redirect-get browser interaction, RESTful URIs and strict template rendering (using StringTemplate). This application does not use Spring Framework by deliberate design - as soon as I introduce it to any teaching session I spend more time talking about Spring then talking about what I am usually there to accomplish. As usual, any comments, bugs or enhancement requests are very welcome....

How to resize iTunes on OSX

I've updated to a smaller macbook - unfortunately iTunes remembered its previous size. Usually you can go to the Window > Zoom menu bar option and resize a wayward mac application, but iTunes just turns itself into a little application - not quite what I wanted. However, if you hold Alt/Option key while you click on Window > Zoom in the menu bar, iTunes will resize itself to fit the available screen area....