Stoopid Script Code Pontifications

Type-agnostic function mapping. This is old hat for LISP programmers, but for other type-defined languages, it often looks as horrific as staring at a tragic automotive accident.

In certain scenarios (subjective environmental analysis), there exists a near-equal referencing of data mapping between two pairs of associated relations. Key and value. You can define a global data structure (hash, dictionary, array, list, etc.) or wrap it in a function. Either way, when you spread out the atomic pointer allocations the end result is often a wash.

Whether you stuff the data in one place and a function wrapper in another, or combine them, the overall footprint is not that different, depending upon the language construct and syntactical constraints. Yes, I’ve been reading some books with big words, but stay with me, mmkay? Either model is still better than one of them with repeated code fragments elsewhere (or within iterations, etc.), hence the advantages of refactoring.

Now, some interesting thoughts and comments on this tragedy, if I may:

The use of a delimited string as the logical array/list/hash store is obviously a point that could be debated well beyond the point at which our spouses had already left the party and we didn’t even notice. However, with smaller structures (less than 1 MB of data) the processing overhead on even an older Core2 Duo is “immeasurably small”. How small? As in, smaller than the chance your vote will affect any future presidential election outcome. So, a Dictionary, or Array (in VB parlance) would suffice equally well, but I’m too lazy right now (been out shopping with my wife).

The type-agnostic handling and return value is nice for avoiding an overload scenario (common to C/C++/Java and C# realms). LISP was (is?) even more dynamic and elegant in that the function can self-define itself infinitely or with self-binding constraints (say that ten times).

I’m sure the above disaster could be done with PowerShell (or Perl, Python, Ruby, JSON, two sticks and mud, a bowl of cornflakes, etc.) But the point is not the language. I just chose this as one example. The point is we often make two (or more) functions which could be refactored more efficiently.

No animals were harmed in the course of making this. However, I did smooch my little dog to the point where she’s hiding right now.