[TYPO3-ect] Hooks vs Patterns

Ernesto Baschny [cron IT] ernst at cron-it.de
Wed Apr 12 12:34:00 CEST 2006


Hi,

regarding TYPO3 hooks, what is your opinion on that?

I would like to discuss the merits and drawbacks of having that
"hook-based" approach, and would like to invite you to try to rethink
some of the hooks in a more OO way, using well known design patterns.

Right now a patch is being discussed by the core team to add a hook for
extensions to create new TS-cObject types. This would be a simple
replacement for the "bloated" obts way of doing that. While I find that
really useful, I think a better design pattern to acchieve that would be:

1) A registry to register new object types
2) A defined interface which a new object type has to implement (fairly
simple), maybe a class that has to be extended.
3) A factory to get a certain typoscript object by its name, which can
then be used by cObject.

The vision I have with this is to be able to move all functions from
cObject to extensions, that simply register their cObject types
("IMGTEXT", "HMENU", etc), which are then easier to be extended by other
extensions (maybe the factory implementation might even be able to work
that out, so we don't need XCLASSes here anymore).

The interface could even provide some kind of method for an object type
to list the available attributes, values, functions that the object
might expect, which can be useful in a TypoScript developer tool that
shows errors in TypoScript setups (e.g. typos in an attribute names).

Another place where a registry/factory pattern might be useful in the
TypoScript context is a way of adding more "functions" to stdWrap.

What do you think?

Cheers,
Ernesto



More information about the TYPO3-team-extension-coordination mailing list