View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Sum00 Final Exam Review: Redesigning the Math Equation Tool

(b) You could use a Factory method to decide what type of MathObject to give you based on the token as a parameter. For example, you parse a '\fract' and send that as a parameter into the factory. The factory then find the subclass that decides what to do, in this case a fraction subclass. That sublass would know to create a MathFraction with: over: and it would return that object.

Factories are worth a little more than that, Mike. I don't disagree with you, but it's important for the MathObject to define a protocol that all the subclasses will follow. That's what allows a client (some class using the Factory) to be able to say "Give me one of X, where I don't know X's class name. Now, I know that X will understand the messages A, B, and C, because all MathObjects do, and I'll never need to know X's class." That's the strength of factories. Mark Guzdial


Link to this Page