programming by exception

S'pose you realize you're in the market for an embedded DSL that, let's say, controls a natural gas pipeline system. One approach is just to start writing things you want the language to be able to handle--for example,

    set valve(Pittsburgh,18,1349) open
    puts "Flow in critical link is $flow(Valdosta,7,88)."
    if [string equal open ...

But wait! This is valid Tcl already! Let's figure out what the output from such a sequence should be, and we immediately have a case that can be coded directly in tcltest. Now all that remains is to implement (just) enough to pass the test we've composed. This is TDD with a vengeance!


lexfiend 3 Mar 2006: AFAICT, that term is generally used to mean:

  • a specific inheritance model -- method behavior defined in a subclass overrides that defined in the parent class, or
  • a (possibly excessive) reliance on exception-throwing to determine your program's logic flow

I'm not sure how the above example fits either definition.


Category Glossary