JUnit Code Snippet

9 PM April 10, 2003

I found this line of code in a test suite I was modifying.

    assertEquals("Next number must increment ", 

                                next == next, next > first);

By alang | # | Comments (0)
(Posted to Software Development)

Honorable "fake" Surrender

11 PM April 8, 2003
Jacob wrote a piece "Honorable war?", in which he ponders:
[...] the "fake" surrender tactic is not new. Which makes me wonder whether all wars might not be dishonorable to some extent.

It's been observed plenty of times before that war brings out the best and worst in people, on all sides. On one hand men and women will put themselves in mortal danger for the greater good of others. On the other hand, men and women will take advantage of the situation - looting, corruption or manoeuvring and manipulating for personal gain.

The extremes of war provides a backdrop for stories of honour and dishonour play out again and again on both small and large scales. And we should acknowledge both: honour and be proud of our men and women who selflessly give of themselves and be ashamed of those who do the opposite.

One thing is worth considering: Are the Iraqi "fake" surrenderers heroes? For their country, they boldly place themselves in the line of fire against the world's largest and best equipped military force, with only a crude piece of trickery as a shield. How brave (or desperate) would you have to be to to come out of a perfectly good hiding place - weaponless - and drawing attention to yourself? Sure my buddies might be hiding nearby with their guns ready, but if I did it, it'd be the bravest thing I'd ever done, by a country mile.

These Iraqi's do use "unfair" deception, but the invading force has "unfair" technology.

War sure does suck.

By alang | # | Comments (0)
(Posted to Stuff)

Ted Neward Validation Amusement

11 PM April 7, 2003

Ted Neward just posted an article on validation. It describes how important validation is, when to do it, what kinds of to do, how to report errors and even discusses the technologies you might use.

I thought it was great. So I went to post this comment:

This is a good read.

A site with a lot of good, consistent, Javascript validation often feels polished and professional. A site with cheesy validation (or worse, a "500 Internal Error" and a Stack trace) can be really painful.

I'd also add that testing validation is a pain-in-the-neck, but if you have, you _must_ test it. Any mistakes in the validation code look bad and can quite possibly prevent a user from submitting valid data.

And then I pressed submit and got...

HTTP Status 500 -

type Exception report


description The server encountered an internal error () that 

prevented it from fulfilling this request.


org.apache.jasper.JasperException: entryID should never be null!

	at org.apache.jasper.servlet.JspServletWrapper.service(


	at org.apache.jasper.servlet.JspServlet.serviceJspFile(


	at org.apache.jasper.servlet.JspServlet.service(


	at javax.servlet.http.HttpServlet.service(


	at org.apache.catalina.core.ApplicationFilterChain.


	at org.apache.catalina.core.ApplicationFilterChain.


	at geekblog.filters.ReferralsFilter.


	at org.apache.catalina.core.ApplicationFilterChain.


	at org.apache.catalina.core.ApplicationFilterChain.


	at geekblog.filters.PrefsSetupFilter.doFilter(


	at org.apache.catalina.core.ApplicationFilterChain.


	at org.apache.catalina.core.ApplicationFilterChain.


	at org.apache.catalina.core.StandardWrapperValve.


	at org.apache.catalina.core.StandardPipeline$



	at org.apache.catalina.core.StandardPipeline.invoke(


	at org.apache.catalina.core.ContainerBase.invoke(


    < ... and so on for a few hundred lines ... >

Apache Tomcat/4.1.24

I am not making this up.

Not that I should find it too amusing... I know this blog's comment form can be a little dodgy too :)

By alang | # | Comments (0)
(Posted to Software Development)

Neat SAX Trick

9 PM April 7, 2003

I have a fascination with dead technologies, which explains why I started reading the Java Web Services Tutorial today. In the XSLT chapter, I came across this gem entitled “Generating XML from an Arbitrary Data Structure”.

It describes how to implement just enough of the interface of a SAX parser to drive an XSLT stylesheet. The example given transforms an LDAP database entry (in the form of an ldif file) into an XML document using the default XSLT transformation. The trick works quite well in this situation, because the ldif file has to be parsed anyway.

This kind of trick might also work in other situations where parsing and transformation are required. For example, you could build a tiny web-app that runs free-format queries against an SQL database, and returns HTML formatted table results. Using an external XSLT stylesheet would give scope for customising the display.

By alang | # | Comments (0)
(Posted to Software Development)

PortableRemoteObject.narrow() must die

9 PM April 3, 2003

Today, while peacefully coding EJBs, I found myself writing code using the dreaded PortableRemoteObject.narrow() again. Charles "Fischkopf" Miller went into some detail about how painful this is in one of his recent blog entries. But in case you haven't experienced the exquisite clunkiness of PortableRemoteObject.narrow(), here is a code sample:

  // Get a bunch of things

  Collection collection = 


  Iterator iter = collection.iterator();

  // Take the first one

  PolicyOptionGroup policyOptionGroup =

      (PolicyOptionGroup) PortableRemoteObject.narrow(



The call to PortableRemoteObject.narrow() is required because the objects in the collection returned by the finder do not actually implement PolicyOptionGroup interface. Which is surprising, if you think about it. If they did implement the PolicyOptionGroup interface, we could write the more idiomatic:

  PolicyOptionGroup policyOptionGroup = 

      (PolicyOptionGroup) iter.next();

(Which is quite long-winded enough in itself, but that is the subject of another blog entry.)

Based on the comments to Charles' blog entry by Thomas Roka-Aardal and Bob Lee, there is a good reason for this verbosity. It goes like this: EJBs use RMI, RMI is transported by IIOP - the CORBA protocol - and the existing CORBA libraries cannot possibly be wrapped or modified for the convenience of EJB programmers.

In other words, this ugliness is caused by exposing an implementation choice that is at least two steps removed from my EJB code. And the benefits? The only two offered are:

  1. RMI IIOP allows CORBA applications to call RMI applications. So what? Can CORBA clients call EJB servers or vice versa? Who has done that in a "real" application? (These are not rhetorical questions - if you know the answer, please comment!) Even CORBA - EJB calls are possible and are used, how much benefit is it developers overall?
  2. Exposing the CORBA like this allows them to be reused. Fine. Good argument. I'm all for reuse. But please, let's wrap the ugly details.

Surprisingly, Bob Lee - in his comment on Charles' blog arguing the case for PortableRemoteObject.narrow() - pointed out that it was possible to hide the call to PortableRemoteObject.narrow() from EJB client code. Excellent. Let's do it and knock out "2 lines" of code (plus method declarations) per finder per EJB client.

By alang | # | Comments (1)
(Posted to Software Development)

M$ Project and Java: Parallels

9 PM April 2, 2003
Mats has a mini-rant about MS Project, finishing with:
And don't get me started on the UI itself. I mean, it seems to be based on Excel! That is such a satanic idea that it baffles me. How can they get away with such a stupid tool, year after year?

Well, not only did Microsoft base a a large chunk of the UI on Excel, several of the good features of Excel seem to have disappeared in the process! For instance, Project has only one level of undo. This is thoroughly inexcusable in a modern desktop application. Other functions are tacked-on and kludgy - like PERT charts and the whole Duration1, Duration2, Duration3 ... Duration9 thing.

On the other hand, Project is the product by which every other in the class is judged. Some competitors are better at particular tasks, some are cheaper, and some are both. But Project is good mix - not the most expensive and not the least. It can do a reasonable job of small projects, large projects and everything in between.

Another neat thing about Project is that it exposes its data model via ActiveX, so you can script it in VBA (or Python!). Last year I wrote a set of macros to take milestone dates from plans, plonk them into a spreadsheet and then graph how those milestones moved over time. Very effective at making any "planned slippages" visible to upper management.

Overall, MS Project is a comprehensive, competent offering. Sure it has some kludginess, gaps and obvious hangovers from earlier versions, but it works, has industry mind-share and is widely used.

Which is what many people say about Java.

By alang | # | Comments (0)
(Posted to Software Development)
© 2003-2006 Alan Green