Variables have rights!

January 26, 2010 - Humour, Programming

I bring forth to you all an important cause.

Ever since the inception of programming, we have used things called Variables. they store our data, they help us to keep track of the ever-changing environment that is where our programs stand. But how often do we think of their rights as individuals? We instead try to optimize them away; “we don’t need that variable” or “we could make that a constant”. You self-centered bigots! All a variable asks is maybe a few bytes of memory, and possibly the ability to be thread synchronized, but you are trying to remove these little helpers as if they have no right to exist! consider the following:

public class ExampleApp
private int munused;
private int maddthis=56;
public static main(String[] args)
System.out.Println("Hello from main");
for(int i=1;i<51;i++)
x /= (++x/i++)/(maddthis*--i)



Any experienced variable killer can see that they can delete munused entirely, and that they can can convert maddthis to a constant. But what they don’t consider is that they are KILLING innocent variables! Programmers these days endeavour to learn programming practices and implement them with unfeeling and unwavering constitution, with absolutely no regard for the font families they destroy or the variables they create; it’s important to relate to your variables. your average programmer sees a temporary or unused variable as wasteful; I see a variable that is going through a scary change, who needs a friend (have you ever considered the Variables feelings when you typecast an int to a double? your just highlighting that variables shortcomings! you’re telling that variable that they are inadequate, that their data type is simply inferior to the one you are casting it to. And you know what that variable loses? It’s value. Now some other new variable is holding it’s value, and it supports floating point operations, and because of it’s type it gets twice as many bytes of storage!). Tell stories to your variables. Tell then the bible story of Variable Jesus who allowed it’s own destructor to be called, just so that all other variables can have everlasting scope. And, remember: NEVER tell your variables what their scope is. If they discover that their destructor will be called right after this quick for loop, they may go mad. “What? I only have 3 iterations left to live! I’ve lost all scope!”. Be sure your variables know their place. “All variables are created equal- it is their initialization that makes them unique”. Function Pointers have a tendency to forget that they are variables; they walk and they talk and they even have similar syntactic requirements as a function, but don’t be fooled! they are really just a variable in a functions clothing. Don’t try to call a null function pointer or the clothing has a habit of chafing.

Object Variables

Object Variables are possibly even worse then Function pointers. they always consider themselves superior to all the primitive types, like ints and doubles. what Object variables don’t realize is that the vtable that makes them who they are is really just a structure; a collection of function pointers. In fact, make sure your object variables know they are really just a collection of function pointers and private data. Also, educate your young object variables. “never show your privates to strangers, even if they give you memory” and never EVER let anybody put something in your back-end!

If you know somebody well enough, you might want to share certain protected variables with them, as a gesture of good faith. But you still should not trust them with your privates. they might still try to shove data in your back end.

Make sure your objects understand that they really are just the sum of their aggregate parts, and that they have their superclass to thank for almost everything. an Object is created, it is given a few pointers, and sent on it’s way.

Your standard pointer variables are pretty unpredictable too; remember that dereferencing, for a pointer variable, is a very traumatic experience. It’s also important to reduce aliasing as much as possible; to avoid indentity crises between multiple variables who meet and see that they both point to the same memory space. It’s important that you initialize pointers, as well. There is nothing more traumatic then a variable discovering it is equal to 0xCCCCCC or 0xDEADBEEF, and that it is really holding a flag. a flag of surrender. Unless the variable is French this won’t feel right for it.

Have something to say about this post? Comment!