David Geary's Weblog : WeblogWelcome to David Geary's Blog   

All | General | Java | Ruby on Rails | No Fluff Just Stuff | Shale | Apache Tiles | JavaServer Faces | Non-technical Reading | Humor

Friday February 03, 2006

Maven Rocks

Since I'm lucky enough to reside in both the Rails and JSF worlds simultaneously, I often get asked what we can do in Java to reap some of the benefits of Rails. I had no idea until recently, but Maven—especially Maven 2—is a heck of a good start.

Maven has been on my list of things to learn for awhile, but it's never made it to the top until I experienced a Maven confluence of sorts, when Shale added Maven support and a client handed me an application built with Maven.

Maven, like Rails, can generate an application for you. Maven 2 has something called archetypes that you can use to generate an application. But the archetype mechanism, much like Rails' code generators, is pluggable. This is really cool; for example, MyFaces has an archetype that will generate a starter MyFaces application. Maven even comes with a plugin that generates IDEA project files. (I'm fresh into IDEA these days)

Now comes the good part. The application that Maven generates for you is setup to work with an impressive array of built-in goals (Maven goals == Ant tasks). So you just do "mvn install", for instance, and watch Maven go through it's paces creating and deploying your newly minted application. You can go pretty far on the built-in goals, but of course, you can also, like, write your own.

One of the barriers to entry for a new technology for me is how easily I can get an app up and running—the so-called 10 minute test. Because Maven can generate a starter application from an archetype created by a third party, I can have a MyFaces application, for example, running in minutes even if I know nothing about MyFaces. Then I can examine the files, learn how it hangs together and extend the app for my own purposes. That saves me an enormous amount of time. (I was hoping Seam would have an archetype, but my searches have failed. Anyone know if there's one available?)

All of this is possible because Maven essentially inverts the structure that Ant users are familiar with. Instead of you implementing build logic with Ant targets, other people implement Maven tasks that you use in your Maven-generated application. That shifts the responsibility of implementing build logic from you to a provider (Maven built-in, MyFaces, whatever) much the same as EJB has forever freed us from the banalities of implementing distributed applications.

One more thing and then I'll send you on your way to someone else's blog. If you're like me, you've got numerous Ant-powered projects and you are committing the cardinal sin of software development: you are repeating yourself. You've got build files all over the place, that essentially do the same thing, but a little differently, for lots of applications and you've got to maintain those build files. You've also got JAR files scattered across your hard disk like goose bumps on the neck of a new Rails convert. Those JAR files have to be maintained too, not to mention the space they eat up.

Instead of bleeding all of this build knowledge all over your drive, Maven encapsulates it in goals that are publicly available and a repository. Like its namesake, Maven accumulates knowledge that you can take advantage of. The Maven repository stores one copy of each of your required JARs at a cool 28 degrees F on your hard drive to ensure maximum freshness. No more JAR files all over the place; Maven gets them from the repository and automatically downloads required dependencies for you. What more could you want?

And I learned not to say much of nothin'
So I figure you already know
But in case you don't, or maybe forgot
I'll lay it out real nice and slow

from Decoration Day by Drive-By Truckers*

* New album due in April, 2006

[Java] ( February 03, 2006 05:35 PM ) Permalink | Comments [8]

Wednesday January 18, 2006

Shale Simplifies Remoting

On my way home from JavaPolis, I was thinking about the Ajax demo I gave during my Shale presentation. In that demo, I use Ajax with Shale remoting to populate city and state fields in response to a selection from a zip code menu. Whooo hooo!

I had given a variant of that demo quite a few times at NFJS but I was always uncomfortable showing the corresponding code, because it felt overly-complicated. To use Shale remoting, you had to:

In the beginning, it seemed to make sense to use Chain for remoting; after all, Shale uses Chain under the covers to process requests, and using Chain for remoting seemed like a natural extension of that implementation. Craig and I had talked about replacing Chain with Dialogs, so you could remotely invoke a dialog, but as I thought about it on my flight home, using dialogs seemed like it would make remote calls even more complicated. Instead of the steps listed above, I wanted:

So soon after I got home, I filed an enhancement request to simplify Shale remoting. I wanted to eliminate the Chain dependency altogether so that we could remotely invoke pojo methods on the server, sort of a remote value binding. Craig responded to that RFE with a revamped remoting package that was almost exactly what I'd envisioned. I was so excited that I modified my JavaPolis Ajax demo and added it to the use-cases application that comes with Shale. So, at last, Shale has an Ajax demo. The crux of the demo is captured in this JavaScript code:

function zipChanged(zip) {
   sendRequest("http://localhost:8080/struts-shale-usecases/" +
               "dynamic/remoting$business/cityAndStateForZip.faces" +
               "?zip=" + escape(zip), 

The preceeding code uses an XMLHttpRequest object to invoke a URL on the server. Shale intercepts the URL and turns it into a cityAndStateForZip method call on a managed bean named remoting$business (the $ is a Shale convention that has no bearing here).

The remoting$business.cityAndStateForZip method calls FacesContext.responseComplete, which effectively halts the JSF lifecycle, and writes an XML response to the response stream. On the client, I have some JavaScript to parse that XML response and store the corresponding city and state values in the appropriate HTML elements in the page.

Teo torriatte konomama iko
Aisuruhito yo
Shizukana yoi ni
Hikario tomoshi
Itoshiki oshieo idaki

Teo Torriatte
from A Day at The Races by Queen

[Shale] ( January 18, 2006 12:06 PM ) Permalink |

Tuesday December 27, 2005

It Never Occurred to Us...

From an article titled Out of the Fyer, Into the Lights in the Dining In section of the New York Times, Wednesday, Dec. 23rd:

We all learned in Hebrew school that the reason we eat latkes on Hanukkah was because they were cooked in oil, to remind us of the miracle of the oil that lasted eight days instead of one," Ms. Goldman said. "It never occurred to us that you could eat other fried things until some Israelis in our congregation introduced us to sufganiyot (jelly donuts).

Surely this is unthinkable to the average American, who is drowning in a sea of artery-clogging delicacies at every turn. But the underyling theme that such a simple concept never occurred to these folks is staggering. It never occurred to us that you could eat other fried things. You've got to be kidding, right?

Yet, as I sat at my kitchen table munching on sesame chicken for lunch, it suddenly occurred to me that it never occurred to me, while I was helping to define the JSF 1.0 spec, that you could have zero-turnaround time in your framework. Or that you could create rich-client applications with JavaScript using a collection of technologies that would later be labeled Ajax. Or that something as simple as convention over configuration could be such a powerful tool.

I was sitting next to Jason Hunter on an Expert Panel at NFJS and Jason told the crowd that the WAR mechanism was never meant to be used to deploy applications, it was meant as a distribution mechanism. "Why jar everything up into a WAR when the server's just going to unjar it?" Jason asked. "Instead, just work in the webapps directory, or map your context to another directory". At the time I was working on a consulting job, where, guess what, we were deploying a WAR file to the webapps directory for every build.

So perhaps the assertion that it never occurred to these folks to fry something tasty is not so far-fetched after all.

How come all the poets fall into despondency?
And they write it down
for us to read every indignity

I'm a Dog
from A Worm's Life by Crash Test Dummies

[General] ( December 27, 2005 04:20 AM ) Permalink | Comments [0]

Wednesday December 21, 2005

Nerd fest!

I have no idea who Ms. Mama is, but this is great!

I hope you had a good time at the conference, Mr. P!


I don't think I can handle this
A cloudy day in Metropolis
I think I'll talk to my analyst

Jimmy Olsen's Blues
from Pocket Full of Kryptonite by Spin Doctors

[Humor] ( December 21, 2005 02:46 PM ) Permalink | Comments [0]

Monday December 19, 2005

The Rails Café

Like you, I practically live in cafés. Someone once told me there's a psychiatric disorder for people who spend so much time in cafés, but if that's the case then I'm okay with it because a lot of my friends do the same and, as a group, we seem normal enough.

I've been frequenting the Java Café now for more than ten years. I remember when it was a little Mom and Pop shop on Oak Street before it was bought out—some say sold out, but I don't cotton to that particular conspiracy theory—by bigger interests. I will always consider myself fortunate because I found out about the Java Café while it was still under construction and, if anyone asks, I just might mention that I had a very, very small hand in some of the initial planning. Now, of course, the Java Café is a huge international chain where many people spend a great deal of time (and presumably they don't get labeled with psychiatric disorders by those who profess to love them).

The other day a new café opened not far from where I live: the Rails Café. It's been under construction for quite awhile and I've noticed that the place is often filled with workers late into the night. Down at the Java Café there's been a lot of talk about the Rails Café and that, of course, includes its share of wild and outrageous rumors. "Have you heard that they'll be able to serve food almost instantaneously?", one wide-eyed colleague asked me the other day. Obviously the poor guy'd had too much Java that day. I just smiled and replied "Well, you never know...".

A few days ago, I went by the Rails Café and peeked in the window. It was scheduled to open the next day, so I thought I'd see what kind of last minute preparations it had undergone. The first thing I noticed was that the workers must've been very busy as of late. Many window dressings and finishing touches had been applied since the last time I walked by. And in the corner, I saw a telltale sign: an empty container of Ajax. Yes sir indeed, the workers have been busy.

So anyway, today I decided to give the Rails Café a try. Of course, I had many pressing matters to attend to at the Java Café, so I promised myself that I'd make this a short stop. One thing you've got to get used to if you come down to the Rails Café is the color scheme: everything, and I mean everything, from floor tiles to seats and tables to silverware, is all Ruby red. The only exception in view is some composite metal, kind of like aluminum I guess, reportedly made from Helium, Magnesium, Titanium and well, believe it or not, Licorice. It looks kind of odd against the ruby backdrop, but nobody here seems to give it the slightest thought. Come to think of it, I think we once used that composite at the Java Café, but I digress.

The other striking feature of the Rails Café concerns the ordering process. At the Java Café, we adhere to a strict ordering discipline that reduces many types of errors that normally take place behind the scenes in the kitchen. For example, you don't just say "I'll have roast beef with mashed potatoes". First you've got to specify exactly what kind of food you want; in our case that'd be meat and starch (although I'd argue for vegetable here). Then you can proceed to exactly what kind of meat and starch you want and of course, the exact quantities of each. Finally the waiter, usually a fairly serious sort, will reiterate your entire order, exactly as you specified it, to make sure that the kitchen gets it right.

At the Rails Café, ordering is much different. The waitresses are typically young irreverent females loudly thinking—oops, I mean chewing—gum. Not only can you order "roast beef and mashed potatoes", but they have something here called specials. Evidently these are some sort of prepackaged meal where you don't have to specify anything at all: everything's right there in the meal. "But surely, I've got to specify something for these specials, don't I?" I asked the waitress. "Nope", she replied, "just say the meatloaf special and everything will be taken care of". Sounds like a good idea that may eventually catch on, but I don't like green beans, and that's what came with the roast beef special, so I ordered the whole meal and substituted corn. (Later I learned that it's perfectly acceptable to order the special, go in the kitchen, and replace your beans with corn. All by yourself. Imagine!).

Anyway, without further ado, the waitress turned her back to me and I thought she had to sneeze or something before, you know, double checking my order. Even though she was only turned for a second a feeling of dread came over me: what if she doesn't double check my order and the kitchen screws up? I thought. And then she turned back towards me with a steaming plate of roast beef, potatoes and corn and put it on the table. I didn't know what to do. I sat dumbfounded staring at the food. Then I looked up and, I swear, my waitress was nowhere in sight. I must admit, it was nice to get my food that fast, but that sort of thing might make some folks over at the Java Café uneasy.

I looked down at my food again and heard "Sir, what would you like to drink?". I looked up and my waitress was back. Well at least this is the same as the Java Café I thought, where we always order food first and then drinks. But guess what? There was no intermediate waiter casting his vote on whether my drink, when brought out of the cooler, was actually the type of drink I asked for. Out of the cooler and straight onto my table! No waiting! No kidding! I could sure get used to that!

As it turns out, I stayed at the Rails Café for the entire day, and I must admit, a great deal of the evening, and yes, even well on into the night. The more I'm here, the more it reminds me of a café I used to go to in my younger days, where people, affectionately referred to as block heads, spent nearly all of their time—believe it or not—engaged in small talk. Hard to believe, but back then people got a lot done and I sense the same ambiance here. Of course, I've got many commitments at the Java Café, so I'll always give them my business, but from now on, I'm going to spend more time at the Rails Café. Won't you join me?

Lick these
My Ruby lips

from sixteen stone by Bush

[Ruby on Rails] ( December 19, 2005 10:26 AM ) Permalink | Comments [11]

Sunday December 18, 2005

JavaPolis 2005

Forgive me for dropping out of sight for awhile, but I've been so overwhelmed the past few months with JSF consulting/training/speaking work that I haven't had time to finish a single blog entry. Not that I haven't tried—I've got a half-dozen entries that I started but didn't have time to finish. Maybe later for those...

But now I'm sitting in bed in a Hotel in Antwerp, Belgium, with nothing to do other than watch a dubbed episode of Dragnet on French TV. I'm a firm believer that some English TV should never be dubbed in any language and Dragnet certainly fits the bill for me.

Anyway, I'm here to speak at Javapolis—damn, Java has been good to me—which by the way, everyone here pronounces Java-polish, without the 'h', instead of rhyming with Metropolis, as in the Man of Steel's hometown. So, before I drift off to sleep, let me tell you a little about Belgium and Javapolis.

Belgium is really, really cool. If you're into (spoken, as opposed to computer) languages, this is the place for you. The native tongues here are Flemish—which is spoken in the North and to me is an incomprehensible blend of English, German, and French—and French, spoken in the South. I can pick out Flemish words here and there that sound English or French, but that's it, although I did go "eeten en drinken" with some friends last night. Everybody here in Antwerp speaks good English and most people also speak French—Yee Ha! Yesterday I got to speak French with a woman that worked at the Metropolis where Javapolis is held, and yes, Metropolis is also pronounced Metro-polish, without the 'h'. That conversation was a real charge for me because I never have the opportunity to speak French in Colorado.

(If that's not interesting enough, Flemish really isn't a language, but a term for a mixture of Dutch dialects. See this Wikipedia entry for more info)

As for Javapolis, it's a miniature JavaOne with an edge—just my kind of venue. From what I understand, we had nearly 2000 people at the conference, which is a 50% increase in attendance over last year. Of course, I wasn't here last year, but I'm sure the correlation between my presence and an ample attendance increase is purely coincidental.

Today I did my Shale shtick. Before the session started, one of the event personnel commandeered my Mac to change my screen resolution and noticed that my Mac locale was set to French (as is always the case, as some of you know). From then on, he gave me directions entirely in French, so that got my blood pumping before the session. I did my NFJS Shale talk, but I shortened it to 60 minutes and I also added a couple of requisite Ajax demos. I ripped through 32 slides and 5 demos in 60 minutes, so the session was a virtual fire hose of information. Last night I really did go out eeten en drinken with my NFJS buddies: Ben Galbraith, Dion Almaer, Ramnivas Laddad, Ted Neward, and Brian Goetz. We had a great time and ended the evening walking around Antwerp(en) eating pomme frites, but I didn't get back to my hotel until around 1AM and then I couldn't sleep. I finally fell asleep around 4:30AM and got up at 8:30 for an interview at 10:00. That short night's sleep, combined with a good dose of jet lag that still stalks me made me a little loopy all day and I was quite disappointed with what I thought was a pisspoor interview, so I was afraid my brain would short out during the session, but when I got up to speak my adrenaline kicked in and I was fine. (Sorry about that interview, Dion: next time, let's skip the frites the night before!)

The Shale session was a gas. I had a big crowd—I love speaking to big crowds—and they responded really well to my twisted sense of humor so we had a great time. I started the talk by asking everyone if they were having a good time and someone in the back yelled out "YEAH" at full volume. When I speak, I like to keep the crowd engaged, in one fashion or another, as much as I can, so I love rowdy behavior. I like some edge and that primal scream pumped me up as I began the talk. YEAH! All the demos worked without a hitch and by the time it was over I was literally buzzing. After a session like that I'm on cloud 9 for quite some time afterwards. Right now, 6 hours after my session ended, I'm just starting to level out. Hopefully I'll able to get some real sleep tonight.

Like JavaOne, JSF had a commanding presence here, but unlike JavaOne, that presence didn't feel forced. Oracle was here in force touting their ADF components that they've donated to Apache MyFaces, and today we had sessions on JBoss's Seam, which certainly looks very interesting, and another by Roger Kitain (co-spec lead for JSF) on JSF 1.2 features. I sat through both of those sessions, but Roger's session was right before mine and I was pecking away on my laptop most of the time, so I missed nearly all of it. Good to see you again, though, Roger—perhaps one day we can hook up on the ice. And then, of course, there was the Shale session. Lots of JSF with more to come over the next two days.

I also sat through Jason Carriera's session on WebWork, where he announced the impending merger of Struts Classic and WebWork. It seems to me that in the face of JSF's success, the WebWork and Struts Classic folks are getting a little desperate; thus, the merger. The WebWork session was very lightly attended, which made me feel bad for Jason. Anyone that puts his heart and soul into something like that deserves more return on their investment, if you ask me.

All in all, I've had a great time here. Today is Wednesday and I don't leave until Friday morning, so I'm really tempted to take a 2hr train ride to Paris tomorrow, but I'm pretty well wiped out at the moment so maybe I'll leave that for next year if the good folks here decide to invite me back.

You cook so well
All nice and French
You do your brain surgery too, Mamma
With your monkey wrench

Little Miss Can't be Wrong
from Pocket Full of Kryptonite by Spin Doctors by Spin Doctors

[Java] ( December 18, 2005 03:48 PM ) Permalink | Comments [8]

Wednesday September 28, 2005

Tipping Rails

Like most people, you might assume that things typically progress in a linear fashion, but in his excellent book The Tipping Point Malcolm Gladwell describes how a wide range of things—from Hush Puppies to best-selling books—reach a tipping point and go from obscure to widely adopted almost overnight. Hush Puppies, for example, once a fashion statement, were on the brink of extinction with meager sales of 30,000/year worldwide in the early 1990s. Two years later, Hush Puppies sold 1.7 million pairs in a single year. How did that happen? Hush Puppies had passed a tipping point.

I believe that Ruby on Rails is approaching a tipping point. Like any tipping point, Rails has three factors that make me believe it's about to bust wide open:

  1. The Law of the Few
  2. Context
  3. Stickiness

Let's take a look at each of those three factors from a Rails perspective.

The Law of the Few

Tipping points are fueled through adoption by a select few; those few comprise three types of individuals: connectors, mavens, and salesmen. At the forefront of Rails we have David Heinemeier Hansson, the principle developer of Rails. David is a natural salesman, as you can tell if you've ever watched his infectious video where he develops a functional, dabatase-backed blogging application in less than 15 minutes. But David's efforts would've been for naught if he hadn't been able to infect a critical group of connectors and mavens.

Connectors are people who are extraordinarily connected to other people: they are the people who seem to know everybody. Mavens, on the other hand, are people who love to acquire knowledge on all sorts of topics and, perhaps more importantly, love to tell others about what they've learned (in fact, the word maven comes from Yiddish and means someone who accumulates knowledge). Both mavens and connectors are crucial for affecting a tipping point. I don't know about other programming communities, but in the Java world, Rails has been enthusiastically adopted by (at least) the following connectors and mavens:

The preceeding connectors and mavens have all become passionate evangelists for Rails and through their blogs, training courses, and public speaking engagements, have managed to infect thousands of people world-wide with the Rails gospel.


How people behave is strongly influenced by the context of a situation. When seminary students believed they were late to a speaking engagement, 90% of them walked right by a person doubled over in an alleyway groaning and gasping for breath; in fact, some of those students actually stepped over the poor fellow. But when those students were told they had time to spare, more than 60% stopped to help. Whether those students had just finished filling out a questionaire that referenced the parable of the good Samaritan made no difference at all in their behaviour; instead, their behaviour was driven by the context of the situation.

The context in which we currently find ourselves in the Java community, I believe, is a strong factor in tipping Rails. Java caught on like wildfire because it was a simple alternative to overly-complex C++. But that was 10 years ago—today the context is quite different. Java, especially enterprise Java, has grown into a complex behemoth that consists of layer upon layer of complexity. As Jason Hunter asserts in his blog, Java, like C++ 10 years ago, has opened the door to simpler alternatives. And no other alternative in enterprise computing has nearly as much mindshare as Rails.


You can have salesmen, connectors, and mavens, and you can have a context ripe for tipping, but the third element of the perfect storm is stickiness. How well does the message stick? Without stickiness all the rest is irrelevant and there will be no tipping point.

It's hard for me to imagine a stickier framework than Rails. At the outset, I didn't believe in the Rails gospel, but after actually using Rails for a couple hours—thanks, Dave Thomas, May I have another?—I was hooked. I couldn't stop programming with Rails. I would go to bed at 10PM, toss and turn, and around 10:30PM, I'd get up and get on the rails for hours until I was so exhausted I could go to sleep (there, I feel better now). Remember the woman at my NFJS Rails presentation in Salt Lake City? That's stickiness, and Rails has it in spades. Zero-second turnaround time; drop-dead simple and intuitive database access; simple, built-in testing; killer Ajax support; scaffolding; convention over configuration: those are the things that stick when you see them.

What the Heck am I doing?

So, you might wonder: why is someone who was on the JSF Expert Group and co-author of the best-selling book on JSF publicly singing the praises of Rails? Is he nuts? Doesn't he realize that he may be hurting sales of his own book? Does he believe that JSF is junk that will be usurped by Rails? Of course not. I am a Rails convert, because first and foremost, I am a maven. I love to learn, and even more, I love to teach. And I absolutely love to learn new technologies. I love Tiles, but I love SiteMesh too, and I have a hard time understanding why this is such an either/or world. I believe that both JSF and Rails have their place. JSF is better suited to conservative organizations with complex needs and Rails is better suited to folks who are willing to take some risk and whose needs are not as complex. And at the moment, I'm having the time of my life working on the 2nd edition of Core JSF with my good friend Cay Horstmann while I develop a kinship with my newest co-author, Bruce Tate as we work on a Rails book for O'Reilly.

In the end, of course, this blog entry is simply my musing. Will Rails hit a tipping point and become widely adopted in the near future? I am certain of it; in fact, I think the tipping has already begun. But, of course, only time will tell. In the meantime, I continue to have a blast every day trying out new things in Rails and figuring out the best way to show my future readers how to do them too.

But there you go, once again
You missed the point, and then you point your fingers at me
And you say that I said not to believe
I believe

it's all understood
from brushfire fairy tails by Jack Johnson

[Ruby on Rails] ( September 28, 2005 05:21 PM ) Permalink | Comments [13]

Tuesday August 23, 2005

Rails Drops Jaws

Lately I've been doing some long-distance JSF consulting work for the LDS church in Salt Lake City, and Ben Galbraith tells me that he's required to wear a suit and tie to work (ouch!). So when I boarded the plane for the Salt Lake City NFJS symposium, I half expected to see a plane full of elegantly dressed folks all clutching the Book of Mormon. Instead, I sat next to a guy in a Black Sabbath t-shirt and black shorts wearing a pentagram necklace and ring. As soon as I saw my seat-mate, I knew this was going to be an interesting symposium.

The Sheraton was fully booked when Jay Zimmerman made hotel reservations months ago, so we had to slum it across the street at the Crystal Inn. To be fair, it was a pretty nice place, with a free breakfast (a real breakfast with eggs, sausage, etc.) and free wi-fi. But I did miss Sheraton's killer beds, though.

On Friday I had JSF Intro, Felix, and Shale, and the first two talks went well, but the Shale talk was a disaster. Two of my demos, which I'd run through before the presentation, quit working, and it was by far the worst session I've ever given at NFJS. Of course, the SLC crowd are always very polite and patient, and I received high marks on nearly all my Shale session evaluations. Thank you, for those of you that attended, but you were too kind.

After the Shale talk, I was really upset with myself for letting that happen, so I went back to my hotel room and relentlessly rehearsed my Ruby on Rails demos over and over for three hours, until I was satisified that I would do nothing but kick ass in my Rails session the next day.

The next morning, I was running on 4 hours of sleep after going to Ben Galbraith's house the previous evening for milk and cookies, and believe it or not, a little late-night poker. Still, I got up early and went through my demos one more time. With a zero second turnaround time after making code changes, Rails is really responsive, so all five of my demos were live coding examples, which is nearly impossible to do in any session covering Java-based frameworks. I was going to do the audience participation bit, but I decided against it at the last second because there are too many variables out of my control in that case. At a JUG, it's not a big deal if you don't finish on time, but at NFJS, we're on a pretty tight schedule, so I decided to just do that demo myself.

I headed across the street to the Sheraton, plopped down in a big easy chair, and, with 20 mins to spare before my talk, started to run through the five demos one more time. I got halfway through the first demo and added a scaffold method to my controller, which was meant to bring a full-fledged database backed application to life with essentially one line of Ruby code and *splat*, I got an exception: "Method scaffold unkown". What the heck? (Note the use of the word heck: I was in SLC, after all). I looked at the controller and the method and they looked okay to me. "Must've misspelled it or something", I thought, so I deleted the line and tried again. Same thing. Ugh.

I looked at my watch, and now I had about 8 minutes until showtime. I tried to be calm, but my heart was pounding like a sledge hammer. I deleted the whole darn thing and tried again. Same error! Four minutes to go. Damn, damn, damn. Unfortunately, I'd based three of the other four demos on the initial demo; if that scaffolding didn't work, I was royally screwed. But by now I was out of time, so I had to go up to the podium and hope for the best.

I walked into the room, which was the big ballroom at the Sheraton, and I was amazed: the room was packed. We'd had an Expert Panel the previous day, and as usual these days, the talk centered around Rails, Ruby, and how-can-you-do-that-stuff-in-Java, and we must've spent at least half of the Expert Panel on that topic. So I expected a big crowd the next morning, but not that big!

I don't know if it showed, but I was really nervous at the start of the talk. I worked my way through about 10 slides and came to the first demo. I got to the point where I type in the scaffold line and I thought "Please, God, let this thing work". I refreshed the browser and everything worked like a charm. YES! I felt the color come back in my face, my confidence soared, and the rest of the demo went perfectly, as did all four subsequent demos.

My third demo put Rails' Active Record through it's paces. I made half a dozen live code changes, adding columns to tables, changing the schema, doing a 1 to many relationship, etc., and after each code change, I refreshed the browser. Five or six live code changes in rapid-fire succession followed by browser refreshes that accurately reflected the database changes. Near the end of that demo, I looked into the audience and saw something that I'd never seen at a NFJS symposium: a woman sitting at a table near the front of the room was looking at me with her mouth wide open and the most incredulous look on her face. It was almost like I could read her mind: "This can't be real!", she must've been thinking. I pointed at her and said "That's pretty amazing, huh?" She nodded a reply, but the look of astonishment never left her face.

But that was just the beginning. I went on to demo integrated unit testing, again making a half dozen real-time changes and refreshing the browser to illustrate the results. Then came... the Ajax demo. With minimal changes to a single view, I rewired the application to show a contact on the same page that lists all contacts in an address book. I changed a link_to to a link_to_remote and specified the DIV to update and BAM! there you go. Then I added the Yellow Fade technique to highlight the addition of the contact, refreshed the browser and BAM!, there it was. I looked out over the crowd and people were just sitting, dumbfounded, staring at the screen. "Any questions, or comments on that?" I asked. Nobody moved and nobody replied; everybody still had that stunned look on their face as they stared at the screen. I thought to myself "Now you know how I felt when I was served my first meal at the Rails Café".

And if you hold on tight
To what you think is your thing
You may find you're missing all the rest

The Best of What's Around
from Under the Table and Dreaming by The Dave Matthews Band

[Ruby on Rails] ( August 23, 2005 12:03 AM ) Permalink | Comments [3]

Wednesday August 10, 2005

Top Ten Reasons to Prefer JSF over Struts

I've got a client who's trying to decide whether to use Struts or JSF. As you might expect, I'm often asked, especially at NFJS symposiums, what the differences are between the two frameworks. And, of course, my client's not alone; quite a few folks are trying to decide which framework to select.

In general, my advice is to prefer JSF for new projects. There are sometimes compelling business reasons to stay on the Struts path for existing projects and those situations usually call for some close analysis, but let's face it: JSF is much better than Struts.

So, without further ado, here's my top-10 list of reasons to prefer JSF to Struts...

Top Ten Reasons to Prefer JSF to Struts

  1. Components
  2. Render Kits
  3. Renderers
  4. Value Binding Expressions
  5. Event Model
  6. Extensibility
  7. Managed Beans (Dependency Injection)
  8. POJO Action Methods
  9. JSF is the standard Java-based web app framework
  10. There's only one Struts

#10: There's only one Struts

Struts is an open-source product, whereas JSF is a specification. That's a subtle distinction, which is often lost on JSF newcomers, but it's significant because we can have numerous JSF implementations. As young as JSF is, we already have two excellent JSF implementations to choose from: the Reference Implementation from Sun and MyFaces, from Apache. On the other hand, there's only one Struts.

#9: JSF is the standard

JEE 5.0 containers must provide an implementation of JSF, which means that JSF will soon be ubiquitous. That might not matter to you, but it matters to tool vendors. With approximately 50 Java-based web app frameworks, tool vendors have been reluctant to support a particular framework, but a standard is something tool vendors can, and have, rally(ied) behind. But it's not just vendors: open source projects are rallying around JSF with such dizzying speed that they're stepping over one another to implement the same features. For example, I hadn't even heard of Facelets until we were done implementing essentially the same functionality with Shale's Tapestry-like views. (I believe that redundancy is a good thing and will serve us well in the long run)

#8: POJO Action Methods

Struts actions are tied to the Struts API, but JSF action methods can be implemented in Plain Old Java Objects. That means you don't have to implement an additional layer of actions that mediate between your forms and your model objects. btw, notice the careful wording of this item: there are no action objects in JSF because actions are typically implemented in model objects. But also note the careful wording of that last sentence: you can certainly create separate action objects if you want with JSF. Also with Struts, you have a form bean and an action bean. The form bean contains data and the action bean contains logic. OO purists want to put them together, but you can't with Struts. In JSF, you can spread out your data and logic, or put them in one object. The choice is yours.

#7: Managed Beans

Like Spring, JSF uses dependency injection (or inversion of control, if you will), for instantiating and initializing beans. It's true that Struts creates action beans and form beans for you, but JSF generalizes that concept and adds the ability to initialize managed beans—of any type—created by the framework.

#6: Extensibility

This is huge. JSF has 6 objects that implement much of the framework's capabilities and you can easily replace those objects by decorating the default implementations. That makes it ridiculously easy, for example, to add your own custom variables to the JSF expression language. It also makes it easy, for example, to plug in your own view handlers, perhaps a view handler that implements Tapestry-like views so you can truly separate components and HTML. In fact, Shale, does both of those things. As if that weren't enough, JSF gives you numerous hooks into the JSF lifecycle to inject your own voodoo. Shale gives you even more.

#5: Event Model

JSF has an event model that lets you react to value changes, actions, and phase changes in the JSF lifecycle. In JSF 1.1, those events are handled entirely on the server, a sore point to be sure, but JSF 2.0 plans on supporting client-side events as well. Stay tuned.

#4: Value Bindings

With Struts, you are responsible for ferrying data from your forms to your model objects. You implement an action with an execute method that takes a form bean as an argument. Then you manually pull data out of that form bean and push it to your model. For every form in your application. Ugh. With JSF, you do this: #{model.property}. That's all. JSF takes care of the rest.

#3: Renderers

Have you ever looked at the source code for Struts tags? They generate HTML directly. JSF component tags, OTOH, don't generate anything; instead, they refer to a component-renderer pair on the server. The component maintains state whereas the renderer is in charge of rendering a view. The point here is that renderers are pluggable: you can replace the default renderers with your own implementations; for example, in my Felix talk at NFJS, I illustrate how to implement a custom label renderer that adds asteriks to labels that represent required fields. You plug in that renderer, and JSF will automatically use it throughout your application. Sweet.

#2: Render Kits

I had a Struts consulting job a few years ago where we had to support both a browser-based interface and radio frequency devices, and it was painful. That task would've been greatly simplified with JSF because you can create your own render kit—a collection of renderers for a particular display technology—and plug it into JSF.

#1: Components

Components are the number one differentiator between Struts and JSF. Like Swing, JSF provides a rich infrastructure for developing components in addition to a standard set of components. That infrastructure makes it relatively easy to create your own components and share them with others. Already, we're seeing custom components popping up all over the place, for example with Oracle's ADF and MyFaces, both of which provide a rich set of components such as JavaScript-powered calendars, trees, etc. Of course, components are only half the story; typically, components delegate rendering to a separate renderer, which provides substantial benefits (see item #3 above). But, as with most things in JSF, you are not forced to adhere to the party line. If you want, you can implement components that render themselves, although if you do so, you will loose the ability to plug a different renderer into your component.

Your liver pays dearly now
For youthful magic moments
But rock on completely with some brand new components

rock'n'roll lifestyle
from motorcade of generosity by Cake

[JavaServer Faces] ( August 10, 2005 10:15 PM ) Permalink | Comments [23]

Good Cheer

From Tuesday's New York Times:


A man who left an accident scene was found with the help of some cheerleaders who witnessed the crash and turned his license plate number into a cheer, the police said... "I was going to not remember it because there was too much going on", the coach, Patricia Clark, said Monday... "So, when I ran down the street and got the plate number, I yelled to the girls: 'Remember this!'".

I would've loved to have been there when the police asked the girls for the number. "Okay, girls, altogether now..."

I didn't go to boarding schools
Preppie girls never looked at me
Why should they?
I ain't nobody
Got nothin' in my pocket

Beverly Hills
from Make Believe by Weezer

[Humor] ( August 10, 2005 09:35 PM ) Permalink | Comments [0]

Sunday August 07, 2005

Ruby on Rails Koolaid, Redux

Excuse me for a moment while I eat crow with some humble pie for dessert...

In February, after reading Curt Hibbs' Rolling with Ruby on Rails, I posted a blog entry titled Ruby on Rails Koolaid. That blog entry was based solely on Curt's article: I took issue with his assertion that development with Rails was at least 10 times faster than with any Java framework.

I took a fair bit of abuse for that post and it seems that even 6 months later, some folks are still upset with me. I must say though, that Curt has been most gracious even though I publicly disputed his claims.

In retrospect, my post was stupid and irresponsible. To publicly disparage claims about a framework I knew nothing about was wrong, not to mention just plain dumb, and to those I offended, I offer my sincere apologies.

So, with that out of the way, was Curt right? Is Rails development at least 10x as fast as your favorite Java web application framework? In a word: maybe. I would definitely agree with 5-10x as fast, but I'm not sure about numbers over 10. Note: my observations are based on about 1 month of Rails experience coupled with what I've read.

Why is development with Rails so much faster than with JSF, Tapestry, Struts, or whatever? The single biggest reason is zero turnaround time. You make changes to your application, refresh the browser, and voila, instantaneous feedback. For some, this might not be as appealing as it is for me. Coming from a SmallTalk background, I like to make tiny little changes quickly in succession. Some folks, like my friend Rob, who I worked with on my Cleveland job, like to write a ton of code before redeploying the app in the servlet container. In fact, I took quite a ribbing from Rob because I wasn't man enough to write large chunks of code at a time.

One thing that surprised me about Rails, once I started using it, was how robust it is. There are some very cool things in Rails: Active Record (Rails' ORM and the single biggest component of Rails) makes it drop-dead simple to write CRUD applications and from what I can tell, is robust enough to easily work with legacy databases; scaffolding gives you canned views and controllers, and although you will indeed replace nearly all of the generated scaffolding, it nonetheless provides a significant productivity boost; partial views are sort of Tiles-lite—you get ~70% of the functionality in Tiles (and SiteMesh, for that matter)—and partials are very simple to use (I've found that 70% to go a long way); convention over configuration lets you adhere to simple naming conventions instead of specifying tedious details in configuration files; 3 environments, one each for development, testing, and production, make each of those phases a little easier; testing baked into the framework makes it easy to implement tests, which means you're much more likely to actually write tests; and finally, Ajax support is absolutely killer in Rails.

Another thing that I didn't realize early on was how much Ruby shines through the Rails. With Ruby, you can, at runtime, add methods to classes, and Rails takes great advantage of this feature by stocking your models with methods that represent what's in database tables. That alone makes Rails very intuitive to use. And as I've said before, once you've been loosed from the confines of static type checking, you may never want to go back.

But of course, Rails is not perfect. For example, Rails suprisingly provides no built-in support for i18n or client-side validation. Yes, you can wrestle with get_text() and use that in conjunction with Rails to localize text, but who wants to endure that pain, not to mention, you've still got other i18n issues, such as unicode, localizing dates and times, etc. Frankly, I'm baffled by Rails' lack of support for i18n. Lack of client-side validation's not that big of a deal—especially now that we can easily use Ajax to validate w/o page refreshes—but lack of i18n support, especially in today's flat world, is hard to understand. And it's not like Rails users don't want i18n; I have recently witnessed Rails users drooling over the idea of resource bundles. Imagine.

And then there's the static type checking issue. I know some folks wouldn't dare to develop mission critical apps without stc, and I won't try to convince them otherwise (although the tight corset that Ada straps on wasn't enough to prevent the infamous Ariane 5 Rocket disaster). One thing about letting the wind blow up your skirt is that you've got to write tests. No choice, when things are this free and loose. Luckily Rails makes tests a breeze to write.

As most of you know, I was on the JSF 1.0 Expert Group, so you might be curious to know how I would compare Rails and JSF. We'll leave that to another post, or perhaps set of posts, but for now let me say one thing: JSF was created primarily for tool vendors, whereas Rails was created for developers. A fair percentage of what Rails does (perhaps 80-90%) could be implemented in a killer JSF-based IDE that featured incremental deployment, active record, etc., but we're simply not there yet in the JSF world. (Note: for Tapestry users, you might want to check out Trails. I haven't used it yet, but it looks interesting, although I'd rather do time in Jails )

Everything Zen
Everything Zen
I don't think so

Everything Zen
from sixteen stone by Bush

[Ruby on Rails] ( August 07, 2005 09:47 AM ) Permalink | Comments [10]

Friday August 05, 2005

These are the Days

This week, for the first time in my consulting business, I had to reluctantly turn down some JSF training and consulting work. I'm booked solid until mid-October with more work than I can handle. This client needs to get rolling yesterday, so I had to recommend my good buddy Kito Mann. Kito and I have an agreement [wink]. btw, have you read Kito's book? I highly recommend it as your 2nd JSF book.

The very next day, a good friend of mine called me at home. He had a JSF question and when we got that out of the way, he was wondering if I'd be interested in developing a Swing application in the Fall. Evidently, he's got a client who initially tried to hire a team from somewhere in Eastern Europe, I forget where, for a measly $25/hour/head. Evidently, that left a bad taste in the client's mouth and now he's ready to shell out serious coin for someone to develop a kickass Swing application. With all the fun I'm having here on the server-side, I must admit, I'm tempted to take a short Swing detour for a couple of months. Anyway, that Eastern Europe business reminded me of something else...

At the Phoenix NFJS, for the first time in quite a while, we did not have one single question about outsourcing on our expert panel. With my newfound understanding of outsourcing in today's flat world (more on that later), I tried to steer an unrelated question to outsourcing, but nobody bit. Last year, people were constantly asking about outsourcing, but all of a sudden, nobody cares anymore.

All of this points to one thing, as so eloquently stated by 10,000 maniacs: "these are days you'll remember". These are the good old days. JSF? Rails? Swing? Evidently, there's work aplenty to be had. Of course, everything's cyclical, so in a couple years, we'll probably be in another global recession, but for now, times are good. Enjoy.

Though we share the same memories
And I swear that's her face
Did you bury the woman I love
And fall asleep in her space?

Have you seen my love?
from Everything to Everyone by The Barenaked Ladies

[General] ( August 05, 2005 10:26 AM ) Permalink | Comments [2]

Tuesday August 02, 2005

NFJS Phoenix: Recap

NFJS in Phoenix was a blast. This show was reminiscient of my early days on the tour: I'd been away long enough that I felt like a rookie again. I had a great time, especially at meals, talking to folks about all sorts of things ranging from my experience with RSI to JSF vs. Rails. I also got to meet one of our newest Struts committers—Wendy Smoak—and we talked over lunch about our motivations for working on open-source and how 90 degrees in the evening in Phoenix can be considered cool.

I did three sessions on Friday: JSF Intro, Felix, and Shale. The first two went without a hitch, but I started to run out of gas in the Shale session. I don't expect any sympathy, but standing and talking for 4 1/2 hours non-stop can turn your brain to mush, especially when you've been out of the saddle for awhile. In the end, I was able to pull a couple demos out of the fire at the last moment and everything worked out fine.

On Saturday, the only session I had was Killer Web UIs, which is quickly becoming my favorite session. We explored Tiles and SiteMesh, looked at a couple of cool (to me anyway) demos with some live-coding. Then we compared the two packages and finally discussed how you could use them together.

We had an interesting expert panel after lunch on Saturday. Dave Thomas and Ben Galbraith had some dissenting views about whether the browser was either a vt100-green-screen-technology-that-harkens-back-to-the-stone-age (Dave Thomas) or the coolest-computing-platform-known-to-man (Ben Galbraith). That debate never did get settled, and a couple hours later Dave and Ben were in the hallway still discussing the topic. Jason Hunter, who's a pretty tall guy, was standing between them.

My plane didn't leave until Saturday evening and I was done with my presentations, so after lunch, I had to pick a session to attend. I had to choose from Ajax (Ben Galbraith), Java Metadata (Jason Hunter) or AOP Design Patterns (Ramnivas Laddad). I decided on meta-data, since I'd been to both of the other talks before. But low and behold, practically everyone went to the Ajax session leaving poor Jason with no attendees. In the end, I decided to sit through the Ajax session again because, well it is Ajax after all, and I figured Ben might've added some new wrinkles to the talk. Indeed he did, with a live coding demo that did auto-completion for zip codes. Ben coded the entire thing, including a servlet, before ~100 people. I'll tell you what, that takes some guts, and even though Ben hit a couple of snags with the demo he expertly drew the crowd in to give him a hand debugging. Ben's an awesome speaker with a very laid-back style interlaced with witty one-liners from time to time. Ben makes you comfortable, entertains you, and imparts a good deal of his deep well of information. Rock on, Ben!

Oh, one more thing. Today I printed something on my laserjet. When I pulled it off the printer, I had about 10 screen shots of Alice In Wonderland and Peter Pan at the top of the pile. If you happened to be in my Killer Web UIs presentation, that should put a smile on your face.

Next up: Austin, Texas, the weekend after next. I can't wait!

Moving backwards through time
Never learn, nevermind
That side's yours, this side's mine
Brother you ain't my kind

Black Gold
from Grave Dancer's Union by Soul Asylum

[No Fluff Just Stuff] ( August 02, 2005 09:53 AM ) Permalink | Comments [2]

Thursday July 28, 2005

NFJS Phoenix

After a self-imposed hiatus of nearly two months, I'm about to get back on the NFJS tour. I needed the break to get caught up on Shale and Tiles and explore Rails, but I'm really excited about rejoining the tour. I'm not sure what it says about the rest of my life, but I rarely have as much fun as when I'm presenting one of my passions to a packed room. I also miss my comrades.

I'll be presenting four sessions in Phoenix: JSF Intro, Shale, Felix, and Killer Web UIs. I've revamped the Shale session (which, due to the dynamic nature of Shale is constantly under revision) somewhat lately to include the demos Craig and I gave at JavaOne, hopefully without the drama of the webflow demo.

I missed the Phoenix show last year, so this will be my first time speaking there. I'm anxious to remember what ~115 degrees F feels like, so I think I'll go out during lunch for a few minutes just to soak it in. At least in Phoenix I won't look out of place in my shorts, unlike when we go to Calgary in November, where, yes, I will also be wearing shorts. One thing you learn early on the NFJS tour is that we never go anywhere when the weather's nice. Of course, that's not by accident. We wouldn't want you to be distracted with outdoor matters when you could be comfortably ensconced in a climate-controlled hotel. 8^}

It's interesting how much great press NFJS has gotten over the past couple years. I was tickled to see Matt Morton's Woo Hoo upon learning that the tour is going through Omaha in October. Jay Zimmerman's done a great job of getting the best stable of speakers possible and it really shows. Not to mention the food's great and the entertainment, in the form of expert panels, is a good deal of fun.

There always seem to be some surprises when I go to a NFJS symposium and I'm sure Phoenix won't be any different. I'll let you know how it went when I get back to cool Colorado. See you in Phoenix!

What you gonna do with all that junk?
All that junk
Inside your trunk?

My Humps from Monkey Business
by The Black Eyedpeas

[No Fluff Just Stuff] ( July 28, 2005 08:03 AM ) Permalink | Comments [0]

Black Like Me

One of my favorite audience questions on NFJS expert panels is "what are you guys reading besides technical stuff?". I'm always interested to know what my esteemed colleagues are into besides Java and Ruby, so I always get out my pen and paper and take notes during the replies.

The other day I was leaving a bookstore when a strategically placed paperback caught my eye: Black Like Me. When I was a kid, my uncle was studying to be a psychologist and I remembered he had to read that book for a course, so I snatched it on an impulse buy. Damn those strategically placed paperbacks.

This is a powerful story about a white journalist, who, in the 1950s, took drugs to darken his skin (along with wood stain to cover splotches). Then he went into the southern US states to see what life was like as a black man. Of course, as you can imagine, he did not have a good time.

One of the most interesting aspects of the book is that, as the reader, you know this guy's really white and, of course so does he. He doesn't get treated badly (to put it mildly) because he is black, but simply because he looks black.

This was one of the most intense books I've read in a long time. It reminds me somewhat of Run Baby Run, a book about life in the gangs of New York City in the 1950s; both books pack a lot of raw emotion. If you read either of those books, you'll remember them for a long time.

My timing's never clutch
My ass is way too skinny
My legs are way too thin
I act like such a ninny
I'm all tanked up on gin

from Taking The World
by Donkey by The Rugburns

[Non-technical Reading] ( July 28, 2005 07:47 AM ) Permalink | Comments [6]

« Shale Clay | Weblog