Tuesday, June 20, 2006

Avoid Null

You can't make something out of nothing? Well, if you're an Agile-mentor-alist, then that's exactly what you do, but programmers shouldn't try to cash in on this skill. In programming terms, a nothing, or null, is of no use. They should be avoided. In particular, as they can sometimes cause crashes, they should be avoided at all costs, regardless of common sense. Here are some null-avoiding-patterns:
  • Where the language allows reference types to be null use an irrational metaphor to guarantee non-nullness
  • Replace null with zombies
  • Replace optional parameters with every permutation of the function with fewer parameters, all mandatory
  • Invent values
  • Absorb all exceptions and pretend not to crash
Customers wouldn't pay for nothing, so why program with it? Mind you, customers wouldn't pay for over engineering in the most subtle and pointless of pernickety style.

0 Comments:

Post a Comment

<< Home