Them where the days

Kasia asks what was your beginning in computers?.

I started out with a VIC 20 when I was 13. All the games were crap (except Rockman!) so I started programming in Basic.

I learnt mostly from typing in programs in magazines, then started to write my own.

I think my first program was a dice rolling program for some fantasy game I used to play. What a geek!

Now I get paid to write computer programs, how cool is that?

JSTL Gripe

Now I am using JSTL in my JSP pages I have found something really annoying.

JSTL provides a very handy mechanism for calling properties on beans.

If you have a bean called "bob" and a bob has a method called "getFoo", then you just put <c:out value='{$bob.foo}'/> in your page and you get the result of calling getFoo on bob.

Initially, this seems very useful.

However, the Javadoc for the Method you call to put bob into the request for accessing in the page says the following:

Attribute names should follow the same conventions as package names.

Names beginning with java.*, javax.*, and com.sun.*, are reserved for use by Sun Microsystems.


So, the suggestion is that when you put a bean in the request you use the full package name, ie, request.setAttribute("org.boncey.beans.bob", bob);.

Ok, no problem, but when you go to access that bean in the page you can no longer use <c:out value='{$org.boncey.beans.bob}'/> as it thinks that boncey is a property of bean org and it barfs.

To get around this you have to use an alternative syntax; <c:out value='{$requestScope["org.boncey.beans.bob"]}'/>.

That is nowhere near as neat and succint as the examples indicate.

Why on earth did they bother even offering syntax that goes completely against the best practice indicated in the docs.

Definitely a case of the left hand not knowing what the right hand is doing.

No more struts.

I converted photodb from struts to jstl last week.

I did it using search and replace commands in vim, after I had learnt how to use backreferences (I’ve used them in perl for years but never in the replace part of a search and replace before oddly enough).

An example of one of them is:

%s/<struts:equal name=['"]\(\w\+\)['"] property=['"]\(\w\+\)['"] value=['"]\(\w\+\)['"]>/<c:if test='${\1.\2 == \3}'>/gc

I stuck them all in a text file and went through each JSP and copied and pasted them into the command buffer for each tag I found.

Was not too laborious, and now I have learnt about backreferences in vim I will use them a lot more.

I still have to do this site though, then I will be 100% struts free.

My reasons for changing over were simply that JSTL’s Expression Language is far more powerful than using tags.

Programming for fun or profit

Crap day yesterday. Coding to a tight deadline, nothing worked properly, everything took longer than expected.

At 7pm I decided I’d had enough and came home.

On the way home though I started thinking about some features I wanted to add to photodb.

I found it strange that after a frustrating day coding at work I wanted to go home and sit in front of the computer and code some more.

Then I started to think about what was so appealing about working on photodb at home versus working on some programming problem at work.

It’s not about being at home versus being at work, it’s something about the nature of the work itself.

Then it hit me. When I work on photodb I have no deadlines, no managers, no client (except myself) and fundamentally, if something I try to do doesn’t work I’ll just live without out.

This is the nature of working on something for fun rather than working for the man.

I dunno, always thought being paid to do my hobby, would be more… well, you know… fun.

coding the blog

I have added some more features to the blogging tool I am writing.

It now pings weblogs.com when I add a new post and it has a RSS feed also.

I have also added the ability to post comments.

I never intended to write those features.

But as I recognised that the majority of other blogs worked in this way I decided they’d be ‘nice to haves‘.

If I had known at the start the amount of extra features that needed to be implemented I may have just used some existing blogging tool instead.

But I enjoy coding the blog as much as I enjoy using it.

Once I have it in a state where I am happy with it, I will transfer my attention to photodb and add some extra features to the photo sites I have written (I have a todo list for that too).

If I ever get to a state where nothing is outstanding on either site I have a few more Web site ideas in mind.

I am quite happy to write new sites, it’s spending time entering content that’s the killer.

Hmmmm, wonder if there is a market for content-less Web sites.

I can provide a working site that requires content, someone else can provide the content.

It’s like herding cats

Just read this great article called Understanding the Psychology of Programming.

In it the author very clearly explains why programmers’ brains are wired the way they are and what steps an employer can take to get the best out of them.

It’s a very short and simple read and if you work as a programmer you should make sure your boss reads it.

Perhaps then he/she will understand why you get frustrated at an inferior working environment or why it’s a good idea to reduce the number of interruptions to you.

Of course, there’s always a chance your boss will think you’re making him read the article as a hint to get some job perk like nap privileges.

If that’s what they think then they are probably incapable of understanding programmers anyway. Tough luck. :-)

Photodb changes

Currently I am working on a new version of photodb.

My changes are along two lines.

1. Fix up the old schema (structure and rules for storing data in the database).

2. Create a system to allow me to mix words and pictures in a free-form style on the page.

Change 1

Change 1 is becoming more and more important as time goes on.

The old schema had certain rules which didn’t actually match the real world.

E.g. A photo didn’t have a photographer directly attached to it.

A photo belonged to a film instead, which then belonged to a photographer.

This initially seemed to make sense, after all, I put a film in my camera, which I own, and I then take all the photos with it.

But it all breaks if I ask someone to take a photo of me with my camera.

The you will see a photo of me on the site, but the photographer will be shown as me!

The new schema has a photographer attached to each photo, which matches the real world.

I also added a Camera table, and a film now belongs to a camera, rather than to a photographer.

All this breaks when I use a digital camera of course, I need to think about that some other time.

Change 2

The second change is also important.

When on my recent holiday it occured to me that my site didn’t really allow me to tell a story.

It allowed me to show a list of photos of course, but there was no context at all.

Most obviously, I couldn’t talk about anything that I hadn’t taken a photo of.

I thought about building a framework that would allow me to mix text and photos in a freeform style, so I could say, “Then we walked up this hill and saw this stunning view, on the way down we saw a deer but he ran away before I could take a picture” (photo of view).

Unfortunately, coding this sort of thing is rarely simple, there are lots of basic decisions to make up front; do I enter the data as raw HTML , or do I format it as I display it; do I store the pages in the database or the file system… etc

Then there is the problem of how I input the data and add photos in a particular position using just a simple Web browser.

I am still at the thinking phase of this development, and I don’t want to publish the new photos until I have done this work.

This means a delay in seeing the new photos of course, which is a shame as I think they are better than last year’s (I am starting to think more about composition and stop just snapping away at everything I see).

Hopefully, I will get some time to work on this soon and get my photos up for all to see.

CD woe

I found a bug in libcdaudio today.

I noticed some CD info was corrupt for compilation CDs.

The last letter of the track and the first letter of the artist was being chopped off.

An example can be seen here.

I finally traced it to something in libcdaudio that was parsing the track artists and titles incorrectly.

Luckily it proved easy to fix.

I’ll run my modified version for a few days and if it’s fine I’ll mail the maintainer.

The real problem I have is how to update all my incorrectly parsed CDs without physically reloading them all.

I may have to write a little C program that calls libcdaudio for each CD in my cache.

I don’t particularly enjoy writing C. 🙁

Caching is fun!

I have been writing some caching code for the site.

At present, every hit on the CD list results in a hit on the db.

I wrote a generic caching class to keep a cache of db results to look in instead.

I was quite amazed that it all worked the first time I ran it, especially as there were thread synchronisation issues involved.

I will test a bit more before sending live though.

Next step, pagination, one page with 80-odd CDs on it is not the most usable is it. 🙂