PropertyChangeListener for non gui objects

?

-

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?
 
T

Thomas Hawtin

- said:
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
 
?

-

Thomas said:
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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top