Tim\'s picture      Blogging Ottinger (tim)

2005-September-22

Only three important numbers

I’m amazed how much RDBMS design is just design.

The old story (sorry I can’t attribute it) is that there are only three important numbers in database design. They are zero, one, and many. One of something means an attribute of some other entity, maybe a single foreign key column. If there are two, a normalized design will have a table for the two of them and linkage back to the original.

Likewise, in OOD you need to consider these three numbers as being the only three meaningful numbers.

If something occurs not at all, you don’t code it. Period. Don’t leave room for it, don’t mess with it, don’t clutter your mind with it. A non-occurring item needs no programming to support it. Not one class, not one method.

One matters. Something happens, something exists, something needs to be done. Oh, sure, you could treat ones as simple cases of many, but that leads to overly complicated code and design. You’ll end up creating interfaces and classes you don’t need, lists iterators you should never have included, wasted time looking for empty sets. Why bother? One is one. You don’t need much help to deal with it.

Two or more are all “many”. If there are “many” (two plus) implementations of some thing, then your OOD should have an interface. If there are many implementations, you need an interface. If there are many items at once, then you should look at a Composite Pattern (GoF) or at least at a list. In the ObjectMentor payroll example, there are many ways to calculate a payroll and many ways to deliver a paycheck. Three is many because it’s more than one. Your design won’t change all that much if there are a dozen, or a hundred. Many defines your structure.

Many matters because often the two you see are just the two which you’ve seen so far… more are on their way. If something has evolved two versions, what makes you sure it won’t evolve a third? Or more? Why do you think you’ll only have two reports, or two ways to enter a number, or two of anything else? Two is not a significant number. The numbers are 0, 1, and MANY. Others don’t matter.

Now, in your code you may have to set cardinality limits. In your optimizations, knowing actual numbers will matter. But in structuring your code, it really is just the Big Three.

Comments »

The URI to TrackBack this entry is: http://tottinge.blogsome.com/2005/09/22/only-three-important-numbers/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.

Get free blog up and running in minutes with Blogsome | Theme designs available here