04
Feb 09

Developer Frustrations

I need unit tests for my unit tests testing whether the unit tests do correct tests or not. And a decent TestNG documentation.


22
Jan 09

Developer Frustrations

Constructing software surely is satisfying work. But these days I dream of constructing airships. What if you could actually see the product of your very own hands, climb into it, loose the tag lines and fly away?


29
Oct 08

Dirty Source Code

Why, oh why do classes, which have the purpose to remove something from documents, always have to be named “XYZStripper”? As a programmer faithful to the (often unwritten) coding conventions, I have to name instances of such classes of course – “stripper“. Unfortunately the names of those stripping methods do not quite match the juicyness of the class name. I would like to code things like stripper.renderNaked() or stripper.undoClips().

And with a swing of her hips
She started to strip
To tremendous applause
She took of her drawers

And with a lick of her lips
She undid all her clips
And threw it all in the air
And everybody stared

Chris de Burgh: Patricia the Stripper


23
Oct 08

Google Code Search

This must be either really new or – what seems more likely – I have slept over Google’s developments the last year. Google Code allows for a regular-expression-based search in publicly available source code. Nice one.


08
Sep 08

Don’t Rethrow, Please

Dear fellow Ruby developers, please kick the habit of catching  and rethrowing exceptions, thus ridding your users of the expeptions’ stack traces. Recently I had to patch the source code of an ActiveRecord adapter as well as the underlying DBI implementation in order to find out where one particular exception was originating from. This makes debugging code really a hassle. I haven’t had this kind of problem in Java since nested exceptions.


01
Aug 08

Scripting The Night Away

One of the very nice features of Mac OS X ist the ability of almost every reasonable application to receive AppleEvents, which makes the whole OS-app-bundle highly scriptable. Normally, Apple recommends that the scripting is done using a malevolent, programmer-unfirndly language named “AppleScript”. But there are alternatives, e.g. using Ruby together with the rb-appscript library.

As a first try, I wrote a small hack solving the following problem:

In Aperture, I normally sort photos in folders named YYYY_MM_DD, so when I sort them by alphabet (or Aperture sorts them and I cannot change the sort order), the oldest ones show up first. Unfortunately, iPhoto imported photos from my camera in the German format DD.MM.YYYY, so the alphabetical sorting is useless.

The ruby script goes like this:

require "rubygems"
require "appscript"
include Appscript

app = app(‘Aperture’)
puts app.projects
app.get(app.projects).each { |project|
  name = app.get(project.name)
  if name =~ /^\d\d\.\d\d.\d\d\d\d$/
    day = name[0, 2]
    month = name[3, 2]
    year = name[6, 4]
    app.projects[name].name.set(year+"_"+month+"_"+day)
  end
}


23
Jul 08

Documentation Note

If you are documenting Java methods, try to fit everything really important (like constraints for the method) into the first sentence of the javadoc. This sentence is displayed along wiht the overview of the class method.

Everything after the first sentence vanishes in the distance where no-one will ever read it.


12
Jun 08

Name That Code

Name That Code
Created by OnePlusYou

I named those codes, and boy, what a miracle – one hundred percent right. Try it yourself!


10
Jun 08

The Ultimate Code Browser

I want a Firefox Plugin that recognizes that the page I’m looking at contains Java, does syntax highlighting and, most of all, inserts links to the classes and methods referenced in the code. The plugin (or a server it can ask) should know where the source code of a class like org.springframework.beans.factory.BeanFactory can be found.

First I thought that such a plugin would need (or could at least profit from) sem***ic web technologies (no dirty words on this blog, please), but it probably wouldn’t. All we need is a global registry that maps package names to the URLs of the web interfaces of the respective source repositories. (Maybe Google Code Search could be such a repository, but its results are often pretty bad.) The plugin would also have to include a reasonably good Java parser, and maybe a heuristic to distinguish betweeen Java and non-Java text.

Why would I want such a thing? Well, I often have to dig through the code of some open source library in order to understand a bug, or just to figure out what I can do with it, and how, because the documentation is incomplete or wrong. Usually I create an Eclipse project and import the code from the source repository, but that’s quite a lot of overhead if I just need to browse the code for ten minutes or so. On the other hand, digging through source code on web pages, without the help of links between the pages, is just a nuisance.

And wouldn’t it just be so cool to have one of the most important features of an IDE as a browser plugin, enhanced by the power of the world wide web?

P.S.: Or maybe I don’t want a browser plugin – maybe I just want Google to put some more effort into Code Search? Come on, guys, you’ve got all it takes – the global repository, the parsers, the heuristics…


03
Apr 08

Use quote_value in Rails 2

This is just a note to all who, like me, wonder why the heck ActiveRecord’s quote method in model classes doesn’t work anymore in Rails 2.x: quote seemingly has been replaced by quote_value, though this is not listed on the deprecation page. So if you get an error that says undefined method `quote’ for your model class, replace the calls to quote by quote_value.


Better Tag Cloud