Open/Closed principle?
Posted: Fri Mar 05, 2010 4:35 am
In Magento there are a bunch of classes
Extension developers override these classes and override methods to change behavior
Magento also provides an event architecture, which allows multiple extension developers to utilize the same "hook point".
It would be impossible to develop a system and identify every hook that is needed from the get-go.
If 2 developers try to override a class, instead of using a hook point, only 1 would take effect.
Is this an example of open/closed principle? (ex. a developer would not feel the need to override said method if it followed open/closed?). I was thinking about writing a "Magento killer" some day, and I think that solving this problem would definitely be a good start.
So my question is how would you guys design said system? Would you just try to be really attentive to developer's requests to add hooks? (Magento has a thread where we can make requests but they ignore us now-adays). Anyways an architectural solution would be desirable. The Magento forum people have suggested firing events for EVERY method reflectively, I think that is bad suggestion for performance reasons.
Is aspect oriented programming the only solution? Aside from just adding hooks as I go, as I discover people needing them (knowing that a certain % won't realize I am willing to add the hooks, and would possibly just "give up" instead of making the request?)
Extension developers override these classes and override methods to change behavior
Magento also provides an event architecture, which allows multiple extension developers to utilize the same "hook point".
It would be impossible to develop a system and identify every hook that is needed from the get-go.
If 2 developers try to override a class, instead of using a hook point, only 1 would take effect.
Is this an example of open/closed principle? (ex. a developer would not feel the need to override said method if it followed open/closed?). I was thinking about writing a "Magento killer" some day, and I think that solving this problem would definitely be a good start.
So my question is how would you guys design said system? Would you just try to be really attentive to developer's requests to add hooks? (Magento has a thread where we can make requests but they ignore us now-adays). Anyways an architectural solution would be desirable. The Magento forum people have suggested firing events for EVERY method reflectively, I think that is bad suggestion for performance reasons.
Is aspect oriented programming the only solution? Aside from just adding hooks as I go, as I discover people needing them (knowing that a certain % won't realize I am willing to add the hooks, and would possibly just "give up" instead of making the request?)