Monday, March 16, 2009

Too Much Choice

An interesting point about choices.
One of my dislikes of Perl is this very thing - lots of way to do X leads to programs that use every way to do X in them.

One of the ways that choice makes our jobs harder is that every option needs to be validated somewhere in the code.  Often this gets translated into masses of checks for all the options at every point of action.

Instead of this, you should strive to have things checked at the earliest opportunity, and then have the rest of your code assume that anything past the checks is valid and right.  This limits your exposure to change, and makes the rest of the code flow smoother.  It does tend to collect your checking code in the UI (or the interface to the UI), but it's a lot easier.

This also applies to the UI - don't give the user every option if they aren't all valid.  Trim your menus of unactivated features; hide the checkboxes of custom features for the other customers.

Technorati Tags --
, , ,


Brian Tkatch said...

Thanx for the link.

And nice comment on bounds checking first. I have made the same comment myself, though i consider it more of a personal style.

Dixie Software Ninja said...


It's mroe than bounds checking - it's feature limitations - if you have certain account types that are only valid if a certain feature is enabled, put the checks as far forward as possible, so that rest of the code does not need to check for the feature.