Is it a good idea to have multiple NHibernate EventListeners? -


we starting out nhibernate , have been looking @ nh cookbook 3.0 highlights using eventlistener stamping object created object , when, changed object , when. looking @ implementing audit tracker event listener (creating history of property value changes). considered best practise have 2 (or more) event listeners each handling 1 task, or single eventlistener handling multiple tasks.

so single event listener code like:

public class eventlistener : ipreinserteventlistener, ipreupdateeventlistener {     ...     ...     public bool onpreupdate(preupdateevent e)     {         _stamper.update(e.entity istampedentity, e.oldstate, e.state, e.persister);         _audittracker.update(e.entity iaudittrackedentity, e.oldstate, e.state, e.persister);         return false;     } } 

whilst 2 event listener model like:

public class stampereventlistener : ipreinserteventlistener, ipreupdateeventlistener {     ...     ...     public bool onpreupdate(preupdateevent e)     {         _stamper.update(e.entity istampedentity, e.oldstate, e.state, e.persister);         return false;     } }  public class audithistoryeventlistener : ipreupdateeventlistener {     ...     ...     public bool onpreupdate(preupdateevent e)     {         _audittracker.update(e.entity iaudittrackedentity, e.oldstate, e.state, e.persister);         return false;     } } 

which considered best practise , there performance drawbacks either? later (two separate event listeners) seem best implementation both clarify , maintenance, unsure if it's going cause problems later on.

i stick separate implementation maintainability reasons - have been using approach in couple of latest projects without issues.. knows maybe @ point in future you'll want provide specific behavior in 1 of listeners - in case re-point configuration new listener/implementation without affecting existing code. 2 cents.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -