Software Design

April 3rd, 2003 7:25 PM

No matter how often I think about it, I’m always very impressed by Damian Conway’s programmer-friendly approach to his software design. The pinnacle of this, I believe, can be found in the API to his DFA::Cellular module.

The module is used to set up rules for a cellular finite automata. The cells are arranged in a grid, and each rule must specify what the next cell value is based on its current value and the values of the cells surrounding it. (This is how one might implement Conway’s game of life, for example.)

The really slick part is Damian’s attempt at making the API friendly for developing - he re-arranges the order of function arguments so that they might seem strange programatically, but end up being extremely concise visually in an editor:

                          '***' => ' ',

Assuming you can see that code snippet in a monospaced font, you will see that the current cell conditional data is spread across the first, second, and fourth arguments while the next cell value is the third argument. Strange when said out loud, but beautifully simple when looked at.