I have a class that requires a large number of properties for initialization:
Hand hand = new Hand();
hand->skinColor(Color(0.5, 0.5, 0.2));
hand->indexFingerLength(0.5);
hand->middleFingerLength(0.6);
hand->ringFingerLength(0.55);
...
hand->init(); // Builds the hand model
These properties are only valid to modify up until the call to init(), which uses them to build the class. The problem is that these properties can still be modified after the call to init() to no effect, an interface which could mislead the user to think that they will have an effect.
Is there a better way to refactor this other than moving all the properties into an argument list for init()?
1 Answer