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

Sum2003 Midterm Review: Design Critique

1. You would want to make an abstract class Shape which has can draw and output the postscript. Then have Circle, Rectangle and Triangle subclasses.

2. Box should have an instance of pen and let pen keeps its actions. A box is not a type of pen, so it should not inherit from it.

3. You should extract the functionality into a class or method (depending on situation), therefor it will be easier to change later on.

4. This is also know as "God and Angels" and it is very bad. You need to delegate more of the responsibility to other classes or rethink your design. (Maybe you need more abstraction).

5. Depending on what this class does, it should be renamed. Right now it sounds like a method name, because it could do more than just edit the background. A better name would be ImageEditor.


Good answers Laurena and Dennis. On 5 remember that class names shouldn't be verbs and should be descriptive of their responsibilities. Barbara Ericson

1. It is bad to have one shape class because you can have multiple different shapes so it's better to design an abstract Shape class that has an abstract method draw. Then create subclasses Triangle, Circle, and Rectangle which inherit from Shape and have their own draw methods, overriding the draw method in Shape class.

2. Box should not inherit from Pen because Box is a not a Pen. Boxes draw themselves using a Pen class, so a Box has a Pen. Therefore, Box class should hold an instance of Pen. This way, some services that Box instance does not need to know about get passed on to the Pen instance (delegation).

3. Copying code is a waste of time and it makes it hard to reuse the code later on. Therefore, the code should be extracted and let other objects inherit from it.

4. Having one main class and a couple of helper classes is not object-oriented programming. You need to create more classes that have their own responsibilities so that not everything depends on one class.
distribute responsibility Barbara Ericson

5. Class name should be a noun, not a verb (action). EditBackground sounds like an action so it should be renamed to something like ImageEditor, a noun.
~Sabina Karkin
Good answers Sabina Barbara Ericson

Link to this Page