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

Milestone 1

Requirements for milestone1:
Create a series of classes which will allow us to create a Form that is a mathematical equation.

Additional files needed for milestone1: to display Greek Symbol. (Note: you'll need to filein and execute Ypatia installAsTextStyle in workspace to install it.)

UML diagram for milestone1
CRC cards for milestone1

Analysis of design and description of classes:
In this project, I created 6 classes: GreekSymbol, MathEquation, MathFraction,MathOperation, MathSubscript and MathSuperscript.

The class methods of the above classes (except MathEquation) will return an instance of the class itself which is a displayable mathmetical object. And from: is a message understood by class MathEquation. The argument of message from: can be a string or a math object, if the argument is a string then just return a displayable Form. If the argument is a math object, then the math object's instance method makeForm is invoked.

Each individual class (except MathEquation) has an instance method makeForm, when it's invoked it will check whether the object is a string or math object, if it's a string, just return it as a displayable form, if it's a math object, just invoke the math object's makeForm.

What we learned and what we need to do for the later milestones:
At the beginning of the design stage, I was pretty confused about "what does each thing return? " and "who calls what?" types of questions. A typical thought of procedural language.

For example: What should (MathFraction from: 'sin(x)' over: 'x') return? It could be a form. But the size will be fixed,so if this form is a superscript in the next message and then we can't make it small. So I designed to let it return an instance of the class MathFraction, holding the numerator and denominator as instance variables.

Regarding to at what point do we convert it to a Form (or something else) and who should do it, I designed to let the object itself to do it, in this example let the fraction to represent a fraction as a Form. Then we can send messages to mathFraction object and let it display itself at whatever size.

Now I got the Form for any given piece of the equation, and the Form understand the message boundingBox which will tell the size of itself. At this point,given the size of any Form, and having the desired equation (e.g., what's a superscript, what's a fraction),it's easy to figure out where things need to sit in order to create the right equation.

The only problem for the milestone1 was that for mathOperation, I didn't have time to make the alignment well, the operator is not sit on the right position. And we can easily fix this problem in the later milestones.

Some testing scripts and results:
note: type the following code in workspace, hit alt-d, and the form will be displayed on the upper left corner of the squeak window.

Link to this Page