Friday, October 9, 2009

What You Have You Keep

The second law of thermodynamics states that in an isolated system, entropy is an increasing function. In his book, Do Androids Dream of Electric Sheep, Philip K. Dick talks about fighting entropy, or Kipple, as he calls it:
Kipple is useless objects, like junk mail or match folders after you use the last match or gum wrappers or yesterday's homeopape. When nobody's around, kipple reproduces itself. For instance, if you to go bed leaving any kipple around your apartment, when you wake up there is twice as much of it. It always gets more and more.

No one can win against kipple, except temporarily and maybe in one spot.

I've found that there is much truth in the Kipple Theorem. Just think of your house, which contiguously gets more cluttered over time. The same also happens to source code, if left to its own devices. It is also true of memory, which gets disordered over time. What was once clear and orderly, becomes obscure and messy.

Over the past couple of weeks, I've tried to always put something back in its place whenever I go from one room to another. When I do this with disciple, my house starts to look much better. A couple of days of slacking off, and the house looks once more like a total mess. And I don't ever remember making it a mess. It's just that kipple does multiple while you're asleep. Unless we take active, continuous action to combat it, kipple will always win.

Source code is no different. It grows smelly over time. No matter what your source control's log tells you, changes are constantly taking place. They make the code more unreadable, make methods more incomprehensible, and occasionally even introduced some bugs in unimportant locations.

The same is true when learning things, such as Japanese. I've studies nearly 400 kanji characters over the last couple of weeks. Unless I take active steps to maintain what I've learned, my neurons start getting all bogged down with kipple. That's why I am very fanatical about reviewing the items in my SRS software every day. Left alone, for even a little bit, the kipple raises its ugly head and starts to take over.

Kipple Fighting 101

When you learn chess, you basically have to study three different stages - opening, middle game and end game. For the opening stage, you basically memorize the known openings, which have already been studied thoroughly. During the middle game you need to understand basic principles and how to implement them. The end game part is usually kind of a mixture of the previous stages: memorize principles for different scenarios.

One of the most basic scenarios in the end-game is the one where you have a king and a rook and the opponent has only a king. It is very easy for you to win now. But, to make things explicit, the guiding principle is to always prevent the enemy from returning to territories from which he retreated. When the enemy king moves, you make sure he cannot move back to where he once was. You corner him into closer and closer areas.

In the endless chess game against kipple, the opposite is true:

What I have, I keep!

This means an endless game of maintenance. You've learned a new word - make sure you review it periodically. You finished cleaning the kitchen - make sure it stays clean. Constant vigilance is the key to winning this battle.

Whenever you go over source code, you will encounter kipple. It is your responsibility to engage it immediately. No matter what your current objective is, you must spend some of your time chasing and destroying the kipple. Otherwise, the kipple will take over the code base, and before you know it, no one on your team has a clue what does what.

Monday, October 5, 2009

Kill the CAPS LOCK!

The Caps Lock key can do wonders to wreak havoc in VI. You're in command mode, minding your own business, when all of a sudden all hell breaks loose. All because you pressed the caps lock key instead of the shift key.

For a long while I was reluctant to follow the plethora of tutorials on how to kill the caps lock key. The reason is that there are several cases where I thought it was very beneficial to actually use it to, well, lock the caps. For example, by tradition, definitions in C/C++ are written in all capital letters. I finally figured out how to get along without the evil key, as I will explain below:

g~w - capitalize one word
g~~ - capitalize the entire sentence
gU{motion} - capitalize motion

I still have some open issues. For example, to capitalize the word I just wrote, I have to go backwards ('b') and then capitalize it ('g~w') and then go back to insert mode ('A'). I'll be happy to learn of better options, options that take into account that I despite having to configure my setup. Nonetheless, I'm now much better off than I was with the occasional caps lock accident.

You can now make the caps lock key do something else, such as behave as a shift key or an esc key.


Further Reading: