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

Summer 2003 Final Exam Review: OO Design Evaluation

OO Design Evaluation

You were hired to review the design and make suggestions for improvements on some object-oriented software. What would you say to each of the following and how would you fix any problems?

a. This class is the main class and handles many of the tasks.

Having one class being the main class is not a good idea nor is it OO style. This class ends up acting like a 'God' class and not distributing out its behavior. Responsibility, control, and communication are distributed in good design. Not one object does everything. The code is not reusable and it is very hard to test. Using delegation (an OO principle) would be a solution to this. ~Sabina Karkin
Good answer, Sabina Barbara Ericson

b. We named the Warehouse class Ware becuase it is easier to type.

Abbreviating class names is a bad idea because they need to be explanatory and non-ambiguous. If a person sees "Ware", "Warehouse" doesn't immediately come to mind. Thus, it would be confusing as to what that stood for. Also, a class name should be a noun. It should be left as "Warehouse". ~Sabina Karkin

c. We are getting tons of code written becuase there are things we can just copy from similar classes.

Copying code from similar classes is a bad OO design. There should be no redundancy in OO programming. Abstraction would be a solution here, to abstract the code that's used in multiple places and inherit from it. ~Sabina Karkin

Actually copying code is bad in procedural programming too. Anyone want to say why? Barbara Ericson

You have to change the code everywhere you copy/pasted if it has to be changed. Big Kang

Right Big Kang, Barbara Ericson

d. We had one class inherit from another becuase the one class needed to access some information in the other class, but we had a problem that some of the inherited methods didn't make sense so we overrode them.

A Subclass should be basically a specialization for its base class. Association should be used in this situation instead of inheritance. It is always bad if a base class cannot be directly substituted by the subclass. Big Kang & Dennis Antonio Delgado

Yes, Big Kang and Dennis, the subclass should be able to be substituted for the parent class and if not you shouldn't use inheritence but association (delegation). Barbara Ericson

e. We have a type attribute in the Payment class and then we case (switch) on the type to handle billing by credit card, purchase order, create a bill, etc.

This should be handled by subclassing Payment - then each class of payment knows how to handle billing, rather than checking the type. -Kerry

Right Kerry, anytime you see a case or switch on a type use subclassing instead. Barbara Ericson

f. We put most of the code into class methods and that way we don't need to create objects to do the work!

Sounds like these people sound pretty happy about their design. If it works well for them, then I wouldn't advise them to spend money and change it. timmy

Anybody care to reply to timmy? Is this object-oriented programming? If this software gets used and is maintained most of the cost will be in the maintenance. Is doing it this way easier to extend and maintain? Barbara Ericson

it's not OO. timmy

When is it okay to use class methods? Barbara Ericson

I would recode the whole thing Ryan

Why? Barbara Ericson

Because these people obviously didn't do OOA, OOD, and there OOP is not OOP, if there are these kind of design flaws then obviously the whole thing is a mess Ryan

Who said there were design flaws? Maybe they did some really good functional or procedural programming and decided to use classes as namespaces for their functions. timmy

If they are using classes to do procedural programming they aren't going to get the benefits of using objects by doing object-oriented programming. One of the benefits they won't have is encapsulation. Another is reuse. Another is it is easier to maintain. You should read the book "Surviving Object-Oriented Projects" which takes a good objective and researched look at the OO hype and does find that it can deliver on these benefits. See Object-oriented programming has moved out the of acedemic world and is now the mainstream. Even Microsoft has accepted it as the standard way to program. Barbara Ericson

You can get encapsulation with closures. You can get reuse with functions. Arguing about easier to maintain isn't really clear cut though. OOP makes all these things more approachable, but I don't like how some of the people above just accept that it's always the best on blind faith. Experience in applying all these paradigms is probably the best way to learn the advantages and disadvantages of using one in a particular case. There are times when prolog is going to help you find a solution faster than java, and there are times when lazy-evaluation makes for a clearer solution to a problem. But that doesn't make them the answer to every problem. timmy

Yes, timmy you can program anything in any language and in any programming style. You should choose the right language and style for the task at hand. But, object-oriented programming has gained popularity becuase it does help programmers write code that is easier to use, reuse, and maintain. Software is expensive to develop and even more expensive to maintain. The software industry doesn't have a great track record for showing that it can develop good quality software that meets users needs (some 50% of developed software never gets used). Object-oriented development doesn't replace procedural. You still use a procedural style to write the methods. Barbara Ericson

Link to this Page