Approximation Of Infinity

(EditHint: Feel free to move discussions from ZeroOneInfinityRule here.)

Related to ZeroOneInfinityRule.

On computers with finite space, you can only give the illusion of being able to handle Infinity of anything. You can handle Zero of any number of things, and One of something provided it fits in the memory you have available, but you can only provide arbitrary numbers of things up to memory limits. Other considerations may also come into play; for instance, a network driver can only handle so many outgoing connections at a sane speed/without dropping them, a call stack can only grow for so many frames, or even such trivial things as "The screen has only so much space."

This does not mean that the ZeroOneInfinity rule should be disregarded; instead, when designing for an "Infinity" limit, one should choose a reasonable ApproximationOfInfinity as the capacity.

A good ApproximationOfInfinity has the following characteristics:

[roughly paraphrased from FixedQuantityOverflowBug:]

In all cases, you should code either as if your types were unbounded. If, and ONLY if, this is impossible, code against some arcane UPPER_LIMIT constant and comment the hell out of it.

If it's possible to use unbounded/dynamically allocated types, then use them.

If the data you store will never leave a single machine, you may use machine types, but make sure you use the biggest machine type. Use no type smaller than size_t or long int. Essentially, the upper bound here should be one which will never be reached in any practical use. (MooresLaw helps with this, since the limit tends to grow much faster than the reasonable set of values--see, for instance, the Unix 2038 [non-]problem.

If the data is persistent, try to use file formats with variable-length fields with massive upper bounds rather than fixed-length fields. This still might not solve the problem forever [what will happen when the field-length specifier overflows?], but it will solve it for longer.

If the limit is for legitimate performance reasons, i.e. hard real-time applications, then treat it as a hardware limit.

If a hardware/real-time limit would ever be reached for reasonable, practical reasons, order more hardware. HaHaOnlySerious.

Examples of good ApproximationsOfInfinity:

The EMail storage/users case is a particularly interesting one; while we could design the system so that the EMail space limits are invisible to the end-users, doing so would make it much harder to approximate infinity users (but on the other hand, if it was hard to change that amount, they wouldn't be able to provide extra storage space for money.) An important part of finding ApproximationsOfInfinity is determining just how close each Infinity has to be, which Infinities are related, and which Infinities are most important.

Characteristics of bad ApproximationsOfInfinity include:

Examples of bad ApproximationsOfInfinity: 2^63-1 --BottomMind


EditText of this page (last edited April 28, 2014) or FindPage with title or text search