Monthly Archives: February 2009

Creating a thread dump in Eclipse

I’ve been trying to generate a thread dump in Eclipse, figuring out why an ant build wouldn’t stop running after all junit tests were finished. The JDK1.5 had some tools for showing a thread dump, but they seem to be deprecated and I couldn’t find any alternatives.

In the end the solution was simple… Run Eclipse with the eclipsec.exe (on windows obviously – don’t know if there are similar executables on other OS’es) instead of eclipse.exe. This will leave the console running, where you can do the well-known ctrl-break combination for generating the dump.

iPod not responding

Well, my dear old iPod stopped responding again… After plugging it into the laptop, nothing happens and the iPod refuses to do anything. So I looked up this problem and found a little trick for resetting the iPod : hold the menu button and the center button at the same time, until the apple logo apears. Maybe not very spectacular but very handy!

Keeping PHP code maintainable using autoload

There are a few rules you should apply to keep your PHP applications maintainable. One of these rules is avoiding too many dependencies between different files. Take a look at following example :

a.php :

require_once 'some_dir/SomeClass.class.php';
$someObject = new SomeClass();
// some functions and stuff using the $someObject

b.php :

require_once 'some_dir/SomeClass.class.php';
$someObject = new SomeClass();
// some functions and stuff using the $someObject

some_dir/SomeClass.class.php :

class SomeClass {
   // some functions and stuff used by a.php and b.php

Now, moving SomeClass.class.php to a new directory would require both a.php and b.php to be modified. In this case, modifying two files is not such a big deal, but if 100 files use SomeClass, this becomes a problem.

Every problem has a solution, and the solution in this case is the spl_autoload_register function which was introduced in PHP5. Read more »

Las Vegas!

Las Vegas

Las Vegas - taken on the Strip in 2006

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial 2.0 Belgium License.