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 / May 2006

Tip: Looking for answers? Try searching our database.

Abstract Base classes - [op john gagon]

Thread view: 
John Gagon - 17 May 2006 07:11 GMT
I'm wondering if there should ever be inheritance instead of
composition. Can you get away with never using extends and just use
field members. I understand that one can use this as an "is a"
relationship but I think interfaces, having multiples of them allowed
are more appropriate.

Some say that one should use a base class if therre is shared
functionality. I've seen it used very usefully for "deferred"
functionality sometimes but I'm still wondering if that can be done by
composition too. What I mean by deferred is that an abstract class's
non-abstract methods calling abstract ones. With composition, it seems
you'd have the enclosing class merely call the method passing in what
it would need and delegating but somehow, it doesn't seem to fit as
well. I thought perhaps "decorator" and lazy instantiation might be
useful or maybe even listener-/action/event model. This all seems a bit
fuzzy and decorators seem rather powerful but also a bit obscure since
the order of nesting seems so arbitrary. Is there a way to control that
with the pattern better?

Thank you.

John Gagon
---
Disclaimer:
All content posted here is the property of John Gagon by virtue of
declaration. John Gagon may revoke this right at any time only via a
formal declaration by John Gagon. If you disagree with John Gagon, keep
in mind that words are not always the things. Everything is relative
and possibly metaphorical. In the event you disagree, it will
automatically be classified as "taken out of context" after which John
Gagon will explain to you the actual context which should clear
everything with formal definitions that will be agreed upon by John
Gagon.
LordAlfredHenry - 17 May 2006 07:40 GMT
John Gagon wrote something John Gagon's mother would be ashamed of:

> I'm wondering if there should ever be inheritance instead of
> composition. Can you get away with never using extends and just use
[quoted text clipped - 16 lines]
>
> Thank you.

Hey there, you know, I think it can be useful when there is a very
minor difference or you want to prevent instantiation or preinstantiate
certain values across a bunch of different classes, and as you say,
defer implementation.

LAH.

> John Gagon
> ---
[quoted text clipped - 8 lines]
> everything with formal definitions that will be agreed upon by John
> Gagon.


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



©2008 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.