The Junit / Green Lantern Oath
In brightest day, in blackest night
No failing tests shall escape my sight!
Let those who sloppy code would write
Beware my power -- Junit's green light!
(Charles Roth, 2011)
OK, it's kitsch
Tacky. Geeky. Even (shudder) cute.
But it also has a point. Bear with me.
(I'm assuming you're a software developer, and already familiar with
and Green Lantern
I wrote my first Fortran
program in 1970.
I've been coding ever since.
These days they call me a "senior architect" --
hopefully for my knowledge and experience,
and not my gray hair.
But every day, in every shop, in every language,
we're bathed in two feelings:
Why Green Lantern?
The excitement, the joy, the power, of making these
lumps of silicon jump through hoops, stand up and
perform miracles at our command.
We write new code in a burst of energy and delight.
And then... when we go to change it, or touch code
that we didn't write... we are afraid.
Because the faithful digital servant that
takes our every instruction as the word of gods... turns
on us, savages us in a microsecond, when we err.
That is why we
Oh, people will blather on about Agile productivity,
improved ROI, safety-nets, unit-tests as documentation, ad nauseum.
But those are just words to convince the blinkered bureacrats.
They will never know the gut-twisting agony and responsibility
that we feel,
when the spaghetti code slides, like razor blades, through our naked
The parallels are striking:
Why an Oath?
- To fly on a thought.
To weave constructs of energy out
of our imagination and willpower.
To make a difference!
To build where others would destroy.
- Fear is our nemesis.
of the DC Universe,
green is the color of will-power.
Yellow is the color of fear.
Originally, Green Lanterns were powerless against yellow.
Even now, new Green Lanterns are recruited
with Gabriel-like declarations: "Hal Jordan of sector 2814, you have
shown the power to overcome great fear".
The Oath came to me in a
in 2011, when I saw the (so-so)
Green Lantern movie
The green light of the Junit test framework merged
in my mind with "Green Lantern's light!"
, and the rest was,
well, history. Or fantasy. Or whatever.
In the real world,
neither a green wrist band
nor a comic-book oath is going
to help us write better code or more tests.
But consider what's behind
In the 1994
Green Lantern: Rebirth
a troubled Hal Jordan succumbs to Parallax --
the literal (yellow!) embodiment of fear,
long imprisoned in the master Green Lantern battery on Oa.
Jordan nearly destroys the Green Lantern corps,
redeems himself by reigniting our dying (yellow!) sun,
and finally triumphs over Parallax with the aide of
his fellow Lanterns:
John Stewart: Hal, what's your plan?
Hal Jordan: Remember fear.
Guy Gardner: "Remember fear?"
What the hell kind of science crap is that?
As developers, that's exactly
what we need to do.
When we don't ackknowledge our fear, we:
- Deny it, and insist on absolutely precise specifications.
"I could write perfect code if only the specifications were correct!"
- Deny the issue entirely, and push it away from the ego:
"I'm a brilliant programmer. Tests waste my time."
- Turn the fear inwards, and obsess.
"I'm a careful programmer, I study every possible path of execution."
We hunch over our monitors, and carry the stress home in our bodies.
- Despair, and live in fear.
"That's just the way it is. We'll always have bugs."
And our delight slowly erodes.
- Look for religion.
"If only we faithfully follow six sigma, or CMM Level 3, or all
become SCRUM masters, we'll be saved."
- Become neurotic, and make the fear part of us.
We painstakingly hack additions and kludges around existing code,
like an oyster putting down layers of pearl around an irritating grain of sand,
and think that this makes us a good programmer.
- Project our fear, and blame everyone else for bad code.
- Avoid the source of our fear.
Avoid change, avoid rewriting, avoid refactoring.
- Escape into "if only's".
"If only we could rewrite the entire project, this time
we'd do it cleanly!"
Or, "If only I could find a job where things were done right for a change."
When we face our fear, we...
- Accept the up-front cost of unit-tests.
- Build our own safety nets.
- Sleep better at night!
- And best of all... begin to realize that change can be safe,
and even exhilirating.
The code that was a mess... can be changed,
can be made clean, can be made whole.
why there's an oath: to remind us.
Face your fear. Own your power. And own the green light!