Direction of the Inheritance Arrow

In visual representations of object oriented software designs, people traditionally draw subclass relations using an arrow that points from the subclass to the superclass. This seemed strange to me when I first learned it -- intuitively it seemed like the arrow should go the other direction. I remember reading a justification somewhere, based on the argument that subclasses "knew about" their superclass, but not vice versa. That argument always seemed weak to me.

However, I just realized that the direction of the arrow actually corresponds to implication in logic. In particular, the Liskov Substitutability Principle is exactly the same as Modus Ponens.

Cute.

Posted on June 7, 2006 08:23 PM
More languages articles

Comments

Of course, in Haskell code, the "inheritance" arrow goes in the other direction - from superclass to subclass. So it means "is implied by", even though it looks like "implies". This irritates me.

Posted by: Robin Green at June 9, 2006 02:16 PM

Robin, I'm not sure what you're referring to. The only arrows I know about in Haskell are "->" which is used for functions (very similar to implication in a constructive proof), and "=>" which is used for type constraints (also similar to implication, in that if you meet the constraints, then the consequent holds).

The closest thing I know of to inheritance in Haskell is typeclass inheritance, and that's specified using "instance" declarations rather than arrows. Can you clarify what you mean?

Posted by: Kim at June 12, 2006 07:21 PM

I thought it was odd, too, the first time I saw it. But it turns out that "weak" reason you cite is actually at the core of what makes UML useful.

In UML diagrams, there are three kinds of arrows:

- Association -- If Class A has a member whose type is Class B, a solid arrow is drawn from A to B.

- Inheritance -- If Class A is a subclass of Class B, a solid arrow with an open triangle arrowhead is drawn from A to B

- Dependence -- If Class A depends on Class B in some other way (e.g., Class A has a method with a parameter of type B), a dashed arrow is drawn from A to B

All of these are dependences: The specification of Class A relies on the existence of Class B, or "knows about it" as you put it. In programming language terms, the source code for Class A will mention Class B, but not vice versa.

It's very useful that all three of these arrows point the same way. It lets you reason about program structure by just looking at the diagram as a graph.

For example, if I'm compiling classes separately, in what order do I need to compile them? Answer: reverse topological order, considering all arrows.

If I'm building software in modules, do I have a cyclic dependence that will make it hard to maintain modules separately? Answer: draw dotted lines around the classes within each module, consider the reduced graph (again considering all arrows) and see if you've got cycles.

Having the arrows point this way also helps illustrate certain kinds of program transformations (aka refactorings). Examples:

- Dependence Inversion Principle (DIP): Martin Fowler's class example: a Copier class uses a FileReader and a FileWriter (solid arrows from Copier to each of FileReader and FileWriter). The Copier algorithm cannot be reused with other types of I/O. Refactored solution has Copier use a Reader interface and a Writer interface (solid arrows from Copier to Reader and Writer), with FileReader and FileWriter implementing the interfaces (solid-open arrows from FileReader to Reader and FileWriter to Writer). The "inversion" is visible in that the arrow on FileReader (or FileWriter) has now been flipped.

- Breaking a cyclic dependence by inserting an interface (very similar to DIP): A uses B and B uses A (solid arrows in both directions). If they need to go in separate modules, introduce an interface by having A use iB, which B implements. Now you've got a solid arrow from A to iB, a solid arrow from B to A, and a solid-open arrow from B to iB. Graph is now acyclic.

- Replacing inheritance with association. Class A was implemented as a subclass of Class B, but not because A is really a kind of B, but merely because A has a B and has some operations in common. In the improved code, A has a pointer to a B, and delegates methods as necessary. This frees A to inherit from some more appropriate base (e.g.). The arrow still points in the same direction, only the arrowhead has changed; this helps illustrate that the relationships have not fundamentally changed.

Of course, all of the above would still hold if you flipped around *all* the arrows. But while the direction of the inheritance arrow is somewhat counter-intuitive, surely the direction of the association arrow is not: if A has a B, everybody wants to draw the arrow from A to B since that direction coincides with the way we all think about "pointers".

This was an epiphany for me when I figured it out long ago, and it's one of the reasons I find UML so useful.

Posted by: Ken Traub at June 29, 2006 09:29 PM

Some systems maintain the distinction between specialization and generalization, based on the direction of the arrow: i.e. the order in which the classes are constructed, the direction of information flow, and dependency.

Specialization is a top-down selection of existing abstractions to combine and extend, but generalization is a bottom-up abstraction and restriction of common existing features.

Mik

Posted by: Mik at November 27, 2007 04:10 AM

I thought it was odd, too, the first time I saw it. But it turns out that "weak" reason you cite is actually at the core of what makes UML useful.

Posted by: free games at October 25, 2009 04:02 PM

Love this man. Great stuff, great prices, free shipping. Email him if you cant find what you are looking for and he will look for you. Good customer service.louis vuittonSomeone who is knowledgeable in louis vuitton.Another guy from hong Kong (Largest louis vuitton second hand city, I believe) he has great stuff at fair prices but his shipping is insane

Posted by: louis vuitton at October 29, 2009 10:09 AM

Love this man. Great stuff, great prices, free shipping. Email him if you cant find what you are looking for and he will look for you. Good customer service.louis vuittonSomeone who is knowledgeable in louis vuitton.Another guy from hong Kong (Largest louis vuitton second hand city, I believe) he has great stuff at fair prices but his shipping is insane

Posted by: louis vuitton at October 29, 2009 10:09 AM

Love this man. Great stuff, great prices, free shipping. Email him if you cant find what you are looking for and he will look for you. Good customer service.louis vuittonSomeone who is knowledgeable in louis vuitton.Another guy from hong Kong (Largest louis vuitton second hand city, I believe) he has great stuff at fair prices but his shipping is insane

Posted by: louis vuitton at October 29, 2009 10:09 AM

There is nothing that touches these for just lazing around at home. Bar sleeping I don’t take mine off now that its getting colder, they are not quite as stiff as they were when they first arrived but still extremely comfortable. It would be nice if they had a little more arch support but other than that I’m very pleased. I am finding a nice ugg boots!

Posted by: ugg boots at November 5, 2009 02:42 AM

Just wanted to say great job with the blog, today is my first visit here and I’ve enjoyed reading your posts so far

Mukluk boots

Posted by: Mukluk boots at November 5, 2009 02:43 AM

Everything dynamic and very positively!

NIKE

Posted by: NIKE at November 5, 2009 02:43 AM

Good work, thanks! My sister received the Mbt Health shoes I bought her for her birthday, she adores them. I was a little worried the calf would be tight around her legs but it hasn’t been a problem. I’ll be back before Christmas.


Posted by: Mbt Health shoes at November 5, 2009 02:44 AM

I think I will try to recommend this post to my friends and family, cuz it’s really helpful.

Thanks for this nice post, i like it very much, write this article more.Nike Air Max 2003 Shoes
.

Posted by: Nike Air Max 2003 Shoes at November 5, 2009 02:49 AM

Only One word to characterize such a great post “WOW” that was a very interesting read
Adidas

Posted by: Adidas at November 5, 2009 02:50 AM

Find Jeans ?!UGG boots On Sale ,Enjoy free shipping + bargain sale now!

UGG Classic Short,100% Authentic UGG Australia Boots!ALL of

Jeans are the cheapest and best for you!Enjoy yourself of shoping , Find Cheap Sheepskin
Jeans !



Posted by: Jeans at November 5, 2009 02:50 AM

We also supply other products such as:

Mukluk boots


Shoes


NIKE


Jeans


Handbags


Lacoste Shoes


Jeans


Watches


Handbag


Adidas


DVD .Welcome to order it.

Posted by: surprise at November 5, 2009 02:51 AM

Hey, i am very happy today, I received my Mbt shoes

just now, very impressed. They are like sort of a massive slipper, soft, easy to wear and

light.

Posted by: Mbt shoes at November 5, 2009 02:51 AM

There is nothing that touches these for just lazing around at home. Bar sleeping I don’

t take mine off now that its getting colder, they are not quite as stiff as they were when

they first arrived but still extremely comfortable. It would be nice if they had a little

more arch support but other than that I’m very pleased. I am finding a nice
mbt shoes sale!

Posted by: Mbt shoes at November 5, 2009 02:52 AM

Good day! Thx for your great post and Im thinking about how to introduce my ugg boots to you cos Im not sure if u like this. Many people who live in the cold area like the ugg boots, especially the north-europe. Our uggshare.co.uk supply the cheapest classic cardy ugg boots, class tall ugg boots, classic short ugg boots and other series of uggs, hope my words didn’t trouble u, cy!

Posted by: ugg boots at November 5, 2009 09:05 PM

Good day! Thx for your great post and Im thinking about how to introduce my ugg boots to you cos Im not sure if u like this. Many people who live in the cold area like the ugg boots, especially the north-europe. Our uggshare.co.uk supply the cheapest classic cardy ugg boots, class tall ugg boots, classic short ugg boots and other series of uggs, hope my words didn’t trouble u, cy!

Posted by: ugg boots at November 11, 2009 09:53 PM

Eliminating the need for the extra trouble to wear ugg boots uk
ugg boots saleuggs, in the extreme sports, look for happiness in life, with UGG Classic boots and nike sb showed off your tall body, do not worry about being laughed at, dancing new style ugg australia and nike sb dunk . The flavor of life that is colorful, there are Christian Louboutincheap nike dunksUGG cardy boots、and nike sb for sale also used fear to creep away money from your pocket Mody ? Love beauty, you might even love UGG Classic tall bootsUGG Nightfall bootsUGG Classic short bootsnew nike sb。There are an infinite high power drivers of popular front ugg boots saleugg saleuggsnike dunkdiscount ugg bootsnike dunk sb, our website also have UGG Nightfall bootsbutton ugg bootsbailey button uggugg button bootsbailey button bootsnike dunk midnike dunk highChristian Louboutin Boots, pick your favorite, do not hesitate!

Posted by: ugg boots sale at November 12, 2009 04:08 AM

Uggs on sale now.UGG Classic Cardy Boot makes me different form the other

girls. The UGG Bailey Button Boot is a good choice for female.

Posted by: ugg classic cardy boots at November 16, 2009 11:41 PM

Louis Vuitton , commonly referred to as Louis Vuitton Sneakers and Gucci Diaper Bags on Sale, or sometimes shortened to Canvas Handbags has become one of the most louis vuitton alexandra wallet Agendas luxurybrands Tiffany In Hongkong.

Posted by: 1 at November 17, 2009 01:41 AM

UGG Bailey Button bootsis a new style in 2009.The classic cardy uggs boots is another hot boots that worth of buying.And the classic tall ugg boots will make your winter amusing.And now uggs on sale,if you are looking for such a boot,the ugg boots is good choice this year.

Posted by: UGG Bailey Button Boots at November 17, 2009 02:03 AM

I love Women's UGG Classic Cardy Boot 5819 very much. And the new style UGG Mayfaire Boots is aslo a good choice this year.

Posted by: UGG Bailey Button Fancy Boots at November 17, 2009 03:13 AM

www.enjoywholesale.com

china wholesale clothing,china wholesale shoes,china wholesale electronics,china wholesale suppliers,china manufacturers

china wholesale products,light in the box,wholesale lots,wholesale ipod
china direct,china dropship,china trade,made in china

electronics wholesaler,ebay wholesaler,financial wholesaler
fashion wholesaler,clothing wholesaler,wholesaler magazine

computer wholesaler,external wholesaler,dvd wholesaler,wholesaler definition,china wholesaler,mutual fund wholesaler,define wholesaler,insurance wholesaler


discount ugg boots
forture
ugg boots
Discount store

Posted by: wholesaler business website, net shopping site, external wholesaler,dvd wholesaler,wholesaler definition,china wholesaler,mutual fund wholesaler,define wholesaler,insurance wholesaler at November 18, 2009 02:52 AM

lxjuan08ed hardyis a famous ed hardy store which sell directly ed hardy clothing, shoes, boots, swim suit and other cheap ed hardy.

Browse through our catalogue of hundreds of ed hardy clothing,Ed hardy Shirt,Ed hardy ... Buy Ed Hardy today for a gift, for a friend, or for yourself.

ED HARDY Online Shop,Ed Hardy Store by Christian Audigier,coach handbags,rolex watches.We supply cheapest Newest ed hardy discount 2009 Commodity New styles.


ed hardy sale

Posted by: ed hardy at November 18, 2009 08:14 PM

We are the best online sales for the china wholesale . Here you can have a large of choices of kinds Ugg Boots,Converse Shoes,Timberland Boots,puma shoes,Nike Shox Shoes ,Nike Dunk SB Shoes,Nike Air Max,Links Of London,Tiffany Jewelry,Dior Handbags?,jimmy choo handbags ,Cartier Watches, 8GB Mp4 Players,Bluetooth Car DVDs. All our cheap online cheap goods are high quality and original packages, and best service. We offer our customers the best service, 7 days arrive at your door.Enjoy your easy and happy shopping with us.

Posted by: cheap goods sale. at November 19, 2009 10:01 PM

Do you like sports? If you like it,the NIke Air Max TN and Nike Air Max 360 is a good choice for you.And now the there is a good news,CheapNike Air Max running Shoes is waiting for you.I think The New Nike Air MAX 2009 Running Shoes makes you great comfortable.

Posted by: Nike Air Max shoes at November 20, 2009 03:28 AM

Your article is write very well, I like it very much ~
ghd Hair Straightener
ghd Hair Straighteners
ghd straighteners
GHD
hair straighteners
bose in ear headphones
bose on ear headphones
bose headphones
nike sb dunks
nike dunks
I wish you have a wonderful day!Thank you.

Posted by: ghd straighteners at November 22, 2009 08:21 PM

Timeberland boots on sale now! Do you want moreTimeberland boots information?Just move your mouse and press it to our Timberland shoes online store.

Posted by: Timberland uk at November 22, 2009 11:13 PM

Laptop Battery Laptop Battery Laptop Batteries
Laptop Batteries discount laptop battery
discount laptop battery
notebook battery notebook battery
computer battery computer battery
replacement laptop battery replacement laptop battery
notebook batteries notebook batteries

Posted by: Laptop Battery at November 24, 2009 10:55 PM

People all over the world know the abercrombie and fitch,but not everyone really knows how fashion the abercrombie is,hollister is the Legend maker. Everybody wears the hollister clothing would be the abercrombie mens and the abercrombie womens, if you want know you can search the Ruehl No.925 or abercrombie outlet in the www.google.com .

Posted by: fitch at November 25, 2009 12:04 AM

Ugg Classic Cardy

Boots

Ugg Classic Tall

Boots

Ugg Classic Short

Boots

Posted by: topuggshoes at November 26, 2009 02:35 AM

Ugg Classic Cardy

Boots

Ugg Classic Tall

Boots

Ugg Classic Short

Boots

Posted by: topuggshoes at November 26, 2009 02:36 AM

chaoying nfl jerseys
Giants Jerseys
Patriots Jerseys
Packers Jerseys
These things are good, I hope you can continue to maintain!


Posted by: jerseysleague at November 29, 2009 03:43 AM

Paul Smith has been collaborating with a few different organizations recently and his latest venture sees him teaming up with Japanese bicycle saddle, Paul Smith bag, on a limited edition leather saddle. The release features Smith’s signature stripes where only 20 will be available at Paul Smith Clothing store in Japan and 8 at the Floral Street store in London. Get on it quick

Posted by: fafda at November 29, 2009 11:13 AM

Just wanted to say great job with the blog, today is my first visit here and I’ve enjoyed reading your posts so far
ugg bailey button
Wow, my ugg classic mini will not be coming off now! I’ve had them on for 12hrs strait and I do not want to take them off. Thanks for everything, well worth the wait.

Posted by: ugg bailey button boots at November 30, 2009 05:50 AM

Gucci is famous as top quality, Louis Vuitton Tivoli PM luxurious, modern, and sexy luxury goods. Louis Vuitton Replica Tivoli PM It is a symbol of status and wealth. From time to time, Gucci belt is favored by most of people very much.As we know, Gucci belts stand for fashion trend,
Louis Vuitton Tivoli PM Replica popular elements, culture, conciseness gucci and noble. As a gentle and fashion business man or woman, Gucci belt is your best choice. Gucci commercial belts adopt real leathers, and the leathers have high hardness, toughness and scratch resistant. Belt buckles adopt high quality CTB alloy, the golden and silver color of them will never be faded. You like casual clothes and belts, because casual living Speedy 25 lifestyles focus on the simple pleasures of life. We believe that you will not hesitate to choose Gucci belt. Gucci casual belts own fashion and lovely style, bright color. The material of belt is high quality real leather or durable PU leather. Therefore, if you own this kind of Gucci casual belt, you will become a popular star.

Posted by: fanqin at December 1, 2009 12:54 AM

uggs on sale
ugg classic tall

Posted by: ugg boots sale at December 1, 2009 02:55 AM

ugg boots sale at a time when large heat has set off a winter 08/09 to Ewha.Outlines the

warm wool winter fashion degree to wool crocheted wool ugg boots uk to join after the

body does not stimulate your skin soft, soft comfort UP. Fashion can not without
ugg boots presence in Winter.and ugg boots have many series.such as:
ugg classic
UGG Bailey Button boots
ugg nightfall
ugg kids

Posted by: uggboots at December 2, 2009 07:51 PM
Post a comment









Remember info?




Prove you're human. Type "human":