Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!wugate!uunet!dino!uxc.cso.uiuc.edu!uxc.cso.uiuc.edu!m.cs.uiuc.edu!p.cs.uiuc.edu!johnson From: johnson@p.cs.uiuc.edu Newsgroups: comp.lang.smalltalk 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 Nf-ID: #R:swbatl.UUCP:760:p.cs.uiuc.edu:80500072:000:1090 Nf-From: p.cs.uiuc.edu!johnson Sep 1 13:11:00 1989 E-mail is definitely NOT appropriate for this topic, which is of general interest. >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. 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. Ralph Johnson