Monday, March 10, 2008

Kenny and The Firing Squad, Episode II: COBOL Has Macros?!!

[[If it is good enough for George Lucas (random release of episodes) it is good enough for me.]

Roll the trailer: Kenny hanging with one hand onto the rear axle of a runaway Cobol stagecoach headed straight for a cliff off which a team of otherwise sensible horses soon will be jumping reaching with his other hand to his ankle sheath and pulling out... COPY...REPLACING!]

Well, someone on comp.lang.lisp made a joke about Cobol and Lisp so I thought I would tell this twenty years later still astonishing cobol-and-lisp-separated-at-birth? war story within a war story about how COPY...REPLACING -- no, that is real Cobol , not a Cobol joke -- ended up taking away the award for Best Supporting Language Feature.

A war story within a war story, with the same theme because I guess they shared a central figure, a young project lead we will call (...thinking of a name...) Reggie. That is good. I got it from Regular Guy and I want to make clear that Reggie was a good guy with a good sense of humor, someone I would party with any time, a young guy his manager (another good guy... look, all these people working in tall buildings are good guys tolerating loose cannon per diems like me to get their code written but not inviting us to the company Christmas party (in the cafeteria -- no loss -- I would have showered had I known) actually causing a boycott by one great guy who could not believe I was left sitting alone at my workstation) ... a young guy his manager trusted implicitly I am sure because of Reggie's technical triumphs past.

The outer story is that I was not even supposed to be working on the task from which I was about to be fired for incompetence. I had not even interviewed with Reggie. (Was that the problem? Hmm.) Reggie had gone to an RDB training class and done his first relational schema and an in-house consulting team had deemed it faulty. Reggie's manager backed him so I was brought in as an out-house... hang on... external consultant to provide a second opinion.

I agreed with the in-house team but Reggie would not budge and the manager still backed him (and I need to admit no one was able to make Reggie see his confusion which must be a story in itself because he was listening to us, he really was a good guy). The schema stayed, and a stage was now a phase:

Reggie's mistake was that he saw that two drug trial business objects (phase and stage) both had a one-to-many relationship with the sample biz object, so he treated stage as a phase. But a stage is not a phase. In Phase IV of testing the samples from Phase III were divided into different stages.) But Reg was fixated on that one abstract commonality and could not get past it.

So? Going away lunch for Kenny? Maybe just handshakes all around since I had only been there a couple of weeks? Nope. It turns out I was there for another reason besides my brilliant mastery of relational DB design: they needed someone to grind out nineteen nearly identical query screens which can best be described as exactly what 4GL packages provide at the push of a button.

Feel free to groan.

Yep. Nineteen screens, each aimed at some node in the DB hierarchy. A few fields at the top constituting key fields and selection criteria, while below was a scrolling list of matching items, each column showing some attribute. Select a row, hit the zoom key and.... sorry, could those of you still awake please nudge the ones who are snoring?

The stack was VAX/VMS, COBOL, TDMS for forms management, and I forget what RDB. Based on the nineteen identical screens take one down pass it around eighteen screens to code on the wall functional spec a child of three could see some template approach was in order, if only through the miracle of cut and paste. But I had been around long enough to know how fast the Red Sea can collapse when after cutting and pasting nineteen screens the user comes along and says could these screens work just a wee bit differently?

Now it happens I had been on a project run by a team of English yobbos who had nothing but contempt for us the few American cowboys (they called us) hired to fill some chairs but they were great fun and pretty good and we had together discovered that Cobol not only had copy-replacing but it could even replace part of a name. I forget what it took, but we found just one letter in the ASCII character set (pretend it was the octothorpe) that lets us code:
perform edit-#fieldname.

...in a template and then (guessing at much of this syntax):
copy "edit-template" 

Well, one was all we needed, so away we went and life was good and now here I am staring at nineteen screens and I forgot to mention Cobol's MOVE-CORRESPONDING which could populate TDMS data records from DB data records if I was bright enough to name things the same and stand back Argentina! Here come the screens!

I told Reggie what I was going to do. He said, Fine. I said it would help knowing which of the nineteen screens was the nastiest (OK, they were not all that identical). He got it. Fourteen, is a beast. It pulls in data from two yadda yadda. Off I went.

You all know how it goes. I spend a week on screen fourteen, not because it takes a week but because I am building a framework, with one eye on the other eighteen screens sitting in the corner. Hell, I even built an IDE.

The command language for VMS was DCL, a gorgeous little thing. This was all before the multi-window days of VMS. Things got a little tedious as I bounced from editing the TDMS form to the Cobol template to the screen-specific Cobol copy-replacing the template to testing the thing, so I wrote a DCL script that just needed to know on which screen I was working and what I wanted to do and then did The Right Thing. When I exited I fell back into the script, which asked what now? Way cool and productive.

Where was I? Oh. You know how it goes. With screen fourteen working I launch into screen one, hoping it Just Works because Reggie and I had picked out A Beast. Ah, not bad. Screen two. Check. Screen three. Here's a twist. Scribble scribble... good.

Screen four. Excuse me? Two lines of info in order to display one detail? Ouch, did not see that one coming. Bang bang hammer thwack... OK. And on we go. Sure, I still had to build a TDMS form for each screen, but I will live. Or so I thought.

It is Monday of week three and Reggie is standing at the door to my windowless little room.

"Morning."
"Morning."
"How's it going?"
"Great."
"I ask because I haven't seen anything yet."
"Sorry?" Hairs on end.

In five years of programming including three as a pricey independent consultant I had yet to hear one discouraging word from a manager unless you count the time the guy (a very big guy) stood over me beet red literally spitting "Sh*t! Sh*t! You didn't test it, did you?!" as my program gleefully copied only every third record in its first production run because I had left in the bit that did that to make tests run faster. Another day.

"Well it has been two weeks and I haven't seen one screen yet."
"I told you. I am doing all nineteen, not one."
"That's all well and good, but I will be at a class all week, won't be back till Friday, and I need to see something by then."
"Fine." Not sure if you can see the smoke rising from my collar.

It is now Friday noon. Kenny has logged no overtime, but Kenny has had his game face on for four solid days. Co-workers discovered they could rewarm their coffee faster than the microwave if they just put it in the same room with me.

Kenny has little hope of a Hollywood ending, but suddenly Reggie is standing in the doorway, right where he was when he hung the sword over my neck.

"How's it going?
"Good. How was the class?"
"Good."
Silence.
"So where do we stand?"
"With the screens?"
"Yeah."
"They're done."
"They're done? All of them?"
"Yep."
Silence.
"Well, if that's true, that's great."
Withering look. And the fun has only begun.

Late Monday Reggie swings by with a list of trivial bugs and issues.

"Thanks."
"I really like the way it works."
"It's your design."
"Right," and reaches over his shoulder to pat himself on the back.
Did I mention he was a good guy?

"Could you print out the source code for me? I'll read it on the train."
"Will do," looking forward to the praise and astonishment soon to be heaped on me.

Tuesday. My turn to stand in the door of his office.

"Kenny, I was trying to read your code on the train home."
Uh-oh.

"First I'm up here, it says perform this, I have to flip down to find it, then there it says perform that, I'm flipping down again, then I flip back up and it says perform something else and I am flipping down again. Then up then down then up again. What's up with that?"

"It's called structured programming. It's in all the books."

I forgot to mention that by this point I had already given notice. I explained that I thought I was signing on for a short DB design review, not a job in a body shop. They reacted with all the chagrin of the monks at learning Ace Ventura was leaving the temple.

"Yeah, well that's all well and good, but if I cannot understand your code we won't be able to use it."

Well, I was right about one thing, only it turned out to be the garbage heap. By now I think I have made clear to my Honored Reader that I do not consider myself an exemplar of human social interaction including especially the delicacy required by the workplace, but what I did next disappointed even myself but felt great because it was so perfectly honest: I slowly closed my eyes, leaned my head against the door jam, and just stayed that way.

Reggie could not help laughing. Did I mention... yeah, I did.

"All, right. Look. We'll do a code walk-through with Roger [his co-lead] this afternoon, see if we can figure this out."

"Fine."

This afternoon. Twenty-thirty minutes. Copy-replacing. Here is the template, here is a usage. The usage has all and only the stuff specific to that screen. The template. blah blah blah. This is here because of screen eight, two lines to show one detail. If you get other screens like that use eight as your starting point. Oh, this is because of fourteen, that special XYZ requirement. Yadda yadda yadda but there was one strange thing and I was deeply worried.

Neither of them asked a question. Ever. Not one. Have I conveyed the smallness of the questioning? This cannot be good, but I had no more to say.

"Any questions? Reg?"
"No."
"Rog?"
"No." Pause. "Pretty obvious, actually."

And then silence.

3 comments:

vanekl said...

When I wondered why the "smallness of the questioning" in my code review was so anemic, I asked everybody whether they had even bothered to read the code. Everybody except one admitted to not reading the code. This was a checklist event, purely for show. When that became obvious, I excused myself and walked out of the meeting so I could go write some code. Not the brightest thing to have done, in retrospect. It turns out that pretending to hold meetings is very important to management. Lesson learned.

I love war stories. Experience is the best teacher.

Anonymous said...

A Yobbo Plea:

Kenny,

Your (stream-of-consciousness, run-on sentence ridden) writing style makes it difficult to read and understand your writing. Can you please try to write with a bit more clarity? I'm not asking you to lose your humor or personality, but just to spend a little more time on sentence structure and coherence.

I think your actual content (stories, ideas, etc.) are always GREAT...it's just that it is often painful to read and grok your content because of the structure.

Kenny Tilton said...

"Never express yourself more clearly than you can think." -- Neils Bohr