File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark ""Is -A" relationship" Watch ""Is -A" relationship" New topic

"Is -A" relationship

Rob Michaelson
Ranch Hand

Joined: Jul 15, 2003
Posts: 36
What is the �Is-A� relationship?
chi Lin
Ranch Hand

Joined: Aug 24, 2001
Posts: 348
"is-A" relationship used on inheritance to describe parent/child realtionship.
eg :
Occupation class as parent class,
Programmer, CabDriver being child class of Occupation.
in Java we say
Programmer extends Occupation
CabDriver extends Occupation
we then decribe the relationship like :
Programmer is-A Occupation
CabDriver is-A Occupation
[ July 21, 2003: Message edited by: chi Lin ]

not so smart guy still curious to learn new stuff every now and then
Rob Michaelson
Ranch Hand

Joined: Jul 15, 2003
Posts: 36
That is great - Thank You!!
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Is-A is a helpful way to hunt for opportunities for inheritance, but it is not the only way and it is not always right and inheritance is not the only way to "be" something else. So if you see something in the real world that "is a" something else but inheritance makes no sense in code, listen to the code.
When using inheritance, you should also be aware of the Liskov Substitution Principle. Do a Google search for papers and see how it complicates the simple "Is-A" some times.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: "Is -A" relationship
jQuery in Action, 3rd edition