From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,b87849933931bc93 X-Google-Attributes: gidfac41,public X-Google-Thread: 109fba,b87849933931bc93 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,b87849933931bc93 X-Google-Attributes: gid1108a1,public X-Google-Thread: f43e6,b87849933931bc93 X-Google-Attributes: gidf43e6,public X-Google-Thread: 114809,b87849933931bc93 X-Google-Attributes: gid114809,public From: Prashant Gupta Subject: Re: What is wrong with OO ? Date: 1996/12/06 Message-ID: <32A87421.6B38@bbt.com>#1/1 X-Deja-AN: 202730680 references: <5883q1$oae@news3.digex.net> <589i82$g1k@cpcug.org> content-type: text/plain; charset=us-ascii organization: BroadBand Technologies Inc. mime-version: 1.0 newsgroups: comp.lang.c++,comp.lang.smalltalk,comp.lang.eiffel,comp.lang.ada,comp.object,comp.software-eng x-mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4m) Date: 1996-12-06T00:00:00+00:00 List-Id: H Brett Bolen wrote: > > I think that Inheritance struggles against Encapsulation. Instead > of a function being in a single file, it is spread out over > two, three or sometimes even 10 files ( depending upon the > 'inheritance lattice'). Sometimes i find myself questioning which > of the 11 virtual functions do i need to fix. > On the contrary, I think careful use of inheritance promotes encapsulation. In any case, I don't think encapsulation means that all the code will be in a single "file". After all, using separate text files for different subclasses is just an implementation detail specific to the language (eg C++). Encapsulation simply means that logically related concepts, namely the data and the operations that can be performed on the data, "live" together within a logical entity. How that logical entity is stored on a physical device is an entirely different matter. An inheritance hierarchy is certainly a well defined logical entity within the OO paradigm where all of the polymorphic methods can live. Let us say we have an abstract superclass (base class) called "Automobile" which provides a method called "Automobile>>#driveTo:" [ Automobile::driveTo(const Destination *) ]. The actual implementation of the method needs to be deferred to the concrete subclasses (derived classes) because 4speed/5speed/Nspeed/automatic transmission vehicles would presumably work differently. Now even if this "driveTo" method is implemented differently in 25 concrete subclasses, I don't see how that violates encapsulation. More importantly, how would it promote encapsulation if we were to not use inheritance and instead construct all of the concrete classes from scratch. Wouldn't that require duplication of code that is common to all Automobiles. Wouldn't that be a violation of encapsulation in a sense. > > 'Whats wrong with C++ and OOP?' is a way different question. No argument there. :-) Prashant Gupta. > -- > b\253 | Take Chances, Make Mistakes > brettb@cpcug.org | Get Messy > brett bolen | - Ms Frizzle - MSB > Walrus Consulting | http://www.cpcug.org/user/brettb -- The opinions expressed here are mine and do not necessarily reflect the opinions of my employer. ---------------------------------------------------------------------- Prashant Gupta mailTo:pg@bbt.com (919) 405 4884 ----------------------------------------------------------------------