Friday, September 16, 2005

see all that stuff in there? that's why your robot never worked

Ever have one of the days where you wake up in the morning and say to yourself: "Self, the world doesn't have enough J2EE web frameworks. Let's make one" ?

My framework, which I will probably not even name much less actually build, will have the following features:

  1. A "web page", with it's forms, buttons, etc., is represented by a POJO, or something very POJO-ish.
  2. Form fields on the web page will have their values copied into like-named bean properties on the POJO. Nothing new there, this is basic Struts stuff.
  3. Buttons, links, etc., being clicked by the user will result in the like-named method of the POJO being executed. Again, nothing new here.
  4. There will be no XML config file. Everything the framework needs to know, it gets from the POJO by doing reflection or annotations or something.
  5. All HTML will be generated by the framework by looking at the metadata on the POJO. That's right, there is NO template language.
  6. Note that does not mean that there will be HTML in the code or the annotations; it means that there will be annotations like "@Textarea" that flag that a certain bean property is represented by a text area.
  7. Annotations are optional, you can use this framework with older versions of Java by conforming to a naming convention for your bean properties and methods.
  8. In other words, all you write is a bunch of plain old classes, that follow some set of naming conventions and annotations, and you produce a working web app.
  9. Maybe the objects don't even have to be written in Java; maybe they are written in a language that does not need to be compiled, to facilitate on the fly hacking.
  10. The HTML produced by the framework will be very basic and is intended to be styled completely with CSS. If you don't think CSS is powerful enough to avoid the need to customize the HTML itself, then you haven't kept up with CSS.
  11. This is a pure web framework; it will not muddy itself by trying to deal with persistence, transactions, etc. Since the page objects are just POJO's, there should be no reason why you can't use them with EJB or Hibernate or something.
How's that for a manifesto?


Uh... have you looked at Ruby on Rails?

I've been learning it over the last month or so. I don't know J2EE, so I really can't say how it compares, but I can say for sure that there are no XML config files, and it is also possible to style the HTML completely with CSS.
I looked at Rails (basically read the tutorials) and it was an inspiration but as far as I see it stops short of what I describe in a couple of area.

One, there may not be any XML but there are certainly config files. Maybe auto-generated but running the "rails" command to start a new project, but you still will have to keep them around. My bullet points say no config files, and I mean it.

Two, Rails still involves the use of HTML templates, just like every other framework. These look uncomfortably like HTML with bits of Ruby sprinkled in, the same way (old skool) ASP is HTML with bits of VBScript sprinkled in. I call for eliminating templates.

Also, Rails goes *further* than what I proposed by also involving itself with databases and persistence. Like I said, I am designing a pure web framework.