home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:18230 comp.lang.c++:17839 comp.misc:4553
- Path: sparky!uunet!spool.mu.edu!agate!ames!kronos.arc.nasa.gov!butch!netcomsv!ulogic!hartman
- From: hartman@ulogic.UUCP (Richard M. Hartman)
- Newsgroups: comp.lang.c,comp.lang.c++,comp.misc
- Subject: Re: What is Object Oriented Programming? Is C doomed?
- Message-ID: <730@ulogic.UUCP>
- Date: 11 Dec 92 22:37:36 GMT
- References: <Byx59B.5v5@news.cso.uiuc.edu> <1g40m9INNdhk@uwm.edu> <1992Dec9.151051.3628@mcs.drexel.edu>
- Followup-To: comp.lang.c
- Distribution: usa
- Organization: negligable
- Lines: 47
-
- In article <1992Dec9.151051.3628@mcs.drexel.edu> tjhendry@mcs.drexel.edu (Jonathan Hendry) writes:
- >>Now you run into another problem. Prewritten code is FIXED. Code can't learn
- >>and modify itself and adapt. Sorry you're out of luck. Just put up, because
- >>modularity is supposed to be a Good Thing. In reality, it's a Goof Thing.
- >
- >Ah, but here is where OOPS shines.If a supplied object doesn't do what you
- >want it to do, just subclass it. That way, all you have to write is what you
- >want to add. You don't have to redo the whole thing. The subclass inherits
- >all the original class' behaviors and variables. You can add or change whatever
- >you want. WITHOUT changing the original code. I've written tons of subclasses
- >of NeXTSTEP objects, and I've never needed to change the original code
- >(and couldn't if I wanted to)
-
- Not always. I tried subclassing NIH's LinkedList class and ran into
- tons of trouble due to the trick they pulled w/ the hidden dependancy
- between their .addFirst() and .add() member functions. I had to reduplicate
- entire functions from their source code to properly handle something that
- SHOULD have been subclassable (is that a word???).
-
- It is truly bizarre -- in the LinkedList::addFirst() member function
- there is a test: if the list is empty (size() == 0) they call LinkedList::add()
- which has special case code for adding the first node to an empty list!
-
- This should be the other way around, if .add() to an empty list, call
- .addFirst() (if you need to do anything special at all). As it was
- since .add() was virtual, I had to DUPLICATE their special purpose
- code in MY .add() routine because .addFirst() called MY .add() routine
- when it thought it couldn't handle the job! This entailed gaining access
- to what should have been private member fields of their linked list class!
-
- (note: the specifics of the problem may not be exact here -- I ran into
- this over a year and a half ago, kvetched, fixed it, and moved on. I am
- pretty certain it was a hidden dependancy between these two routines as
- described, but it could be some variant thereof....)
-
- OOP and C++ is NOT a "silver bullet", any more than "structured programming"
- was. It is a new tool that gives us the potential for things that were
- more difficult before, but in and of itself does NOTHING. That is the
- job of the software designer. If it is done poorly, it is done poorly
- no matter what the language or paradigm.
-
- -Richard Hartman
- hartman@ulogic.COM
-
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- Never speak in absolutes. It will always lead to trouble.
-
-