[TYPO3-dev] [TYPO3-dam-devel] RFC #13641: dam_ttcontent: Use new TYPO3 4.3 hook for preview images in page modul
Jigal van Hemert
jigal at xs4all.nl
Sat Feb 27 09:22:26 CET 2010
Hi,
Francois Suter wrote:
> Martin Kutschker wrote:
>
>> We have too many of them and most of them expose the guts of the
>> classes to the hook implementations. So the IMHO they do not create
>> a proper API but are just another way to hack the system.
>>
>> I welcomed and proposed the hooks when they were new to TYPO3, but
>> now I see that have become a problem themselves.
>
> I can believe that. Should we start using more interfaces instead?
You mean PHP Object Interfaces? This would only be a solution for a few
cases which use the hooks.
Hooks can be bad thing to have, but on the other hand they are often the
only way to modify behaviour of existing code without changing the code
itself.
Hooks are often more future-proof than XCLASS solutions, since the
latter has to replace the entire function (and the original might have
been modified slightly in newer versions).
It is true that a hook exposes the inner workings of a class, but that
is the nature of their design. They enable someone to modify the data of
an object without changing the existing source code.
There are quite a few extensions which contain hooks to enable someone
to modify the marker array; this functionality can of course be handled
in a very different way.
The largest problem with both the XCLASS and interface solution is that
many class methods perform both data manipulation and actions. If a
method only manipulates data it is often enough to extend the class,
call the parent and do your own data handling after that. In reality the
method also performs an action based on the data; a hook allows you to
manipulate the data before the action takes place. How are interfaces
going to solve that?
--
Jigal van Hemert.
More information about the TYPO3-dev
mailing list