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

Fall2004 Midterm Review: Design Critique

1) It would be far superior to simply make a "Shape" class and extend the types of shapes from it, such as Circle, Rhombos, Octahedron, Dodecahedron, or whatever other shapes we might want to draw like Rubber Band Lines. This gives us the aded advantage of giving each shape their own set of methods that will handle the drawing, erasing, and other necessary tasks. This means we can simply call the same function on any Shape and not have to worry about its types. It improves the extensibility and mantainability of the code by allowing you to extend objects rather than modifying existing code in the form of switch statements, i.e. Lower the chance of breaking stuff and spending the whole damn night in States lab emailing the Squeak TA's hoping that someone will help because you decided to use some stupid switch-like statement.

2) It would be far superior to encapsulate Pen inside Box because Professor Leblanc said so (that is, a Box is not a pen).

yes, just to be a little more clear: a "needs-a" or "has-a" relationship implies some type of composition or encapsulation. inheritance should only be used when you can say "is-a" . -ellie

3) Copy-paste programming isn't gonna get anywhere, even PMD says so. If you have an error in one line, it will be reproduced over all the copies you made and will give you one hell of a headache. Plus, its not code re-use for obvious reasons.

yep, so if there's a lot of code that's the same, one way you might try to re-use code is through inheritance -ellie


4) That's just stupid. The fix is to break things up into smaller methods that each perform specific functions.

yes, having one "main" class and several "helper" classes is very functional/procedural. we'd like to separate things out into classes that represent objects that one might encounter in the "real" world (with better names please!), and divide functionality among said objects -ellie

5) Class names should be nouns. However, I disagree with the implication that naming a class a verb is a bad design technique. Using a command design pattern, this makes perfect sense. For the case of this test, however, they probably want it to be a noun like the book says.

there are perhaps occassions where "verb" class names are appropriate, but, classes should represent objects, hence in general they should have names that are nouns. classes should encapsulate both attributes and responsibilities. if you ever have a class that's only data or only methods, then you probably haven't designed your object model very well. A better name in this example might be "ImageEditor." -ellie


Link to this Page