Multiple Dispatch and the Visitor Pattern
Saturday, June 14th, 2008 Posted in Code Design, Design Patterns, Java, Lisp | No Comments »Following from my yakking about the state machine pattern, I've run into situations since where I've had a class which must react differently to different inputs, and thought how, rather than write a huge switch statement, or huge else-if with ...
Programatically Selecting Text Background Colour
Monday, October 22nd, 2007 Posted in Code Design | No Comments »Yesterday I was reminded of a little problem I had thought about before but never really solved: how to write a function to select the optimal background colour for any colour of foreground text so that the text can be read easily. An obvious ...
State Machine Inputs
Friday, October 12th, 2007 Posted in Code Design, Java | 1 Comment »The other day I was thinking about state machines. More specifically, the best way to write a class such that when some "input" method of the object is called, the object acts differently depending on which state it is in. The ...