Re: [General]acces of members of subclass
- From: Mark Space <markspace@xxxxxxxxxxxxxx>
- Date: Sun, 27 Jul 2008 13:45:30 -0700
Daniel Moyne wrote:
So Lew as superclasses cannot acces subclass members (in you example you
just provide methods "bar" in the subclass sub but no members) there is no
reasons to declare them as public and then only private makes sense ; am I
correct ?
Well, I think it's far to strong a statement to say there is "no" reason to declare fields in a sub class public. In fact it's done all the time in the Java API.
What you should say is that you don't see how sub-classing will implement the solution you were hoping for (whatever solution that might be). That's fine. Sub-classing and inheritance is not a panacea in OOD. In fact, you should avoid it and favor composition and concrete classes if possible.
Inheritance is kind of a last resort solution, and getting it correct can be tricky, as you are discovering.
.
- References:
- [General]acces of members of subclass
- From: Daniel Moyne
- Re: [General]acces of members of subclass
- From: RedGrittyBrick
- Re: [General]acces of members of subclass
- From: Lew
- Re: [General]acces of members of subclass
- From: Daniel Moyne
- [General]acces of members of subclass
- Prev by Date: Re: [NetBeans]changing menuitems
- Next by Date: Re: [General]acces of members of subclass
- Previous by thread: Re: [General]acces of members of subclass
- Next by thread: Re: [General]acces of members of subclass
- Index(es):
Relevant Pages
|