multiple inheritance in Java

A

Arne Vajhøj

Classes whose objects represent what is the English meaning
of position and color of a pixel, i.e., x and y, and r, g,
and b. I was hoping that this might become clear from the
examples given.

That is how real people think.

Homo sapiens programmaticus is a weird species that gets distracted
by class names with real meaning in language discussions and therefor
Foo, Bar and FooBar are often better in that context.

:)

Arne
 
S

Sebastian

Am 04.07.2013 23:33, schrieb Arne Vajhøj:
[snip]
I understand his »poor man's multiple inheritance«. [snip]

But it still has nothing to do with public field vs accessor
as the above also be done as (and IMHO should be done as):

public class A {
public void a() { ... }
}

public class B {
public void b() { ... }
}

public class C {
private A a;
private B b;
public C() {
a = new A();
b = new B();
}
public A getA() {
return a;
}
public B getB() {
return b;
}
}

C o = new C();
o.getA().ma();
o.getB().mb();

Arne
Or even better, if you really want inheritance, use inner classes:

public class C {
private CA a;
private CB b;

private class CA extends A {
@Override
public void a() { ... }
}

private class CB extends B {
...
}

public C() {
a = new CA();
b = new CB();
}

public A asA() {
return a;
}

public B asB() {
return b;
}
}

-- Sebastian
 
G

Gene Wirchenko

That is how real people think.

Homo sapiens programmaticus is a weird species that gets distracted
by class names with real meaning in language discussions and therefor
Foo, Bar and FooBar are often better in that context.

:)

Some of them can get so caught up in it that there is a real
question whether they are of the same species and whether they should
be classed as homo programmaticus. This is much as whether
Neanderthal man should be homo sapiens neanderthalensis or homo
neanderthalensis.

People are people, but programmers are something else.

<VBEG>

Sincerely,

Gene Wirchenko
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,340
Messages
2,571,398
Members
48,791
Latest member
Richard Zapor

Latest Threads

Top