0, 1, Many, a Zillion
There are only four numbers in computer programs:
0, 1, many, "a zillion"
If you have 2 or more of anything, you are, in general, better off using loops to process many of them.
But what is "a zillion?"
Zillion is a made-up number. Your system cannot hold a zillion items in memory. It cannot show a zillion items on the screen.
Doesn't work for "a zillion":
Select employee name:
Doesn't work for "a zillion":
def handleFiles( filenames: Array[String] ) { val results = openFiles(filenames).readAll().processAll() results }
Doesn't work for "a zillion":
Changing software from handling "many" to "a zillion" is hard if the program is already written.
Decide when you need to handle a zillion.
Try:
None, some, lots, zillions.
None: I don't need to worry about this.
Some: I don't need to be clever about this.
Lots: I need to be clever about this.
Zillions: I need to be very clever about this.
Consider the read & process example:
None: No files. Nothing to do.
Some: The naive approach above is fine.
Lots: OK so we need to read, process & discard in a loop.
Zillions: We need to implement multi-threading to avoid bottle-necks... (or whatever technological limitation you're pushing against).
Steve McConnell talks about the difference between application development and R&D.
R&D is the never done before & not sure it can be done domain of 'zillions'.
Two: Is basically a simple conditional.
Several: Is 3 or more, but less than 'Many'. This is basically a CASE, simple loop or drop down list.
I make the distinction between 2 and 3 because it is at this point you have to start thinking differently about how you approach a problem and the algorithm's you will use.
Otherwise totally agree.
VP trees: A data structure for finding stuff fast
Let's say you have millions of pictures of faces tagged with names. Given a new photo, how do you find the name of person that the photo most resembles?In the cases I mentioned, each record has hundreds or thousands of elements: the pixels in a photo, or patterns in a sound snippet, or web usage data. These records can be regarded as points in high dimensional space. When you look at a points in space, they tend to form clusters, and you can infer a lot by looking at ones nearby.