Search the web
Sign In
New User? Sign Up
extremeprogramming · Extreme Programming
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
implementation inheritance   Message List  
Reply | Forward Message #67051 of 152305 |
Re: [XP] implementation inheritance

Kay A. Pentecost propagated the following meme:
> I understand how implementation inheritance works in other languages... but
> so far I don't see if or why VB's lacking it is so bad, because I'm still
> ignorant of a lot of OO things...
>
> I'd like to hear comments on either side... anyone have any?

(Note: I'm a Java hacker mostly, this is written from that prejudice. I'd
be especially interested in the point-of-view of someone who commonly uses
an object-system like CLOS, which uses generic functions instead of
message-passing)

Interface inheritance is the most important kind of inheritance. It's the
cornerstone of Polymorphism - the idea that objects can be treated alike
because they respond to the same messages.

Implementation inheritance is a convenient shortcut. It's saying "because
I'm inheriting the interface of my parent, it's most likely I want to
behave in mostly the same way, so I'll respond _the same way_ to these
messages unless I'm specifically told otherwise."

Implementation inheritance is convenient, but it comes with a number of
important shortcomings that you have to keep in mind. It is far less
flexible than pure interface inheritance, and it often ties you to the
details of your superclass's implementation, breaking encapsulation.

The other problem is that in most languages[1], an interface implies, but
_can not enforce_ a set of contracts that the class is expected to
obey. If you inherit an interface, your class is expected to be able to
polymorphically substitute for its superclass, so it needs to obey the
same contracts as its superclass. A subclass should be a _specialisation_
of the superclass, its behaviour a subset of the superclass's behaviour.
If that is not true, you shouldn't be inheriting its interface.

Sometimes, I think that it was a mistake to join implementation and
interface inheritance as closely as has been done. That said,
implementation inheritance has its place. It's not essential for OO,
but it does save a lot of typing (and duplication) in common cases.

Charles Miller
[1] i.e. those without built in design-by-contract
--
Contributing to the Heat Death of the Universe since 1975.
http://fishbowl.pastiche.org -- -- The Weblog



Sat Dec 7, 2002 3:10 am

carlfishie
Online Now Online Now
Send Email Send Email

Forward
Message #67051 of 152305 |
Expand Messages Author Sort by Date

Hi, Everybody, In Steve Quinlan's interesting article at http://www.exoftware.com/newletter/issue3/newsletter_3_content.htm#Article2 it says: <quote> We did...
Kay A. Pentecost
tranzpupy
Offline Send Email
Dec 6, 2002
7:39 pm

This issue (not in VB, but Java) has been a hot issue at our office this week. One engineer is constantly saying "Favor Composition over Inheritance"....
David Corbin
david_corbin
Online Now Send Email
Dec 7, 2002
12:59 am

... group ... Unkie Bob has pointed out that the Observer Design Pattern needs II to remove duplication. Hordes of programmers are writing millions of lines of...
Phlip
phlipcpp
Offline Send Email
Dec 7, 2002
2:17 am

... CLOS isn't all that different in principle from implementation inheritence in Java (or #includes if you're feeling bitchy), but involes a lot less...
Bill de hÓra
bdehora
Offline Send Email
Dec 7, 2002
4:46 pm

... The problem with generic functions isn't necessarily with knowing what the first method which will be invoked is; it's knowing what the next method invoked...
Chris Hanson
cmh23
Offline Send Email
Dec 9, 2002
2:07 am

... <snip> ... He was probably referring to the concept of object composition vs. class inheritance. Goodness or badness is often in the eye of the beholder,...
Olson, Curtis B
gullywompr
Offline Send Email
Dec 8, 2002
7:07 am

... There are two common patterns I see where inheritance is misused. I see lots of people that confuse is-a and has-a relationships. Inheritance is taxonomy;...
Chris Hanson
cmh23
Offline Send Email
Dec 9, 2002
2:08 am

... I'm confused - a generic function works by calling the most specific method for the arguments supplied. What's the problem? ... And it still hasn't agiend...
Bill de hÓra
bdehora
Offline Send Email
Dec 10, 2002
4:25 pm

... (Note: I'm a Java hacker mostly, this is written from that prejudice. I'd be especially interested in the point-of-view of someone who commonly uses an...
Charles Miller
carlfishie
Online Now Send Email
Dec 7, 2002
3:10 am

Hi, Kay, ... I think the magic phrase is "programming by difference." In VB if you have a Widget class and suddenly need a SpecialWidget, your choices are...
manaster@...
cmanaster
Offline Send Email
Dec 7, 2002
11:31 am

I _used_ to do most of my programing in VB6. ... Yes that is one way, that probably gets used far too often, resulting in a horrible spagetti of code. ... When...
uk_mjs <xp@...>
uk_mjs
Offline Send Email
Dec 7, 2002
6:49 pm

Hi, Mark, ... Sometime in the future, I too will be able to say that!! (I hope!) <grin> ... That was mostly what I saw done. ... I'm not completely following...
Kay A. Pentecost
tranzpupy
Offline Send Email
Dec 7, 2002
8:21 pm

... Mmm... Proper Inheritence- class A { void foo(){println("foo");} } class B extends A { void bar(){println("bar");} } Another kind of Inheritence- interface...
Bill de hÓra
bdehora
Offline Send Email
Dec 7, 2002
8:25 pm

Hi, Bill, ... Lemme see here, now.... the a.foo method prints "foo".... so far so good. ... Now b.bar prints "bar" right? (Remember I'm an OO baby... ) and...
Kay A. Pentecost
tranzpupy
Offline Send Email
Dec 7, 2002
9:24 pm

... Exactly. ... Yep, and that's not a bad thing. The best you can say about 'extends' is that it saves you some keystrokes. It a) adds no power to a...
Bill de hÓra
bdehora
Offline Send Email
Dec 7, 2002
9:37 pm

Hi, Bill, ... As the people on this list who are using it seem to.... ... Thanks, Bill, this is helpful! Kay...
Kay A. Pentecost
tranzpupy
Offline Send Email
Dec 7, 2002
10:02 pm

Hi Kay, ... the ... of ... _didn't_ ... well ... class ... And ... IEmployee_GetStartingDate_GetRate? ... I'm ... Employee ... Employee ... through the ... ...
uk_mjs <xp@...>
uk_mjs
Offline Send Email
Dec 8, 2002
8:24 am

Hi, Mark, This is great! Very helpful. I have another question, but it will have to wait for tonight! Kay...
Kay A. Pentecost
tranzpupy
Offline Send Email
Dec 8, 2002
6:13 pm

Hello all. Please forgive this late entry - it seems to be taking up to 48 hours for my posts to reach this list. ... <snip> ... We use a tiered VB...
Olson, Curtis B
gullywompr
Offline Send Email
Dec 10, 2002
4:50 am

Hi Kay, Thanks for reading the article. Having mainly used C++ and Java on my XP projects, I wondered if I would miss implementation inheritance when I had to...
Steve Quinlan <squinl...
steveq_xpsig
Offline Send Email
Dec 7, 2002
1:23 pm

... Nice article. Your problem is that you're comparing the quality of the VB6 code you're writing to the quality of code *you* write in other languages. If...
jeffgrigg63132 <jgrig...
jeffgrigg63132
Offline Send Email
Dec 7, 2002
3:07 pm

... I do like implementation inheritance, and frankly I don't concern myself all that much with LSP and the like. Still, in the case you mention above, might a...
Ron Jeffries
RonaldEJeffries
Offline Send Email
Dec 7, 2002
3:17 pm

... Perhaps. But the list of public methods supported by the classes is unbounded. (It's not just "view", "edit" and "save".) So I think we'd have to either...
jeffgrigg63132 <jgrig...
jeffgrigg63132
Offline Send Email
Dec 7, 2002
3:59 pm

... I understood you to be saying that on the subclasses you only implement one method. That was the method I was thinking would be implemented by Strategy...
Ron Jeffries
RonaldEJeffries
Offline Send Email
Dec 7, 2002
4:05 pm

... In the simplest case, the subclasses need implement only one (abstract protected) method, with one line in it -- returning a constant. By doing so, they...
jeffgrigg63132 <jgrig...
jeffgrigg63132
Offline Send Email
Dec 7, 2002
4:46 pm

... http://www.exoftware.com/newletter/issue3/newsletter_3_content.htm#Ar ticle2 ... duplicate code. ... user's group ... He ... not being ... languages... but...
Alan Shalloway <alsha...
alshalloway
Offline Send Email
Dec 7, 2002
9:32 pm

Hi, Alan, ... Ah! ... I'm *getting* an understanding of design patterns... I started the GoF book, and then started Bertrand Meyers Object Oriented Software...
Kay A. Pentecost
tranzpupy
Offline Send Email
Dec 7, 2002
10:02 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help