18 February 2006
How DRY I am, except for the framework
Last year I published one entry regarding "BEA Workshop Annoyances".  I've moved on to other projects as of three months ago, but I was reminded of another Workshop annoyance I encountered, by a Bruce Eckel's article posted on reddit, which the author began with some observations about the DRY principle, the one that says "Don't Repeat Yourself".

In a nutshell, I had devised a system whereby I populated an array with values from the database, and this array was used both to populate a drop down menu, and to validate the value provided for the same field.  This was necessary because of an extraordinary use case, where the data entry form could be populated from an uploaded Excel spreadsheet, in which case it was entirely possible that the uploaded data might not match the choices from the pulldown menu.

In which case the validation message printed properly, that "blahblah" wasn't a valid value, but the framework also performed some highly undesirable magic under the hood.  It added the invalid value to the array of possible values and displayed it in the drop down menu.

So I would like to thank Workshop/Beehive/NetUI for making me look like an idiot in front of the project manager after I'd been proudly pontificating about the DRY principle.  No wonder, as Bruce Eckels put it, the principle is practically ignored: when it should work some corporate mandated framework steps in to make sure it won't.

Actually there was a workaround, I don't remember it precisely, but it was some sort of horrible hack that had to be implemented on the client side, involving looping over the array either through JSP scriptlet or Javascript code, and removing the unwanted element.  The shame of it is, that otherwise Workshop did some wonderful things.  Through its use of "annotations" (this was pre Java 1.5 so they were not annotations in that sense), I never had to touch a struts xml configuration file.  I even had a subsequent phone interview with a leading Struts author, and he wanted to pick MY brain about this.

If only the developers of this, and other frameworks (Ruby on Rails included from what I hear), could consistently do just enough for the developer, and then get out of the way, instead of performing some magic they think makes sense.  Whereas I was attempting to adhere to DRY, these framework developers need to adhere to the principles of test driven development.  Surely the developers of Workshop/Beehive/NetUI did not create a test that added the unwanted element to the source array of elements for the UI widget, and then conclude that the test passed.

Just my $0.03.  Inflation.
Posted by htmatters at 6:16 AM | Comments (7)