Path: utzoo!attcan!uunet!mcsun!ukc!servax0!ese!goss From: goss@ese.essex.ac.uk (Gossain Sanjiv) Newsgroups: comp.lang.smalltalk Subject: Re: When to make a parent class Message-ID: <1596@servax0.essex.ac.uk> Date: 3 Sep 89 11:28:11 GMT References: <760@swbatl.UUCP> <80500072@p.cs.uiuc.edu> Sender: news@servax0.essex.ac.uk Reply-To: goss@ese.UUCP (Gossain Sanjiv) Organization: University of Essex, Colchester, UK Lines: 40 Article 419 in comp.lang.smalltalk: From: johnson@p.cs.uiuc.edu Subject: Re: When to make a parent class Message-ID: <80500072@p.cs.uiuc.edu> Date: 2 Sep 89 23:03:27 GMT References: <760@swbatl.UUCP> Lines: 24 In a recent article, <80500072@p.cs.uiuc.edu> Ralph Johnson says.. >> I am making a new class and have defined most of the important methods. >> ... I find a class (foo) that has almost every thing >> that my new class needs except there are several methods that I definitely >> do not need in my new class. >> Do I 1) make my class a sub class and stub out the methods that >> don't fit, 2) go above foo and put a new class between foo and its parent >> and leave out the methods that I don't need for my class and then sub class >> off of this new class, or 3) do something else ? > It depends on what you are trying to do. If you are rapid-prototyping > then you make it be a subclass and ignore the extra methods. If you are > trying to make an elegant design then you build a new abstract superclass > of the two classes. This is the standard way of finding abstract classes. Dr. Johnson is perfectly correct in what he says here. The process of finding abstract classes is not an easy one, but allows one to structure a class hierarchy in an elegant and, sometimes more importantly, comprehensible manner. > If you just keep subclassing and never reorganize your hierarchy then > you will end up with a very ugly set of classes. You have to clean things > up periodically to keep your design elegant. I think that people who use OO languages, should be aware of the need to restructure and "clean up" the hierarchy as more classes are integrated into it. There is nothing wrong in having to redesign existing classes in the light of additions to the hierarchy. Sanjiv Gossain