in reply to Re-using/changing a class

Why are you changing the behaviour of the class?

Depending on the problem, a pattern that may fit very well is to have a base class and several classes that inherit from it (each one being a "state") and then call bless to change your object from one class to another, to another and back to the first.

If you want a particular method to be doing one of several fixed things, this is probably a much cleaner solution than what you are using right now.

  • Comment on Re (tilly) 1: Re-using/changing a class