September 7, 2008 - Tags:

Crafting your code and respecting other’s

I noticed that a lot of developers don’t take responsibility laying out their code anymore. Using auto-formatters, auto-sorters and auto-clean-up-ers they surrender their work to their IDE.

I like to craft my code. I’ll break lines where it makes sense. I group methods in logical blocks. Every space I insert is intentional. It’s all part of the art.

Until a minute later someone runs their little helpers making a mess out of what was once a beautiful piece of text.

The number one reason seems to be to “reduce version control conflicts”. Of course there are less conflicts if all code looks the same. But: If you just keep mine as it is and don’t reformat it there wont be any conflicts either. Sorting methods alphabetically? Breaking a line in an awkward spot just because it has 83 characters instead of 80? Reordering import statements?

A good set of sensible coding guidelines and responsible programmers who love their art should be enough to keep a clean code base.

February 17, 2008 - Tags:

Synchronizing Subversion Repositories

Since Subversion 1.4 you can synchronize repositories easily. This way you can have a local copy which works when you’re offline. Great to keep a copy of your code + history on your laptop. The only thing to watch out for is that you can only synchronize it one-way, so don’t commit anything. Here’s how to do it on Windows:
more …

February 9, 2008 - Tags: ,

The Evils of java.lang.String.toUpperCase

String.toUpperCase is not as innocent as it looks. If you carefully read the docs you’ll see that the default signature asks for a java.util.Locale. The reasoning behind this is that there are language specific rules on how to convert lower case letters to uppercase. German, for example, has the letter “ß” which gets converted to “SS”, so “straße” becomes “STRASSE”. See the problem? The String length changed! This can trip you up if you stored it somewhere before you called toUpperCase. I’m sure there are lots of examples for other languages, so watch out and never store a String length.

(C) 2008 - Stephan Brosinski - All Rights Reserved