Home > Archive > Java Help > June 2005 > 2 extends
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Irlan agous 2005-06-09, 8:58 pm |
| Hello i want to extend from 2 classes lik
public class PatientImpl extends DataModel ,UnicastRemoteObject implements
PatientInterface throws RemoteExeption;
But this gives an error message, dfoes anyone knows how to solve this?
Thanks
| |
|
|
|
| On Thu, 9 Jun 2005 13:38:40 +0200, "Irlan agous" <irlan345@msn.com>
wrote:
>Hello i want to extend from 2 classes lik
>
>public class PatientImpl extends DataModel ,UnicastRemoteObject implements
>PatientInterface throws RemoteExeption;
>
>But this gives an error message, dfoes anyone knows how to solve this?
No multiple inheritence in Java.
--
now with more cowbell
| |
| Thomas G. Marshall 2005-06-10, 8:58 pm |
| Bryce coughed up:
> On Thu, 9 Jun 2005 13:38:40 +0200, "Irlan agous" <irlan345@msn.com>
> wrote:
>
>
> No multiple inheritence in Java.
{cough, cough}....except for interfaces.
--
Everythinginlifeisrealative. Apingpongballseemssmalluntilsomeoneramsi
tupyournose.
| |
| Hal Rosser 2005-06-11, 3:58 am |
| Pehaps you may consider creating an instance variable of the 'other' class.
This approach is preferred in many cases. Composition is a good alternative
to multiple inheritance, and is preferred by some authors of the subject.
HTH
"Irlan agous" <irlan345@msn.com> wrote in message
news:6bebb$42a82a41$52ade8f3$30956@news.versatel.nl...
> Hello i want to extend from 2 classes lik
>
> public class PatientImpl extends DataModel ,UnicastRemoteObject implements
> PatientInterface throws RemoteExeption;
>
> But this gives an error message, dfoes anyone knows how to solve this?
>
> Thanks
>
>
| |
| Tor Iver Wilhelmsen 2005-06-11, 3:58 am |
| "Thomas G. Marshall" < tgm2tothe10thpower@replacetextwithnumber
.hotmail.com> writes:
> {cough, cough}....except for interfaces.
Or through inner classes and using methods instead of casting.
public class MyClass {
private MyOtherType myOtherTypePart = new MyOtherType() {
public void overriddenMethod() {
// Should access members of MyClass
// otherwise it's pointless
}
}
public MyOtherType asMyOtherType() {
return myOtherTypePart;
}
}
| |
| The Wogster 2005-06-11, 3:58 pm |
| Irlan agous wrote:
> Hello i want to extend from 2 classes lik
>
> public class PatientImpl extends DataModel ,UnicastRemoteObject implements
> PatientInterface throws RemoteExeption;
>
> But this gives an error message, dfoes anyone knows how to solve this?
>
There are a few tricks, an Interface is one, an instance of the second
class is another, you could potentially combine both or create a new
class that Interfaces to both, as a child of neither.
However needing multiple inheritance usually means that something in the
initial class design is broken. Often it's from trying to create a
jack-of-all-classes combining a bunch of what should be unrelated stuff
into a single class.
It's like the goto, it's legal in C, but the only times I have seen it
used, were because someone had programmed themselves into a corner.
Once I rewrote a few lines and got rid of it, the other is still there
AFAIK, because the code was so fragile, nobody was stupid enough to want
to monkey with it, even the lead programmer would not touch it.
W
|
|
|
|
|