Friday, October 14, 2005

Tapestry Components, Naturally

Mike Henderson and my business partner, Vladimir Drndarski, presented an introduction to Tapestry at the Orange County Java Users Group meeting last night. For this demo, they rewrote the entire www.ocjug.org website (albeit without persistence), and threw in a few extra features to boot. It took them only a matter of hours. One of the main aspects of Tapestry that they showed off was how easy it is to componentize elements of your web pages for reuse. Indeed, developing in terms of components with Tapestry comes so naturally, that you’d practically have to fight it not to.

One of the extra features Mike added was a component to take advantage of Google maps to give you driving directions to the OCJUG meeting. Initially, it just shows a map of the meeting location. If you enter the address of your starting point, it first calls one web service to translate it into lat/long coordinates, and then calls the Google mapping API to generate directions and show the route map. Pretty slick. All of the code for this Tapestry example is available on Mike’s blog (www.behindthesite.com/blog). See also www.t-deli.com for a demonstration of more Tapestry components.

Mike is the evil genius behind Tapestry Palette (tapestrypalette.sourceforge.net) and had a hand in developing Groovistry (Groovy for Tapestry, groovestry.sourceforge.net). Vladimir is President and co-founder of Maxim Software Corp. (www.maximsc.com).

Further reading: There’s a recent Server Side article that compares JavaServer Faces to Tapestry (www.theserverside.com/news/thread.tss?thread_id=35899) . By the way, www.theserverside.com itself is a Tapestry app (www.theserverside.com/news/thread.tss?thread_id=31313).

Friday, September 23, 2005

How to Be a Better Writer Through Blogging

As one of my colleagues is fond of saying “practice doesn’t make perfect, it only makes permanent.” His point is, it doesn’t do you much good if you keep practicing the wrong thing. So, when blogging, pay attention to style as much as substance, even though it’s “only a blog.”
  • Be eager for feedback and treasure any that you get.
  • Give yourself feedback. Simply go back and re-read what you wrote (the next day, and again later). Is what you wrote still as clear now as you thought it was when you wrote it? If not, figure out what you did wrong.
  • Proofread three times before clicking Post: once for content and clarity (how many times have you forgotten that ever so important “not”?), once for rhythm and style (word choice, asking questions or issuing commands instead of just making statements, etc.), and finally one last time for spelling and grammar.
  • Buy a style guide and use it. The Skunk and White you got in college will do, although one made specifically for journalists is a lot better for blogging purposes. (Mine’s the Washington Post version. I got it for $2 in a library liquidation fundraiser. I understand that the Associated Press puts out a good one.)
  • Already have a style guide? Supplement it with a thesaurus – a real Roget-style 2-parter, not one of those silly alphabetical-only compromises (of course, that would certainly be better than nothing).
  • Take advantage of spell check and grammar check tools and don’t be too quick to ignore the suggestions they give you. Tip: a grammar error is often actually a spelling error in disguise because the misspelled word looks like another word (“fell”/“feel,” “fiend”/“friend”, “it’s”/”its”).
Most importantly have fun with your blog. Write about the things that tickle your fancy. Write about your hobbies. Write about the “good” parts of your job. Write about the fun stuff that your friends, colleagues, customers and vendors are up to. The more interesting the topic, the more you’ll enjoy investing your time on it, don’t you think?

Sunday, September 18, 2005

Keeping Crib Notes

  • What’s the regular expression pattern for validating an e-mail address?
  • What are the command-line switches for configuring a Windows Explorer shortcut?
  • What are the 10 best opening hands in Texas Hold’em poker?
I can answer those questions in 10 seconds flat (assuming my laptop is booted up), because I maintain a series of “crib note” documents with just such information. (Currently, I use one Word doc per subject, but I’m thinking of moving it all to a personal wiki). I tend to do everything on the computer, but I know other people who handwrite such notes in an engineering notebook or keep a loose-leaf binder. Pick your poison.

The trick with any of these is figuring out what’s worthy of jotting down, and what’s not. Here are some of my criteria:
  • How hard was it to find the information? How hard will it be to find it again?
  • What’s the likelihood that I’ll need this information again? Is this already the second or third time that I’ve needed it?
  • Is this something I’m trying to become an expert on? Will writing it down help to reinforce the lesson, even if I never need to consult the note again? (But then I’ll have the note as a backup, just in case.)
My notes are currently divided into 18 folders: Self Improvement, Business, Office, Home Improvement, Hardware, Reference, Hobbies, Programming (in general), plus ten specific programming topics like Java and XML.

Saturday, September 10, 2005

Foolish Anagrams

Several years ago, my office mate, Jeff Davidson, and I got on a word-puzzle kick and we discovered an anagram engine on the web (now located at http://wordsmith.org/anagram). April 1st was coming up and we decided it would be fun to replace the nameplate of everyone in the office (about 35 people at the time) with an anagram of their name for the day -- a nice, clean practical joke. It took a little doing, even with help from the engine. For some people we had to try different variations like using Dave instead of David, including their middle initial, and/or adding a title like Mr., and so forth.

JARGON SLICE
Craig L. Jones

SONIC GERM JAR
Mr. Craig Jones

Then, it was just a matter of printing them up on card stock (we used something like 72pt type for the anagram with the original name centered underneath it in 18pt) and swapping them out for the real nameplates the night before.

INVADE MY FJORD, SERF?!?
Mr. Jeffrey Davidson

Of course, we stashed the real nameplates in Walter’s office along with other incriminating evidence. (Walter, you see, was even more famous for wordplay than the two of us.)

LET WAR RISE!
Walter Reis

Well, the joke was on us, because nobody saw them. One of the first people to arrive in the office that morning was a V.P. with a bug up his butt who didn’t think the anagrams were funny. (I’m sure he didn’t even recognize them for what they were.) He promptly tore them all down and put the real nameplates back up, mumbling about the company expecting visitors in the office that day (not true). Eventually, someone rescued the torn-down anagrams out of the trash and Jeff and I saw a number of them taped to people’s monitors by the end of the day. Oh, well.

If you try this yourself, you’re bound to get a better reception than we did. If, in your efforts, you come up with any real gems, please post a comment here. I can always use a good laugh.

Friday, September 09, 2005

I Blog, Therefore I Am Better

I’m not sure if writing a blog has been good for my soul, but I am sure it’s been good for my career. It gets me thinking, and asking questions. It gets me to practice my writing. Best of all, whatever I write about "sticks" better. “See one, do one, teach one.” Isn’t that the slogan that Med students live by?

Thursday, September 08, 2005

"Head First" Book Sometimes Makes My Head Hurt

I’m helping out with a study group for "Head First Design Patterns," which just finished chapter 6. On the whole, it’s a pretty good introduction to software design patterns – way more accessible than the seminal work by the Gang of Four; however, the examples sometimes make my head hurt. I can’t imagine what they’re doing to the heads of the beginners in the group. Coming up with decent examples is the hardest thing to do in expository writing, and I certainly give the authors an E for effort in creativity, but I wish they had been a little less concerned with making their examples "hip" and a little more concerned with making them appropriate.

To wit, the whole pizza store analogy in chapter 4 (to illustrate factory method and abstract factory) is flawed. For one thing, that’s just not the way you’d model a pizza business in any actual software that I can imagine. For another, the differences between a New York pizza factory and a Chicago pizza factory are too subtle/trivial to make for an effective illustration of why you would need to subclass anything (much less use a factory to manage the subclasses). A much better example, as everyone in my group agreed, would have been an application that needs to offer up a consistent set of functionality to users who are accessing it in wildly different ways: one’s in a web browser on a desktop, another is running a cell phone app, another is using a touch-tone phone, and yet another is using a voice-activated headset. All the client code knows is that, for example, it needs to ask a multiple-choice question and obtain the answer. It’s up to an abstract factory to provide the client with a set of classes that can do that, in the context of the selected user-interface, in whatever way is necessary.

To a lesser degree, the Starbucks coffee example at the beginning of the book suffers from the same too-hip-to-be-effective syndrome, although I do think that the remote-control example for the Command pattern in chapter six is dead on.

For any novice who is reading this book without the benefit of a study group, I highly suggest that you find at least one other programmer who is experienced in design patterns to explain why/if/how the examples are lacking.

Wednesday, June 29, 2005

Wax On, Wax Off – Red Bar, Green Bar

TDD has become as automatic for me as breathing. It’s a beautiful thing when you get to start a new project from scratch and can write every line of code test-first. These days, however, I’m working on a legacy app with very little in the way of unit tests, and it feels as if I’m working at 5,000 meters above sea level and struggling for every breath of rarified atmosphere.

So I can only imagine how it seems to the rest of my team, for whom automated unit testing is a new concept. The level of drudgery involved in retrofitting a legacy app with a test harness rivals the chore of waxing Mr. Miyagi’s deck. All I can tell my teammates is that it’s good practice. Soon, writing unit tests becomes a habit, and then, eventually, it becomes pure instinct. Attack from the right? Wax On! Attack from the left? Wax Off! Add a new feature? HTTP-Unit! Change a business rule? JUnit! Keep it up, and that black belt will arrive in no time.

Wednesday, June 22, 2005

Copying SQL Records within the Same Table

I discovered a neat trick for copying a record, or set of records, within the same SQL table today. For example, say you have 20 employees listed in department A, and you want to clone all 20 records to also be listed under department B.

You may or may know that this can be done with a single INSERT INTO statement if you use an embedded SELECT statement in place of the VALUES clause. The hard part is that you cannot just use SELECT * FROM table WHERE ... becuase the * would pick up the key field (e.g. DepartmentID) along with all the rest. So, you have to list every field in the table by hand, except DepartmentID. You would specify the new value as a constant ("B") instead.

The "trick" is that you can probably find a tool that will generate the INSERT and SELECT statements for you. In my case, I'm using the Query Analyzer that comes with Microsoft SQL. In the explorer pane, navigate to the table. First, right-click and choose the option to generate an INSERT script and send it to the clipboard. Paste it into your favorite editor. Next, right-click and choose the option to generate a SELECT script and send it to the clipboard. When you paste this snippet into the editor, do it so that it replaces the VALUES... part of the INSERT statement. Finally, change the field name of the key field in the SELECT statement to the appropriate constant.

The Cobbler's Children Have No Shoes

This blog is back. It's been offline for far too long -- a case of me being so busy working on software projects for other people that I haven't been able to keep my own stuff going. Anywho... Things are starting to settle down, so you can look forward to more of my endearing, but not necessarily enduring, wisdom to come.

Wednesday, February 16, 2005

"Building WebApps with Tapestry" - 2/22/05 7pm

My business partner, Vladimir Drndarski, will be speaking on Tuesday, Feb 22 at 7pm in the city of Orange on the topic of Building WebApps with Tapestry. This will be at a meeting of the Orange County Delphi Users Group, although the topic has nothing to do with Delphi, per se. OCDUG meetings are free and open to the public.
Here is the official meeting announcement:
This month Vladimir Drndarski of Maxim Software Corp. (www.maximsc.com) will show how to build web applications in Java using the Apache Tapestry framework (a JSP alternative). As a recent convert from Delphi to Java, he'll introduce the topic from the ground up focusing on freely available open source projects that'll get you started quickly and for free. To start, Vladimir will show the Eclipse IDE and compare it to Delphi. He'll then discuss several Eclipse plug-ins that are must haves when working in Tapestry. And finally he'll delve into Tapestry itself. If time permits Vladimir will give an overview of the Hibernate persistence layer and give a quick demo of its use in Maxim Software's latest website, Oovie.com.

Vladimir Drndarski is co-founder of Maxim Software Corp. and the co-creator of Oovie.com (www.Oovie.com) and CollectorStreet.com (www.CollectorStreet.com).

The OCDUG meetings are held at Red Brick Software, 1301 East Lincoln Avenue, Orange, CA 92865. [Directions]

Saturday, January 15, 2005

Pres. Lincoln's Farewell Address

The "Great Moments with Mr. Lincoln" attraction on Disneyland's Main Street is going away on Februrary 22 (the day after President's Day) to make room for a special exhibit celebrating Disneyland's 50th anniversary, and our favorite audio-animatronic won't be giving his rendition of the Gettysburg Address again until Autumn 2006. So, if you haven't seen Great Moments lately, be sure and catch it this month -- especially if you haven't seen it since 2001 when the 3D audio effects were added and the whole tie-in with Mathew Brady's glass plate photography was included in the story. This is a great attraction to catch on your way out of the park. They always run it one last time after the official park closing. So, put on your headphones, have a seat, enjoy the show, and wait for the exiting crowd to die down. Who knows? You and your kids may even learn a thing or three about US history in the process.

Saturday, January 01, 2005

Orange County Poker Meetup

Happy New Year. One of my New Year's resolutions is to play more poker, and to that end I would encourage any and all poker players here in Orange County, CA to attend the Poker Meetups every third Tuesday. We don't actually play at these. We just meet and talk, and arrange for games at other times. I usually bring whatever poker books I've been reading to pass around and we always have some terrific discussions. So, get yourself registered on meetup.com and then RSVP for the next poker meetup.