[Owncloud] [Proposal] New hooks system

Bart Visscher bartv at thisnet.nl
Tue May 7 19:23:47 UTC 2013


On Mon, May 06, 2013 at 06:26:51PM +0200, Robin Appelman wrote:
> The current hooks system (provided by OC_Hooks) gives serious issues with 
> testablity of the core classes, it's hard to controll the side effects of test 
> cases caused by hooks emmited by the tested classes.
> 
> To solve this I propose to create an updated hooks system that scopes the 
> emited events and listeners to an instance of the class emitting the event.
> That way any events emited by an instance of a class created for testing 
> purposes won't cause any side effects outside the test case.
> 
> A quick writeup of the proposal can be found here 
> https://gist.github.com/icewind1991/1e315e6e75c106406405
> 
The problem that i see with the proposed system is:
- We are directly connecting to a class/instance, this means that that
  class needs to be loaded, even when that is not used.
- It is not possible to send a event from an other location (when
  upgrading, refactoring)

I think that using an event dispatcher would work better, this is what
OC_Hooks already is. But make this an object that can be injected in the
instance we want to use or test.

Bart



More information about the Owncloud mailing list