Abstract Base classes - [op john gagon]

Discussion in 'Java' started by John Gagon, May 17, 2006.

  1. John Gagon

    John Gagon Guest

    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.
     
    John Gagon, May 17, 2006
    #1
    1. Advertising

  2. 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
    > 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.
    >


    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
    > ---
    > 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, May 17, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RN
    Replies:
    3
    Views:
    512
    Matt Berther
    Feb 27, 2005
  2. DaKoadMunky
    Replies:
    4
    Views:
    552
    Lee Weiner
    Apr 20, 2004
  3. FrankLewis
    Replies:
    0
    Views:
    518
    FrankLewis
    May 16, 2006
  4. Ben Finney

    Abstract Base Classes

    Ben Finney, Nov 11, 2005, in forum: Python
    Replies:
    6
    Views:
    407
    Steven D'Aprano
    Nov 14, 2005
  5. pasa_1
    Replies:
    1
    Views:
    327
    mlimber
    Nov 17, 2006
Loading...

Share This Page