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

Spring2004 Midterm Review: Design Critique

1. instead of doing case testing why not use inheritance, make a general superclass that has shared methods and define what each method would do in each sublcass. the problem with the question is that it will be more complicated to add a new type of shape to the code.

2.a box doesnt act much like a pen so the box shouldnt inherit from pen.

3. instead of copying, think of ways to reuse your code

4. not object oriented

5. maybe make the class background and have edit methods in it.
- An object should be a noun, EditBackground has a verb connotation

1 We decided to have one shape class and have a type attribtue which can be "Circle", "Rectangle", "Triagle". We have to case on the type to figure out what to draw. Later we need to case on the type again to output the postscript.
That 'type' attribute ignores the power of polymorphism. All shapes should have a draw and a postscript method that they've overwritten with their behavior. The parent class would have a dummy version which just throws an error saying that the children must implement it.

2 Boxes need to use a pen so we had Box inherit from Pen.
inheritence implies an is-a relationship. Composition implies a needs-a relationship. That's what this is describing, so Box should simply contain a Pen that it uses when needed.

3 We got lots of coding done because we were able to copy code to many different classes.
The data that was copied should have been encapsulating in some other class that all of these classes needing that code called upon.

See the first answer to this one. The question is about code copying, which usually suggests that inheritance or delegation would have been a better choice. Maintaining multiple copies of the same code is usually a disaster waiting to happen. Rich LeBlanc

4 We really only needed one "main" class and a couple of helper classes.
This is a very procedural statement. What is "main"? I've never heard of it. Separate out the elements of "main" into classes that have meaningful names.

5 We call the class that edits the image part of the slide "EditBackground".
Two things wrong here: 1) That class name is a verb. Class names should be nouns. 2) The name doesn't fit with what it does. You probably are looking for something like ImageEditor that stores a modified Image for Slide.