Pure programming knowledge is not enough

I’m short-sighted. The degree of blurriness isn’t terrible, so I can still make do without glasses. When I first started working, I thought working with computers the whole day warrants the wearing of glasses, so I got myself a pair. Turns out to be more trouble than it’s worth…

Eyeglasses
[image by Gene Chutka]

Anyway, I found out about it when I was in university, when I couldn’t see the notes on the projector screen or on the board properly. I’d have to sit in the first 3 rows if the words were to be clear. But the first 3 rows were occupied by uhm, zealous students, so I took seats slightly further away.

Since I couldn’t see much of the notes, I squinted. To forestall some of the obvious questions, no, vanity had nothing to do with not wearing glasses. Glasses were expensive, and so were contact lenses. And they’re really troublesome to wear on a regular basis. So yeah, no glasses.

To compensate for my “loss” of sight, my other abilities stepped up to take on the responsibility. After 2 and a half years of serving the nation (National Service in Singapore), I was suddenly very productive. I paid better attention to the lecturer. I listened carefully.

Since I can’t see very well, I got context from surrounding words. My language skills helped a lot, filling in grammar, spelling and sentence structure. In both proper and “broken” English no less. I was studying math, and my math background helped in making sense of the symbols and the esoteric language used, filling in gaps where my language skills were useless.

With perseverance, lots of context filling (from language and math), I got most of the lesson. I actually took very little notes, since I couldn’t copy them fast enough anyway. I opted instead to understand what the lecturer was teaching and try to quickly absorb them.

I’m not so much concerned with seeing the words correctly, but interpreting them correctly.

The squinting… Now the squinting seemed to blur the words even more. But I saw the words more “clearly”. It’s like holding a picture close to your face. It’s blur, and you can’t make out anything. Take it further away and you can see the picture. It’s something like that. I needed to “blurrify” the words so they became meant for far viewing in my case. Sort of like Nazca Lines.

After I graduated and started working, I got myself a pair of glasses. Then I stopped wearing them. I haven’t needed to read words at a fair distance. And the computer screen seems to read fine. I take regular breaks to rest my eyes. Besides, wearing glasses gives me a headache and dries my eyes easily. Sometimes, I still wear them, and only for reading books and playing video games (otherwise I can’t see the dialogue on the TV screen).

The lesson?

When I read code, be it other people’s code or mine, I use a lot of context filling. Half the time, I’m using my knowledge of business logic, human psychology and languages (English or otherwise) to understand the code. The other half is programming knowledge.

It’s when I do this that I figure out patterns, of decisions made (where devoid of comments). That I understand where I needed to make changes for new business logic. That I can do simple refactoring (the refactoring is simple. It’s the understanding that’s hard. Different programmers do the same thing differently).

I found that when reading code, whether because of debugging or adding changes, pure programming knowledge isn’t enough. For example, if I knew the original programmer wrote that piece of code far in the past, I could make a guess as to why he wrote it that way. Say he’s trying to optimise a piece of code, but the optimisation is no longer relevant in modern times.

It bears repeating. Pure programming knowledge isn’t enough.

You are debugging with the wrong database

I feel an urge to tell a story first. So here goes…

Once upon a time, in a far away land, a young prince lived in a shining castle. Although he had everything his heart desired, he was spoilt, selfish and unkind.

But then, one winter’s night, an old beggar woman came to the castle and offered him a single rose, in return for shelter from the bitter cold. Repulsed by her haggard appearance, the prince sneered at the gift, and turned the old woman away. But she warned him, not to be deceived by appearances, for beauty is found within…

Oops, wrong story. Let me try again.

Once upon a time…

In the Far East, there was an adventurer by the name of Wen Sen* (wuhn suhn). He wandered many lands, climbed many hills and even walked on glaciers. But he’s a scholar at heart, and so he set out in search of knowledge.

Mayan ruins explorer
[image by Steve Geer]

Wen Sen wanted to find out more about a particular village with strange inhabitants. After travelling many days on foot, he finally reached the village’s gates. Despite his raging thirst, his thirst for knowledge was greater. So he accosted the first villager with

Do you think it’s a coincidence that the first 3 prime numbers are also part of the Fibonacci sequence**?

Getting a blank stare, he leapt to the next villager with

What are your thoughts on the first 3 odd prime numbers forming 2 pairs of twin primes***?

Despite his fervour, Wen Sen didn’t get anything out of the villlagers. He even tried indecent questions such as “Are you divisible by 17?”. Dejected, he slumped at a corner of a building, thoroughly miserable.

An elderly woman approached him and asked,
“Are you alright, young man?”
“I’m fine. I just haven’t found what I am looking for,” Wen Sen sighed.
“Well, what are you looking for?” she asked.
“Your village is supposed to hold the key to unlocking the secrets of prime numbers,” Wen Sen breathed. “But everyone seems confused. What am I doing wrong?“.

“Oh,” the elderly woman’s eyebrows lifted. “You must be referring to our neighbouring Village 2357. This is Village 4680.”

The real story…

Well, I can’t remember the details. All I remembered was, I was testing my code, and the results on the web page didn’t match the results in the database.

I triple checked my code. I retrieved the results from the database to verify the data. Everything was in order. But why wasn’t the web page showing the correct set of data?

I forgot what triggered it, but I suddenly realised that I was connecting to the wrong database. I was working with databases in development, testing and production environments then. And I forgot to change a configuration setting.

From then on, I was careful about making sure that I’m in the correct database before I do anything else.

* Wen Sen are the closest Chinese characters to my name Vincent. It means “knowledge forest” or “culture forest”, depending on context. And depending on the Chinese characters used, of course. And no, my actual Chinese name isn’t Wen Sen.

** The first 3 primes are 2, 3 and 5. The Fibonacci sequence is 1, 1, 2, 3, 5, 8 and so on.

*** 3 and 5 form one pair of twin primes. 5 and 7 form another.