develooper Front page | perl.qa | Postings from October 2011

Re: Event handling: One method per event or one method for all?

Thread Previous | Thread Next
From:
chromatic
Date:
October 27, 2011 00:36
Subject:
Re: Event handling: One method per event or one method for all?
Message ID:
201110270036.18068.chromatic@wgz.org
On Wednesday, October 26, 2011 at 09:58 PM, Michael G wrote:

> So now the question is one of good event handler design, which I don't have
> experience with.  How does one design a good event handler?  Is the pattern
> one method per type of event?  Or one method to do the dispatching?  Or
> something else?

I've done this several times. I prefer one method per type of event (hello, 
cheap and easy polymorphism!).

This is also one case in which I find an abstract base class acceptable; the 
null method pattern means never having to call ->can().

-- c

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About