Thursday, 27 September 2007

POJOs and annotations

What is a POJO? It is a plain old Java object. I believe the definition allows inheritence, but I would like to think that it discourages use of factories, home interfaces and other such malarky (think EJB2).

But what really disturbes me is that people think that they can take a POJO and annotate it and it is still a POJO. Well that's just not true!

By annotating your POJO you have coupled it tightly to whatever framework supplies the class definitions for the annotations. For instance, EJB3. People rave about being able to use POJOs, but you're still annotating your classes with EJB specific code.

The programming model is similar to POJO, in that you now don't have to worry about that extra EJB rubbish you had to produce in earlier versions (never understood why that was needed in the first place!), but it's still an EJB.

As far as I am aware, please correct me if I am wrong, you can't take that EJB annotated class out of the J2EE environment and use it elsewhere without having to include the classes for the annotations. I believe you will get a "class not found" (or "class def not found") exception if you try to use a class that has been annotated, but you don't have those classes on your class-path.

Which to me makes annotations pretty much useless.

Wednesday, 26 September 2007

Coding Kata

I was recently introduced to Coding Katas. I actually consider myself a practitioner of this but without realising it had a name and I haven't been working on the examples on that website, I'd just been doing some other stuff but using new technologies.

I recently undertook "Kata 14" and pumped out a solution in an evening. Good fun! And the output is actually quite interesting too. While I had a specific reason for doing this, I might actually be tempted to keep it updated and improve it and see if I can get it to produce even better results.

In other news, I'm currently working on a task management system based on OSGi, GWT and an DB4O in my spare time (currently my train journeys to and from work). It is actually coming together very quickly. Programming the front end with an easy API like GWT helps a lot, as does not having to worry about mapping my objects to an RDBMS. It just works. Can't say I'll have it it available any time soon as I haven't bothered to outline any specific requirements for it, I'm just throwing it together to see what the technologies can do and how they can help me.

I may well shelve it and work on a game instead, though I have no idea what!

I'm also quite looking forward to EclipseCon 2008 - if I can get my employer to cough up for it. Not holding my breath though as I suspect it will fall right in the middle of some busy work period. :(

Saturday, 22 September 2007

I don't watch TV

Seriously. I find it intrusive and time consuming. I tend to put aside some time to watch my favourite shows on DVD and of course I'll sit and watch movies on DVD, but that's not what I want to talk about.

There appears to be a growing trend of people publishing podcasts and online videos with regards to technical articles and interviews. While I'm working I haven't got time to watch a video and I can't listen to someone rambling on about something when I'm trying to concentrate on what I'm doing.

I'm sure I'm missing out on a lot of good stuff, but I much prefer text and pictures on a web page. I can scan read and the pictures, if appropriate, will aid my understanding of what I have scan read. If I pick up on something that requires more attention I bookmark it and come back to it later when I can read it in detail. I can quickly access the importance and relevance of a document while I'm working, without it interupting me too much.

Videos and podcasts don't allow for that kind of interaction. They are also not searchable by search engines.

I feel as though the technical community is taking a step backwards from what the internet is supposed to be. For me the internet is a fantastic place to find information in a randomly accessible way. At least consider posting a transcript of your video or podcast somewhere accessible. Thanks!

Wednesday, 19 September 2007

Joel vs GWT?

I don't generally read "Joel on Software", as I read I can't help but associate a self-righteous tone and a fat, patronising, American accent as I read a bunch of fluff that I generally already know. The odd article is spot on though and I have friends who read him religiously... almost.

Somebody over on the GWT Google group pointed out Joel's latest rant. I wasn't sure at first, but I thought he was trying to imply GWT was doomed to be out-done by some "NewSDK" and that people are wasting their time building AJAX applications, but then I re-read it and realised that GWT *is* the "NewSDK" he's referring to, so unless I'm missing some half-baked American irony Joel is a bit behind the times on this one.

Tuesday, 18 September 2007

GWT and OSGi

I decided I would try to build a GWT app and deploy it in my OSGi container using the Http service.

Deploying GWT as a client only app was straight forward enough. I converted my Eclipse project to an OSGi bundle in the usual way and created an Activator which then created a ServiceTracker and Customiser for the HttpService. In my customiser I register the location of the GWT files and it just works. Great!

So I decided to take the next step and deploy a client/server GWT application.

At first I couldn't work out what was going on. My server side class which extended RemoteServiceServlet was being called (I had overridden the service method to make sure) but nothing appeared to be happening and my client was reporting an error on the server. Everything was working fine through hosted mode, of course.

Eventually I discovered it is because in RemoteServiceServlet there is a call to request.getContextPath() which is a Servlet 2.2 method. OSGi only supports the 2.1 specification and the framework I am using simply throws a ServletException when calls to Servlet 2.2 methods are made. So I copied the code of RemoteServiceServlet and created "OSGiRemoteServiceServlet" then replaced the call to request.getContextPath() with the 2.1 equivalent of request.getRequestURI(). This fixed the problem and my GWT app now runs fine through my OSGi container which is fantastic.

Hopefully, I won't run in to any more Servlet Spec 2.1 issues, but if things don't work as expected, especially compared to hosted mode, that'll be the first thing I check!

Friday, 14 September 2007


2-5 years, j2ee will be a thing of the past.

i believe it has failed in achieving it's aims. i'm not sure what those aims were exactly, but i find j2ee hard to use. people have tried to make it easy to use by adding further frameworks on top, e.g. spring/struts. i always believed that servlets and jsps were enough, with a good bit of design to seperate display logic, business logic and database logic. that's the kind of design you should apply in any type of application (e.g. .net, php), not just j2ee.

let's face it, ejbs were always a bit rubbish. ejb3 has tried to become the silver bullet object-relational-mapping solution but i'm just not convinced there's very little modularity about ejbs. your application is tightly coupled to the interfaces they declare and there's no getting away from that. if the implementation of those interfaces are not available your application will not work. ok so an ejb may be used by several applications, but in reality... i've never seen that! further more it isn't as though you can have code dynamically contributing application functionality at runtime with a web app. and don't get me started on the hibernate nightmare!

so step aside j2ee and welcome osgi. i believe it's already starting to happen. some of the big app servers are already moving over to an osgi based architecture; ibm's websphere was already there, of course. my worry is that they'll do it wrong and it's such a simple thing to get right. rather than producing app-servers they should be producing high quality, enterprise capable osgi compliant frameworks. creating a web app as an osgi plugin is already easy since there should be an http-service running in your framework. you can just look it up, register your servlet and away you go. the ibms and weblogics of the world should focus on making it happen fast and reliably. i think you can forget sun on this one though. my impression is they see osgi as a threat and are deliberately trying to avoid it, though before long osgi or something like it will become part of the java specification.

and anyway, back to databases. since this is java we're talking about shouldn't we be doing things with objects and not having to worry about mapping them to a relational schema? which leads me to my next prediction...

5-10 years, rdbms will be a thing of the past.

rdmbs are great for procedural languages, but most modern languages deal with objects. pretty much every modern language deals with objects. what a waste of time mapping objects to a relational schema when you could just be storing your objects directly in to a oodbms. oracle 9i (i think, definately 10) has object support in it, but you still access the database in a relational way. i think the team over at db4o have the right idea and their solution works for all versions of java and .net. great stuff! and it runs in an osgi container. even better.