Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

is it possible to make superclass extend another class ?

Thread view: 
krislioe@gmail.com - 06 Oct 2006 16:07 GMT
Hi all,

I have Class A as superclass.

I have Class B extend Class A
Then Class C extend Class B

Is it possible to make Class A Extend Class D ?

Thank you,
xtanto
Andrew Thompson - 06 Oct 2006 16:28 GMT
...
> I have Class A as superclass.
>
> I have Class B extend Class A
> Then Class C extend Class B
>
> Is it possible to make Class A Extend Class D ?

Sure.  So long as D extends none of A, B or C.

BTW - are you sure this is the best design?
A lot of layers of 'extends' sometimes suggests 'no'.
(and those are silly class names - even for an abstraction)

Andrew T.
paul_himanshu@yahoo.com - 06 Oct 2006 17:06 GMT
> ...
> > I have Class A as superclass.
[quoted text clipped - 11 lines]
>
> Andrew T.
Patricia Shanahan - 06 Oct 2006 17:24 GMT
> ...
>> I have Class A as superclass.
[quoted text clipped - 11 lines]
>
> Andrew T.

A couple of additional restrictions:

A must be a class you can change.

A's immediate superclass must also be a superclass of D, trivially true
if A is a direct subclass of Object.

I share Andrew's doubts about a design with that many layers.

Patricia
krislioe@gmail.com - 07 Oct 2006 03:27 GMT
Hi,
Thank you for your response.

> I share Andrew's doubts about a design with that many layers.

As a rule of thumb, how many is indicating too many ?

Thank you,
xtanto

> > ...
> >> I have Class A as superclass.
[quoted text clipped - 22 lines]
>
> Patricia
Patricia Shanahan - 07 Oct 2006 04:09 GMT
[Rearranged to avoid top posting confusion]
>>> ...
>>>> I have Class A as superclass.
[quoted text clipped - 28 lines]
>
> As a rule of thumb, how many is indicating too many ?

I don't think there is any rule of thumb, but an increasing queasiness
as the number of inheritance levels increases. We have at least 5 levels
here (Object, D, A, B, C). Whether it makes sense to go that deep
depends on what the classes are about, but it is deep enough that I
would question it in my own code.

Patricia


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.