My first post on LinkedIn: Don’t over-engineer, listen to your customer. If software development / web app development is of any interest go give it a read :)

Customizing Easyeclipse’s runtime environment

The error dialog raised by EasyEclipseThis all started as an effort to solve a problem in getting EasyEclipse to run on my new laptop. The error initially surfaced as a dialog full of JVM output when trying to run Eclipse.

After some digging (i.e. running Eclipse from a terminal) the error was pinpointed to a problem in the JRE install that comes with EasyEclipse. The error was:

Error: no `server’ JVM at `/usr/java/easyeclipse-lamp-’.

Several searches on Google provided some others with the same problem, but no solutions. Since I’d wanted to run Eclipse under a newer VM anyway, I thought I’d try hacking and see if I could get Java 6 to work.

The solution was deceptively simple:

  1. Change into the EasyEclipse directory.
  2. Rename the jre directory ( jre jre.old).
  3. Link the JDK supplied JRE as the jre directory (e.g. ln -s /usr/java/latest/jre jre).

There is some output that comes to the terminal once Eclipse is started, but it doesn’t seem to affect performance at all. For all I know, it might even be normal output…

An OO rant against IE

The OO programmer in me cringes. I ran into a bug last week in my DOM traversion code that was a bit tricky to solve. The hardest part was isolating the problem since the code had worked before some logic changes needed to be done. Once the problem was isolated I noticed that I kept getting a Text-node that wasn’t an instance of the DOM class Text (which inherits from CharacterData which in respect inherits from Node) but something else (with a class of Text).

Without going into details of why I wasn’t getting a Text-node (I confess, I didn’t have the time to figure it out, just come up with a solution), I decided to solve the issue by inspecting the class of the node that I got. If the class was empty or Text I’d just skip it and go to the current elements parent, otherwise I’d just get the previous sibling with previousSibling. Of course the code for this is simply:

if ((node == null) || (node instanceof Text))
// Skip...
// Do something

This worked fine in Firefox. Time to test in IE. And what do we find? IE doesn’t recognize a class Text (or any DOM class). Searching for a solution on the Google didn’t provide any sensible answers other than the information that IE doesn’t create DOM classes are real classes but something else. So with IE you can’t try to use the simplest method to figure out the class of a node (for example in a NodeList returned by getElementsByTagName()).

The OO purist in me is screaming and crying. Such elegant simplicity taken away from me by IE’s stupidity. Aargh!

P.S. Don’t ask me how I solved it. The current fix is a hack that needs to be tested better before I’ll trust it.

On rewriting software vs. careful planning

A recent post over at the 37signals blog got me thinking about the importance of careful planning in software development. The 37signals folk are quite strongly in favor of agile methodologies in software development, repeatedly pointing out the value of releasing software early without a full set of imaginable features.

The projects they work on are such that the cyclical process in which the software is refined over several iterations of the develop-and-test-cycle (with several steps thrown in) doesn’t cause any problems. In fact, rapid prototyping in these cases gives the testers (internally or the users at large) something to play around with and offer feedback on, often refining the user interaction from what was originally envisaged.

A definition of Agile (or Xtreme) Programming points out that it’s a methodology better suited for situations with unknown or unstable requirements as changes to the requirements are to be expected during the development of a product. More rigorous change management is better suited for those situations in which the requirements are defineable at the projects initial design phase.

While I agree in principle with the separation of when the two different approaches to change management are to be used, I’d like to see more discussion on how to balance the use of agile programming and rigorous change management. I argue that most applications that aren’t limited to trivial input/output data scenarios have areas in which there are initially unknown requirements and well-defined requirements. Especially applications which require user1 interaction have undefined requirements which may change as prototypes are tested by the actual users of the program.

For example, the intranet application that I’m working on at work has quite a bit of well-defined unchanging requirements. After all, we’re using nationwide agreements on how to calculate salaries based on daily and weekly amounts of hours worked and how the date and time affect the modifiers of such calculations. But at the same time, the business logic of the application has been very poorly defined. In fact, I’ve found that the choices and decisions I made to establish a prototype from which to start off, have defined the way the organization works.

My biggest problem with an approach to software development that encourages rewrites is that tried and tested code may be deleted and bugs reintroduced. Especially when security is an issue, rewriting tested code shouldn’t be the first approach to refactoring. Or then the rewrite needs to be planned and well-designed to utilize the important parts of the tested code.

Of course this doesn’t solve the issue in which you need to rewrite the tested code because changes over time have made it into a spaghetti-like tangled mess. Ideas on how to solve this dilemma are well appreciated here, I’m in that awful place right now at work.

  1. Yes, I do talk about users. Especially when developing a product that will have a defined set of people using it, users is a term that is actually beneficial. And it doesn’t mean that I’d think of users belonging to a different set from people.

Publishing on a given date

If you’ve ever taken a look at either the Life of Jalo or Jermut, you’ve probably noticed that both sites create a daily page for the picture/strip. The way I’ve created it is that each file that needs to be shown is saved with the filename simply as the date (e.g. 20060428.jpg is today’s image in LoJ). This post will show you how the naive approach to triggering something based on the current date and time may backfire and how to solve it.

To prevent people from looking ahead of the current date I used a simple is statement that compared the date now to the image requested. If the imagefile’s name was greater than the current date, a HTTP 403 error code is returned. The code looks like this ($showTime is the date portion of the filename):

      if (date('Ymd') < $showTime) {
	return 403;
      } else {

Of course, by now all of you should be wondering exactly what is the timezone in which the date should change? Well, my intention was that we'd follow a Finland-centric approach to the whole thing and the new image would be visible at the strike of midnight in Finland.

This all worked fine until we moved our hosting from a Finnish provider to DreamHost. The Finnish provider's servers all used EET (Finland's timezone, UTC+0200) and date() worked just fine. DreamHost's servers naturally don't use EET as their default timezone and testing that everything works after I've uploaded an image was a bit too hard. Plus I like seeing the next days picture before I go to bed, or rather having Anna look at it and tell me if something's wrong.

Luckily PHP comes with the function gmdate() that returns the current date and time in UTC. Then, with some simple code we can convert the reference time to EET and we're back at the usual publishing schedule. After you know of the existence of the function, any problems caused by timezones can now be easily solved.