Sam Newman's site, a Consultant at ThoughtWorks

Archive for ‘January, 2004’

This little beauty was spotted in my struts code by a colleague of mine, clearly the result of too little coffee in the morning:

ActionErrors errors = errors = new ActionErrors();

Whilst I say this is a mistake, it actually complies and works. Here I’m assigning an object reference twice. It also works with multiple references:

Long p;
Long l = p = new Long(10);

Which results in both p and l are referencing the same object. It has to be said that I can’t think of a single legitimate reason why you’d want to do this – I blame the lack of coffee this afternoon for me spending even this much time on it… seems to be to bookmarks what “”: is to blogs. provides an online bookmark manager, which provides simple bookmarklets to add and view your bookmarks, and even allows categorization. Your bookmarks are public, and can even be retrieved via RSS making integration into websites fairly easy – those of you using MovableType for example could use the “RSS feed(MT Plugin Directory – RSS Feed)”: plugin to integrate the RSS as a sidebar. My only minor complaint is that unlike is doesn’t seem to have a proper mozilla sidebar setup for it – I might look at creating an XSLT file to style the RSS…

Since I first heard about the notion of tablet based PC’s, I actually first thought about those little screens used in Star Trek TNG – little, A5 devices that fit in your hand. The reality was big, heavy laptops. Now thanks to the “Transmeta Crusoe”: chip, the “oqo”: looks like it might make the tablet PC a reality. Its about the size of a video tape, complete with a 1 Ghz processor, touch screen and keyboard. Oh, and its wireless. With bluetooth. And a 20GB hard drive.

No information on prices as yet, but according to “the inquirer(Transmeta’s goldfish conquer fear of Windows )”: it should be available in a few months, although the oqo website states that fall 2004 as being the expected arrival time.

The “London Java”: website is down at the moment, so my way of a reminder we will be having this months meetup at “Smiths of Smithfield”: on Tuesday 13th.

[Updated 11/01/2004 18:18pm]: Jez has informed me that his provider has gone a bit screwy, so until it gets sorted the offical london-java site can be seen “here”:

[Update 12/01/2004 14:42pm]: There is a “new domain”: for the meeting site. The updates blog link still seems to be broken, so use “the mirror”: for now.

There has been much talk concerning frameworks recently. It seems that almost every opensource project that isn’t an application (and lets be honest, there are very few opensource Java applications) calls itself a framework. This set me to thinking – what happened to calling something an API? When does an API become a framework?

An API is a set of classes and methods (at least in Java parlance), packaged together. They typically provide features for a well defined scope. The Java Standard Edition includes many API’s such as the Collection API or the NIO API. Both are well defined in scope, packaged together and work consistently within themselves. By those terms, frameworks are also APIs. Something like Struts, which we can all agree on is a framework, certainly meets those criteria. So what extra features make Struts a framework?

Probably the key for me is the fact that a framework provides an extendable structure. With Struts for example you extend from the struts-provided base classes and create your own forms and actions. Of late there has been an increasing trend towards so-called ‘light’ frameworks, whose use is almost invisible from the application code’s point of view. Spring and PicoContainer for example use IoC to integrate your own components together, with themselves acting almost invisibly, but they’re still there.

By this reasoning, “Hibernate”: is not a framework (which I don’t think it is), nor is the recently announced “Morena”: product (although it bills itself as an “Image Acquisition Framework”). An implementation of the EJB specification arguably is a framework, as is the Servlet API.

Maybe I’m arguing with myself here, but I’m increasingly getting the impression that people are calling things frameworks as it sounds somehow bigger, more expansive, than just calling it an API. Semantics are important!

I’ve just installed Oscar Hills’ very fine “EZ Subscribe To Comments( November 18, 2003 Archives)”: plugin. It should allow people to subscribe to my various entries and track any comments made. It also provides a web-based interface for management of the subscriptions, so you can easily alter your subscription options. I have to give kudos to Oscar for this – the plugin installed very easily (a single file, no hacking of MT required) and worked first time. My comment forms now look a little ugly with the extra subscription options, but I’ll look to tidy this up in the next few days.
I have managed to overwrite the comment listing though, which will take me a bit of time to sort out. Anyway, feel free to post some test comments on this post and try the subscription options!

[Update: 09/01/2004, 10am]: The comment listing is fixed, and eveything seems ok now.

[Update: 09/01/2004, 11am]: Cleaned the comment form up a bit (its still pig ugly) and made sure the subscription options appear on all comment forms. I also found a bug whereby the blockquotes java script wasn’t being applied on some pages – this is also resolved.

I’ve been writing some caching code recently at work and it occurred to me that I should really look into some caching API’s. Whilst talking to Matt at the last London-Java meetup, the discussion of caching came up. He said he’d looked at “OSCache”:, but decided against using it due to a complaint with its API. Apparently when you get an entry from the cache, if it doesn’t exist it throws an exception. Not fulling believing this to be true, I looked through the API docs (note to the OpenSymphony guys – a simple tutorial would be nice) to find that he is completely correct. This from the cache.getFromCache javadoc:

NeedsRefreshException – Thrown when the object either doesn’t exist, or exists but is stale. When this exception occurs, the CacheEntry corresponding to the supplied key will be locked and other threads requesting this entry will potentially be blocked until the caller repopulates the cache. If the caller choses not to repopulate the cache, they must instead call cancelUpdate(String).

This strikes me has bizare to say the least. First off exceptions are being used to control logic flow, which is a bad thing. Exceptions are for errors in your code – be they user driven, programatic or due to system disruption (please don’t quote the whole NumberFormatException being thrown from the various number parse methods – thats just wrong). Secondly, the obvious (to me) way to design a cache is to allow a pluggable load strategy to the cache, and if the content doesn’t exist the cache itself goes and gets the content. Then if there is a problem loading the content you would get an error thrown, which would of course be an unchecked exception as it will be a programmatic or system environment error. Here the cache is saying “I’m stupid, fix me” and will then perhaps even lock your thread until you do. To be of any use to me I’m going to have to wrap OSCache with my own Cache class to do this for me.

I am struggling to think of a single advantage to this approach. Everywhere you want to use the getFromCache() method you are now forced to wrap it with a try-catch block, and then have to repopulate the cache if it fails. A pluggable content-loading system wouldn’t be hard to write. I have come to the conclusion that I must be missing something. Either the javadoc is wrong or there is a very good reason for getFromCache() to work like this. Can someone put me right?