Java 1.5 gets attributes

Something that is new in 1.5, and could potentially be very cool is its support for metadata, which (based on a brief scan) looks a lot like .Net attributes, and possibly even more powerful. The java site has this to say:

Metadata

This language feature lets you avoid writing boilerplate code under many circumstances by enabling tools to generate it from annotations in the source code. This leads to a “declarative” programming style where the programmer says what should be done and tools emit the code to do it. Also it eliminates the need for maintaining “side files” that must be kept up to date with changes in source files. Instead the information can be maintained in the source file.
Refer to JSR 175.

Annotations are also used to implement the ‘override’ functionality of .Net, as this snippet from the JSR states:

This annotation type allows the programmer to declare his belief that a method
declaration overrides a superclass method:

@Overrides public boolean equals(Foo that) { … }

The compiler checks whether method actually overrides a superclass method,
and reports an error if it does not, nipping the problem in the bud.

NIO and Servlets

Interesting article from IBM about how you might implement a servlet container using non-blocking IO, by essentially layering a non-blocking demultiplexer on top of the standard servlet input/output stream stuff.

Pleasingly the article vindicates my position during a recent pub conversation with Jon where I asserted that it should be possible to use NIO to write a better servlet container, but due to alcoholic impairment I was unable to articulate precisely how.

Great minds and photoblogs

Looks like Alan and I have had the same idea at roughly the same time.

I’ve been wanting to try photoblogging for a while, and more generally, post about stuff that is decidedly not work related. Rather than dilute this one with non-techie stuff I think I’m going to start a second one that I can muck about with a bit more.

My leanings to date are to stick with MoveableType and probably use some or all of the following plugins:

Been having trouble getting ImageMagick set up on my hosted server, but have managed to work around that so far by using it locally under cygwin and processing images manually. ImageMagick is highly scriptable (including Ruby!) so it should be pretty easy to build an automated image publishing workflow even if I can’t get it working on my server.

Defect Driven Development

Credit for the title of this post goes to a remark by JB Rainsberger in the extremeprogramming yahoo group.

The pertinent line was something like, “I pretend that my program starts as an infinite collection of defects”.

I like this concept because it discourages the creation of separate story queues and bug queues, and encourages driving out the design through the addition of failing tests.

Each test added will constrain the defect-space of the program, until all the requirements have been satisfied by tests and all the tests are passing. At which point the defect-space and functionality-space of the application are separate and distinct. There’s probably some clever comment about set theory and venn diagrams I could make here, but I’m not smart enough to think of one.

Virtual vs Final

Posted to the Artima forum following this interview with Anders Hejlsberg about the ‘virtual’ keyword in C# compared to Java’s ‘final’

By making methods final by default, and having to explicitly state which ones can be overridden, you are forcing developers to try and anticipate all possible future uses of the code they write.

It encourages a sort of protectionist attitude that says ‘You’re not smart enough to understand how my code works, so I’m going to only let you override the bits that I choose to allow’.

I write code to be useful, and if someone sees a use for it that I didn’t anticipate, by overriding a method, then thats a good thing and should be lauded, not repressed.