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

Discussion 4 - Stephen Ake

From the Summer 2003 Midterm Review:

What is wrong with the following and how do you fix it?


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.
2. Boxes need to use a pen so we had Box inherit from Pen.
3. We got lots of coding done because we were able to copy code to many different classes.
4. We really only needed one "main" class and a couple of helper classes.
5. We call the class that edits the image part of the slide "EditBackground".

  1. The different shapes have fundamental differences in how they need to be displayed and drawn. This object model does not extend well if other shapes needed to be added, either. Shape should be a superclass, and Circle, Rectangle, and Triangle should all be subclasses that inherit from Shape and override its methods.
  2. Box does not need access to Pen's methods and variables, rather, it just needs to tell Pen to draw something. It needs to delegate Pen, not inherit from it.
  3. If code is copy and pasted extensively with only few or no modifications, then there is a lot of redundancy in the object model. The few modifications may better be used as modifiable flags as parameters to the one method of the frequently used code.
  4. The premise of OO programming is to split up all responsibilities into different classes. Keeping all the functionality in one "God object" is inherently bad design. The responsibilities in the one large class need to be identified and delegated to new actors.
  5. The method 'EditBackground' that edits an image assumes that the image is the background. While this may be true for this implementation, it does not take into account how an image in the foreground needs to be edited. The method should be renamed 'EditImage' or similar.

Links to this Page