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 - Izudin Ibrahimbegovic

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. This is very poor desing and it poses a lot of problems if any calculations have to be performed on the individual shapes. An example of this is area or circumference formulas. These shapes are hardcoded in the above example and the addition of new objects is very difficult. One solution would be to have a Shape superclass and create subclasses from it. The superclass should have all the common methods like name of the shape but the subclasses should have the specific methods like area and circumference.

2. Inheritance should only be used if there exists an "is a" relationship and a Box is in no way a Pen therefore a Box should instantiate a Pen object and use it instead of extending from it.

3. Whenever code is copied to a lot of different classes, that usually means that something more efficient could and should have been done. Inheritance is a better option and would save a log of code from being written and also would allow for a better design.

4. The principle of Object Oriented desing is to break up methods into more specific methods and to break up objects into its subobjects in order to allow for a better design and also make modifications easier to put in place and implement.

5. "EditBackground" does not sound like an object and therefore should not be a class but a method in slide because it perfroms operations on the slide.

Links to this Page