Ideas about clean if statements

If you’re reading a lot of code you may get to the point where you’d like it to be clean, so it’s easier for you to read. There’re a lot of resources about the beauty of code around and in this post I’d like to share some ideas about writing concise if statements.

Although these ideas may apply to a lot of different programming languages I chose to give examples written in Java, PHP or Python. There should be no problem to translate this into other, similar languages.

Continue reading →

German translation for xRecurseDiff

I was searching for a simple Windows application that compares the files of two directories. This comes in handy if you’ve downloaded an update to some Open Source software and want to know what exactly changed in the new version. So I found xRecurseDiff and it was perfect for my situation.

Since there wasn’t a German translation for it I created one and the author, Matteo Lucarelli, integrated it into a new release. If you’re from Germany and don’t speak English you may want to give this software a shot.

Iterating over the characters in a string

I was wondering what would be the fastest method to iterate over the characters in a string with Java. A small test implements the following things:

  • using an Iterable
  • toCharArray()
  • charAt()
  • calling charAt() on a CharSequence

You can download the Eclipse project as a tar or zip or browse the code online here; have a look at the StringIteratorTest class first.

Continue reading →

Caching with dynamic proxy classes

In my last post I used AspectJ to implement a cache that stored the returned result of methods with a special annotation (@Cachable). If you can’t use AspectJ you may want to use a dynamic proxy class: in this post I’ll present a solution for this.

You can download the Eclipse project as a tar or zip file or view the code online here.

Continue reading →