I have the following situation. I have a factory method that returns a matrix. This matrix can be calculated at two levels of accuracy: level1 and level2. In order to calculate the matrix, I need to pass a bunch of information to the factory method, and this information is nicely packed in another object Info. Info is passed to the factory method, and the matrix is returned.Info contains details that are needed for both levels of accuracy. a set of these details are used only by level1. If level2 is needed, info must contain additional data which are used to evaluate level2 accuracy.I have two strategies to perform the decision:I pass the Info object to the factory method. If it finds the info for level2, it computes level2 accuracy. If it finds only info for level1, it computes level1.you pass the factory method both the Info data and the requested accuracy level, then use only the Info contents useful for the appropriate level. There may be a case where level2 is requested, but Info does not contain any level2 information. In that case the program will throw an exception.Which option would you consider better ?
using the presence of a value to control flow?
design
I would go with the second option. I would think it's up to the calling function to decide what level it wants, and also if that level is appropriate (it's the caller's responsibility to ensure that if it requests level2, the request can be met with the Info object it gives).Some pseudo-code of how I'd write it:if /*there's enough data in Info for level2*/ then    matrix := MatrixFactory(Info, level2);else    raise NotEnoughInfoForLevel2Exception;    /*    of maybe you could do     matrix := MatrixFactory(Info, level1)    or something else to handle this problem    */end