Friday, February 27, 2009

Item 1: Rmvng vwls frm vrbl nms svs spc. Wh crs bt rdblty?

That's right you read it. Well probably not. That is the point.

Dave was a firm believer and enforcer of the idea that saving
disk space was paramount - and removing vowels from variable and function
names saves space (disk space). And that gives us the title. The reality was
that you removed vowels (except in a few cases) and some constanents.

Ingenious idea, right? Who really cares about readability ("Wh crs bt rdblty" for
those that haven't figured it out yet), right? Everyone except a Dave. Why?
Dave wrote, and remembers it. He doesn't need to read it. If someone else
needs to understand it, ask Dave!

But we digress...

Let's look a little closer at this. At first glance, there's some logic here -flawed
as it may be - but there is logic. Technically each character taken out of a file
saves one byte of space on a hard drive. Therefore you saved one byte for each
vowel removed from a variable of function name.

So how much space do we really save? Lets look at a simple example. Let take
a function that is supposed to return the current time zone. Insisting on readability
we would call this function getCurrentTimeZone(). Dave would insist (and sometimes
change the name for us in our specialized version of a shared source repository(but thats another story)) to GtCrrntTmZn(). By our calculations Dave managed
to save us a grand total of SEVEN bytes!

Here are some other examples of variable names:

Level => lvl saves two bytes
Name => nm saves two bytes
LevelName => lvlNm saves four bytes
PlayBack => plyBk saves three bytes
comPort => CmPrt saves two bytes and confuses everyone...

Disk space hasn't really been an issue for some time. Bear in mind Dave didn't
say this in the early eighties - he was enforcing this practice in the early 21st
century. Ok at that time, terabyte hard drives were only available in a programmer's
dreams. But even then 4, 6, 8 GB hard drives really existed!

In the end lets learn from this. Saving a byte (approximately .0000000125% of an 8GB
hard drive) does not help as much as the reduced readability hurts.

Don't Be a Dave!

No comments:

Post a Comment