Struts Mentor

The first prototype of the Struts Mentor site is up. There’s 400+ hours left on the Oklahoma contract, but once we wrap that up, I’d like to focus on training. The twist is that the Struts Mentor training materials will be open source too: “Open source courseware for an open source framework.” Hopefully, other people will teach from the materials too, so that the courseware will benefit more people that anyone of us could reach on our own.

Over at Struts University, I dabbled a bit with a MailReader Training Course for Action 1, but I think the better place to start would be Action 2 (WebWork) or Shale.

To ORM or to Map?

The Java community (incuding Sun itself) have been working with SQL generators for several years now. Results have been mixed. The current wisdom is that SQL generation is a good thing when you

(1) Have complete control over your database implementation

(2) Do not have a Database Adminisrator or SQL Guru on the team

(3) Need to model the problem domain outside the database as an object graph.

When one or more of these conditions are not meant, many developers are turning to SQL mapping tools.

A mapping tool lets you assign a logical name to a SQL query. The parameters the query needs can be taken from a single object passed at runtime, or as a primitive number or string. Likewise, the result of a query is passed back in a disconnected object.

A mapping tool is less like a “persistence layer” and more like a lightweight wrapper to simplify using ADO.NET. You still have full control of the SQL, but you can test and manage the SQL code outside of the application.

The best time to use a mapping tool is when:

(1) You do not have complete control over the database implementation, or want to continue to access a legacy database as it is being refactored.

(2) You have database administrators or SQL gurus on the team.

(3) The database is being used to model the problem domain, and the application’s primary role is help the client use the database model.

For a time, there was a feeling in the Java community that developers shouldn’t need to worry about SQL. After some bad experiences, this feeling is changing. More developers now recognize that SQL is here to stay. We’ve been using SQL and the Relational Model virtually unchanged for 40 years now — which is more than we can say for any other development platform. :) The question for many teams is not how we can “hide” SQL, but how we can ~manage~ SQL.

For managing SQL, the iBATIS Database Layer for Java has become quite popular. There is also a .NET version called Nausicaa. It’s code-complete and is now working on porting the iBATIS documentation.

Of course, some projects have a rich business object layer that models the problem domain independently of the database. In other projects, the SQL is not complex and is mainly grunt work. Some projects need to migrate to different database systems, for example, from Access to SQL Server. In these cases, a solid object-to-relational “persistence layer” can be a very good thing. Many of these have been written for Java, most based in whole or in part on Scott Ambler’s famous white papers.

Most Java implementations require developers to specify a good deal of metadata. There is a new implementation for .NET that cuts the redtape to a minimum and faithfully follows Ambler’s architecture, called Gentle.NET. I took Gentle for a test drive the other day, and it works very, very well.

But, at the end of the day, most of my projects work better with a mapping approach, like that taken by iBATIS and Nausicaa. But, then, I actually enjoy writing SQL :)

XXE and Subversion - My New Best Friends

I’m dabbling with the idea of using DocBook for technical writing projects. Word doesn’t agree with me, and I really want something I can check-in and diff. I finally took the time to visit XMLMind and take XXE for a spin (http://www.xmlmind.com/xmleditor/). I was blow away. From the tutorial, it looks like the standard version will do what I need, but I’ll probably get the professional version, just to show my appreciation. It’s that good. :)

Most everything I do ends up in an open CVS these days. But there are exceptions. Subversion is the new darling of the Apache Group, so I thought I’d take it for a spin too. The Subversion book seems quite good, but I just wanted to get a Subersion up and running on a local machine, so I could start playing with it. Between the book and a quick-start in the FAQ, I was able to get Subversion up and running in the afternoon (so I could check in my XXE-made XML that evening).

Here’s quick step-by-step of what I did from download to first commit.

0. Download and install Subversion - http://subversion.tigris.org/

Accept the defaults. The Windows installer with setup the path and so forth, and be ready to go. The directory conventions follow Unix, but all instructions are for Windows.

1. Create a repository

> mkdir /var
> mkkir /var/svn
> svnadmin create /var/svn/cookbook

2. Setup permissions

edit /var/svn/cookbook/conf/svnserve.conf

[general]
anon-access = write

3. Setup email notifications [TODO]

install perl for windows, install modified scriptenable template

4. Launch svn server

> svnserver -d -r /var/svn

5. Import content

> svn import -m “Initial import” /projects/ORA/svn/readme.txt svn://localhost/cookbook/readme.txt

6. Checkout content

[delete working directory]
> svn checkout svn://localhost/cookbook
Checked out revision 1

7. Commit changes

> svn commit -m “Routine changes” svn://localhost/cookbook/readme.txt
Committed revision 2

Try the Tortoise client to get off the command line.

See also http://www.onlamp.com/pub/a/onlamp/2002/10/31/subversion.htm

NYC Java OpenSource Conference

It’s a small world after all. Vic Cekvenich contacted me earlier in the year about speaking at a conference this spring. It finally came together Saturday April 3 in Manhattan. It was fun to meet some of my favorite code warriors, like Clinton Begin and Matt Raible. Not to mention my Struts partner-in-crime, Steve Reaburn. It was even more fun to learn that Jason Carreira of WebWorks fame lives only a few miles from me. Sounds like an excuse to heft a few Guiness some time. :)

Some of the earlier presentations ran long, and mine was right before lunch, so I had to rush a bit to get everyone out on time. Pity really, since it was bleeding edge stuff. I’m working on an example application for Commons Chain of Responsibility package, using the venerable Struts MailReader. The key idea is that you can reduce the Action to a “state adaptor”. The Action “simply” passes the state of the (web) application to the Command, and the Command (or Chain of Commands) does all the dirty work. In this way, the Command is a pure business object and can be used in any environment. Say, a testing environment or a desktop environment.

Given the abbreviated presentation, I’m not sure everyone got it. But, I’m sure I was at least able to put Commons Chain on everyone’s radar. Aside from the Struts example, I’d also like to do a WebWorks example too, along with a generic Servlet and Portlet example.

The one non open-source presentation was about Macromedia’s new Flex platform. Flex is a flashy front end that you can program via XML, using tools that you already have (like IntelliJ). For now, the cost puts it out of reach of many projects ($12,000 for two cpus). Still, Flex is going to be the technology to watch as the price drops. Someday, I’m sure, all web sites will look like Flex.

One very nice thing is that Flex is a presentation-only platform. If you already using a MVC architecture, say in a Struts application, you can just plug it in where you are using JSP or Velocity templates today.

One area where we all should start working together today is Validation. Validation runs up and down an application, as a system layer. The Commons Validator is a nice start, but there’s still much work to be done.

No Fooling

My Struts Quiz made the java.sun.com home page on April 1st, bouncing the book back into the 500s (or better) again – still in the Java top ten! We’re about to make our fourth printing of SIA, and there’s a Japanese translation in the works. The errata has trailed off, so maybe the 4th time will be the charm =:0)

The Retract Bid story went in easily. Did the Right Thing and set it up to mark the records, as if they were deleted. This made it easy to print a log of the retracted bids under the nominal bids. This also keeps all the detail so we can even undo it. (In case of data-entry error.) If I can get through paging today, that will sum up the necessary changes for the public part of the auction. That leaves improvements for fulfillment and user administration for next week. I’m eager to get through this so I can back to work on the Oklahoma project.

Finally go the laser printer fixed. It’s been pulling multiple pages when it heats up for some tie. Turns out there’s a lawsuit. Deadline for filing is the 8th, and my paperwork is even in the mail!