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

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

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

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. Krick
    Replies:
    2
    Views:
    3,519
    Olaf Heimburger
    Jan 10, 2004
  2. Will
    Replies:
    3
    Views:
    2,040
    Michael Rauscher
    Apr 29, 2004
  3. Will
    Replies:
    1
    Views:
    445
    Chris Riesbeck
    Jun 10, 2004
  4. Replies:
    2
    Views:
    796
    Roedy Green
    Dec 12, 2005
  5. Matt Newcomb

    Jython + propertyChangeListener?!?!

    Matt Newcomb, Jul 29, 2003, in forum: Python
    Replies:
    0
    Views:
    545
    Matt Newcomb
    Jul 29, 2003
  6. Replies:
    2
    Views:
    462
    Diego Martins
    May 19, 2006
  7. 7stud
    Replies:
    11
    Views:
    1,071
    Dennis Lee Bieber
    Mar 20, 2007
  8. Hal Fulton

    GUI and non-GUI data

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