Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About IS-A relationships needing two classes

 
Thomas Kennedy
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question came up whether an IS-A relationship requires two classes, and the answer I got back was that yes, they do. But is an interface a class? My understanding is that interfaces, not supporting constructors, are not to be considered classes. Discuss...
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Discussions about the "is-a" relationship are by definition conceptual and language-independent. If you use the word "class" in such a discussion, it's not the same as the Java keyword "class", which refers to a specific language feature.

If you want to have the same discussion specifically in the context of Java, you could either be pedantic and say "class, interface, or enum" whenever you mean "class" -- or you can just continue to say "class" and let it be understood that you mean that in the broader, object-oriented design sense.
 
alpa
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is-a relationship happens when there are two classes.When we say ObjectA is a Object B, it invloves two classes .
Interface is not class, but it is blue print of what you can do with the objects of the class that implements that interface.
Eg. if we take a set of alphnumeric keys as an interface.
The interface has english alphabets, numbers and soem extra keys.
The computer class when implements this interface we use it in a bit diferent way as comaped if it is implemented by a cell phone class.
We cannot say a cell phone is a computer because it implements the same interface.
This is a weak relationship we can say cellphone is a kind of computer.

On the other hand.
If we have class called Processor.
Computer extends Processor and PDA also extends Processor.

so we can ssay PDA is a Computer.Its a strong relationship and we are usign two class for it.
 
Maneesh Godbole
Saloon Keeper
Posts: 11070
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"alpa_pathak"
We do have a naming policy here at the ranch which is not optional.
Your screen name must consist of a first name and last name which must not be obviously fictitious.
Please note, user accounts not adhering to the naming policy stand a good chance of getting suspended.
You are expected to adjust your your screen name before you post next.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by alpa_pathak:
Is-a relationship happens when ...


Nope, total bosh. See my post above.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic