Reflections of an old man: Learning to code

Not sure this anecdote necessarily has a point, just sharing a story for Friday afternoon.

Reflections of an old man: Learning to code

It’s the year 2000. I’ve just been handed a copy of Design Patterns: Elements of reusable object oriented software. And subsequently told to ignore it. This was one of the most formative lessons in my career.

I had just graduated with an aerospace degree a few months earlier and was somehow sitting writing C++ emulator for a fighter jet. And I was stuck. My manager at that time (whose name, I’m ashamed to admit, I can’t remember, but it might have been Vikash so let’s just use that) handed me the aforementioned design patterns book opened to the composite pattern. I dutifully followed the book to the letter. 

All through my degree I had learnt the rules for engineering. If I was implementing a Rung-Kutta based method to implement Navier Stokes, I wasn’t about to start inventing my own algorithms. I read the chapter on the composite pattern and diligently applied the examples to my own problem, doing exactly as stated in the book. I was pretty sure I had nailed it.

Then I showed Vikash. He was less impressed. He proceeded explained why my solution wasn’t vert good. Sure, it worked, it just wasn’t optimal or beautiful in its design. I protested. I explained I had done things exactly the book had told me to. He taught me what, more than 20 years later, has proven to be one of my most formative lessons. 

What is in the book is a suggestion.

That one sentence made me rethink what I was doing completely. I wasn’t supposed to implement it verbatim; I was supposed to be mould it to my own particular needs. So, I rewrote my code.

A year or so later I had a very similar problem. This time I was writing code for the UI of a telecoms system in Visual C++ and trying to model all of the phone numbers owned by a legal entity. Different domain. Same problem. The existing code worked fine if you opened Joe Bloggs. It took tens of minutes to render if you opened up a large company. Solving that one got me a bonus that was the downpayment on my first Ducati.

I guess this all just old man reminiscing at the clouds at this point though. The genie writes the code now and I don’t know how we even teach similar lessons.