A simple Java puzzler

By Confusion on Thursday 18 June 2009 14:59 - Comments (17)
Categories: Java, Software engineering, Views: 3.579

        final long YEAR_IN_MS = 1000 * 60 * 60 * 24 * 365;

What will be printed?

Undecipherable product descriptions

By Confusion on Friday 12 June 2009 17:57 - Comments (4)
Categories: Java, Software engineering, Views: 3.057

Today I had to merge a Flex frontend into a Java project. Inside the Flex project, in a 'lib' directory, I found something called 'cairngorm.swc'. Having no experience with development in Flex, I had no clue what this file was. The person responsible was not available at the moment, so I did the only natural thing: Google it. That turned up Adobe's homepage for Cairngorm. The first section, which your eye falls onto when you view the page, is titled 'Overview' and reads:
Cairngorm is the lightweight micro-architecture for Rich Internet Applications built in Flex or AIR. A collaboration of recognized design patterns, Cairngorm exemplifies and encourages best-practices for RIA development advocated by Adobe Consulting, encourages best-practice leverage of the underlying Flex framework, while making it easier for medium to large teams of software engineers deliver medium to large scale, mission-critical Rich Internet Applications.
Ehmmm, yeah, right. Thanks for making me feel stupid. Now I still don't know whether it's a library that I need to include to get the application to run, a standalone Flex viewer/debugger or a collection of examples. By clicking "More information" and reading further, I didn't actually get more information. Only after a PgDn I finally encountered
The Cairngorm microarchitecture is intended as a framework for Enterprise RIA developers.
ah, framework. That's a word I know. So it's a library.

I have this kind of experience more often than I like to: I read an introduction to something and afterwards I still have no idea what the thing is. Is it just me or do you also feel introductions should start with the simple facts and purpose and maybe expand towards an all-encompassing vision of the developers towards the end, rather than starting out that way and leaving you at a plane of abstraction that causes you to miss the actual simplicity of the thing?

Nasty Java HashMap race condition

By Confusion on Tuesday 9 June 2009 22:03 - Comments (13)
Categories: Java, Software engineering, Views: 14.720

After reading this I think I need to check some applications I wrote in the past.

The piece is excellent and details matter, but I'll attempt a summary anyway:
if you use a regular HashMap in a multithreaded environment, it seems the worst that can happen is that you incur some additional cache misses due to race conditions. In a lot of situations that is perfectly acceptable and since wrapping the HashMap with Collections.synchronizedMap() incurs quite a performance penalty (and at that point, that was basically the choice), you are tempted to just leave the HashMap in. Don't. The 'put' operation may trigger a resize and redistribution of the internal data structure of the HashMap that can thoroughly hose it is concurrently accessed during the restructing , to the extent that your program goes into an infinite loop.

These days, there isn't any performance reason to decide in favor of the regular HashMap: the java.util.concurrent.ConcurrentHashMap has excellent performance, even in singlethreaded applications. However, I think I've made the mistake of using a regular HashMap somewhere in the past. However, the application has never malfunctioned (as far as I know), so it may well be that the chances of this bug occurring are so small that they are negligible for all practical purposes. Nevertheless, unless you want to do the math, replacing it by a ConcurrentHashMap is a safe bet.

Will technological innovation ever end?

By Confusion on Sunday 19 April 2009 11:16 - Comments (10)
Categories: Science, Technology, Views: 4.493

Sometimes people seem to make sense, but when you think about it a bit longer, you discover they're just rambling. Take What if our tech is good enough. Based on observations of the sales of Blue-Ray discs, Windows Vista and some other technological advancess, the author concludes that the improvements these technologies offer are too small to attract consumers and consequently there is no more room for innovation. The article ends rather abruptly, but the unspoken implication is that the manufacturers are doomed and that, perhaps, even technology in general has reached an endpoint.

Given the examples (though not all of them), that seems to make sense: at some point something is just so good that you couldn't wish for a better version. If you can't buy a better version of something that will work for twenty years, then the number of products sold will decline fast and the manufacturer has a problem. However, that line of though misses three important points
  • Every product has always reached a mature phase and manufacturers are usually prepared for that to happen. There haven't been major improvements in world receiver radio's for quite some time, but they are still being produced and sold.
  • When the improvement upon the previous model decreases, the time to general adoption grows. This is usually because the price lowers with time and the cost-benefit ratio increases. If the time grows too large, steps may be skipped: 100GB video discs may well be the next big thing, even if blu-ray fails.
  • It is about perceived improvement more than about real improvement. Did I actually need this 32" LCD television? Is it actually that much better than my previous 24" CRT version? I don't think so, yet I bought it.
Therefore, we can conclude that the author was just following a train of thought that he didn't follow far enough. The rather abrupt end indicates that he should have expanded upon his thoughts or should have thrown the article away and written about something else.

Nevertheless, this does leave us with one really interesting question: will there ever be a time when no technological improvements are marketable anymore? When you have your range of Star Trek technology: holosuite, replicator, spaceship, transporter, ..., would there still be a consumer market for new technology? If not, then the question is when the effective end would be reached.

Thoughts on telecommuting

By Confusion on Thursday 16 April 2009 21:00 - Comments (2)
Category: Software engineering, Views: 3.438

The author of an interesting Nerd Handbook had some thoughts on working remote. He hits a few important nails, that should be on the mind of everyone that works remote, has co-workers working remote or supervises people working remote. As often, the Hacker News comments are also worthwhile.