Some code using the command pattern and other decoupling techniques.