Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to represent it?

 
Rohan Deshmkh
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose Animal is a superclass And Horse is it's Subclass.
So Animal a=new Animal() would be shown as in diagram:


now i wanted to how can you represent
Animal a=new Horse()


 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply replace the word Animal in the picture by Horse?
 
Rohan Deshmkh
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then how can we differentiate between
Animal a=new Horse();
and
Horse a=new Horse();
digramatically?

Of course i know the difference between the two statements in general, i just wanted to know if in a diagram i replace Animal with Horse.
How can i know whether it represents
Animal a=new Horse();
or
Animal a=new Animal();
 
Matthew Brown
Bartender
Posts: 4565
8
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to differentiate between those, I'd suggest labelling the reference with the type. So instead of a, use a: Animal and a: Horse (or equivalent notation).
 
Rohan Deshmkh
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thanks, i got it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic