Monday, April 25, 2011

Ghosts of LOCs past

The maid was sweeping the floor, making wide arcs with her broom. I was surprised to observe that even at the end of the process, there wasn't anything in the dustpan. In a house where the five-year-old always manages to throw things around (objects that are precious to him, and garbage in my eyes), and where there is a perpetual thin layer of dust on every piece of furniture, a spotless dustpan was out of the question.

I accused her of not cleaning properly - of not crawling under the bed and peeping under the table and pulling out lethargic dust-bunnies or other misbehaving undesirables hiding under them.
She said, I did check under the bed and sweep well. There weren't any.

It simply wasn't possible. My argument was, though she cleans the house daily, there should be something for her to gather. There should be something visible - a certain acceptable amount, not more, not less - in the dustpan. Every day. Crumpled paper, dust, black hair, grey hair(ouch!), broken pieces that were once toys, pencil tips, eraser crumbs, dirt, whatever.


Our brain has this uncanny, unnecessary and annoying ability to pull out metaphors from the past and toss them right to our face. We can almost hear it chuckling as it does so. So it was, when I thus spoke to my maid, I was stopped short by a voice (inside my head?) reprimanding me for not unearthing - hold your breath - enough defects from an unsuspecting developer's code during a Code Review (CR).

The sky ripped open with a flash of lightning, the scene before my eyes rolled back, the maid vanished, and I saw myself perched before my PC, lines after lines of code (LOC) scrolling up and down before me. I was straining my eyes sweeping between the lines and over the lines, trying to bring hidden faults to light: logical, analytical, syntactical, grammatical, typographical, nonsensical or any other that I could jubilantly ("eureka!!") make a note of in an excel sheet, categorise them as Major, Medium or Minor as per my whims and fancies. There is this N:1 ratio that wise people invented in the last century: for every N Lines Of Code, there should be at least one defect. I am sure it is based on the undisputed fact that nobody is perfect, so nobody's programming code has the right to be perfect. The overall number of defects at the end of the CR hangs in a delicate balance: if the number is too large, the program is not well-written and the developer is in trouble. If it is too low, it does not mean the program is well-written, but that the review was not exhaustive enough. Which was why my eyes were peeled for the evasive crumbs of programming defects, to sweep them into my dustpan of an excel sheet.


If my maid threw extra pieces of paper or sand into the dustpan (even if she had to bring them from her home for the purpose), I would have been satisfied. On the other hand, since the program code could not be changed to insert bugs (because the version-control repository would record the modification along with the name of the mischief-doer), the only thing to do was report non-existent or impossible bugs. Like this:

"The comment on line 143 does not follow coding conventions." - Minor
"It is better to give the '{' in the next line." - Minor
"There is an extra space between the end of code and the semicolon." - Medium
"An extra couple of blank lines between two blocks of code!" - Medium
"If the program forgets to perform NULL check, there will be a series of crashes." - Major

If, by chance, we found a real bingo Major / Critical defect (a potential crash, a suicide bomber or a hidden grenade), we would split it into one major and 2-3 medium defects, even invent a few minor ones, so that the overall ratio of CR defects would remain 'as expected', without any harm to the coder or the reviewer.


"There has to be defects concealed in all these hundreds of square feet of code," I said.
"Eh?" said the maid.

Jolted back to the present, I stared at her for a second and said, "Why don't you sweep the floor again, you might find something."


4 comments:

  1. This is wonderful. We are sooo suspicious of good work!

    ReplyDelete
  2. Funny how things that are troubling us now were once ways we troubled others. Be careful not to judge because somehow it comes back!!!

    ReplyDelete
  3. You said it, Mike!

    Anonymous (sorry, I prefer at least initials): We get what we give, we give what we get, we get what we ...

    ReplyDelete
  4. A good read. A system often neglects the persons. It has no way, many a time, to record the truth. (And we fear to be truthful). What it needs is data matching up with the statistics. We forget the statistics applies only to huge chunks of data.

    ReplyDelete