PropertyChangeListener for non gui objects

Discussion in 'Java' started by -, Jul 19, 2005.

  1. -

    - Guest

    I have several non gui objects that has addPropertyChangeListener,
    removePropertyChangeListeners and the various fire event methods.

    Since there are duplicate codes, is it better if i pull up those methods
    into a base class and have the non gui objects extend it?
    -, Jul 19, 2005
    #1
    1. Advertising

  2. - wrote:
    > I have several non gui objects that has addPropertyChangeListener,
    > removePropertyChangeListeners and the various fire event methods.
    >
    > Since there are duplicate codes, is it better if i pull up those methods
    > into a base class and have the non gui objects extend it?


    Possibly, but you might want to use the single inheritance for something
    else. In that case I suggest introducing a support class and just
    forward those two methods.

    Tom Hawtin
    --
    Unemployed English Java programmer
    Thomas Hawtin, Jul 19, 2005
    #2
    1. Advertising

  3. -

    - Guest

    Thomas Hawtin wrote:

    > Possibly, but you might want to use the single inheritance for something
    > else. In that case I suggest introducing a support class and just
    > forward those two methods.


    I can use the PropertyChangeSupport class and adopt the composition
    pattern but isn't doing so seems like duplicating code which can be
    solved by inheritance? In this case, is the duplicating of code a minor
    issue since composition is more favored than inheritance?
    -, Jul 20, 2005
    #3
    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. Will
    Replies:
    3
    Views:
    1,831
    Michael Rauscher
    Apr 29, 2004
  2. Will
    Replies:
    1
    Views:
    363
    Chris Riesbeck
    Jun 10, 2004
  3. Replies:
    2
    Views:
    724
    Roedy Green
    Dec 12, 2005
  4. Matt Newcomb

    Jython + propertyChangeListener?!?!

    Matt Newcomb, Jul 29, 2003, in forum: Python
    Replies:
    0
    Views:
    406
    Matt Newcomb
    Jul 29, 2003
  5. Hal Fulton

    GUI and non-GUI data

    Hal Fulton, Aug 5, 2004, in forum: Ruby
    Replies:
    1
    Views:
    137
    Austin Ziegler
    Aug 5, 2004
Loading...

Share This Page