← Back to team overview

openerp-expert-framework team mailing list archive

Re: hooks are evil [was: toward a cleaner addons API...]

 

On 09/27/2011 07:22 AM, Jerzy Orłowski wrote:
> In a big project, with ~100 modules installed and 50% of them
> modified for the needs of the project it gets really hard to know
> where was each of the functions overriden and which ovveriding is
> currently the working one.

  "which ovveriding is currently the working one."
                   ??
All of them should be active and working, usually.


> The same function can be overriden in several modules and there is
> no clear way e.x to manage dependencies

You mean apart from the normal 'depends' relationship between modules,
that is used to load the 'dependencies' before the module that depends
on them, thus ensuring a proper class hierarchy?


> You can end up with modules that not "depend" on themselves" but
> "exclude" themselves and everything gets messy.

That would mean they are incompatible, and need to be redesigned more
cleanly, not made worse with more hooks and more mess.

This is all of course assuming the base API is modular and extensible
enough, but we're talking about improving it here, not making it worse.


> Hooks might be not the best solution but there should be a method
> for that.

Sorry, I fail to see how that is better than having a properly modular
API in the first place?
A dummy 'hook' method that is overridden by subclasses is subject to the
exact same kind of misuses, isn't it? For example any subclass that
overrides it and does not call super() will randomly break other
subclasses' logic - just the same.


References