Hi
I have a design question about the evolution of an object (and its state) after some sequence of methods complete. I'm having trouble articulating what I mean so I may need to clean up the question based on feedback.
Consider an object called Classifier. It has the following methods:
void initialise()
void populateTrainingSet(TrainingSet t)
void pupulateTestingSet(TestingSet t)
void train()
void test()
Result predict(Instance i)
My problem is that these methods need to be called in a certain order. Futher, some methods are invalid until a previous method is called, and some methods are invalid after a method has been called. For example, it would be invalid to call predict() before test() was called, and it would be invalid to call train() after test() was called.
My approach so far has been to maintain a private enum that represents the current stateof the object:
private static enum STATE{ NEW, TRAINED, TESTED, READY};
But this seems a bit cloogy. Is there a design pattern for such a problem type? Maybe something related to the template method.