Project

General

Profile

Actions

Feature #59497

closed

Typed Slots

Added by Bernhard Kraft almost 10 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2014-06-11
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:
Needs Decision

Description

At some time the TYPO3 project introduced interfaces for hooks. This seemed as a good idea so a developer does have a template when creating a hook class. Since the signal/slot concept was introduced the concept of interfaces was somehow put in the background.

Proposal: Have to kinds of slot/signals. We could denote the first current one "flexible slots" and the new one "typed slots". Such a new typed slot would need to implement some specific interface as required by the dispatch call. Altough this takes away the possibility to connect a signal to "any" method it rather mimics the old hooks. At least those having an interface.

Actions #1

Updated by Bernhard Kraft almost 10 years ago

The title should read "Typed slots"

Actions #2

Updated by Wouter Wolters almost 10 years ago

  • Subject changed from Types Slots to Typed Slots
Actions #3

Updated by Martin Sonnenholzer almost 10 years ago

Please correct me if I'm wrong, but you are trying to mix two design patterns. Hooks belong to the template method pattern and SignalSlots are a observer pattern.
The discussion wich one is better is another one, but mixing those two sounds incredible wrong to me.

Actions #4

Updated by Bernhard Kraft almost 10 years ago

Well. Then it sounds this for you.
For me both are variants of the same principle. Don't paint hooks black because they are called hooks.

From wikipedia "Observer pattern" my comments in ((double brackets)):

The observer pattern is a software design pattern in which an object ((i.e. TYPO3\CMS\Core\Database\DatabaseConnection)), called the subject, maintains a list of its dependents ((i.e. DatabaseConnection::$preProcessHookObjects)), called observers, and notifies them automatically of any state changes, usually by calling one of their methods ((i.e. @line 477: $hookObject->INSERTquery_preProcessAction() )). 

Altough the description isn't completly exact: The list is not maintained by the subject but rather from outside. But this is also true for our current signal/slot approach: The connection list isn't maintained by the observing object (the subject) but rather by a class instance it holds.

So neither of both implementations is exactly what wikipedia (Or Fab4) describe as observer pattern.

Actions #5

Updated by Susanne Moog over 8 years ago

  • Sprint Focus set to PRC
Actions #6

Updated by Benni Mack over 5 years ago

  • Status changed from New to Closed

Hey,

for v10, we're going with PSR-14, which is fully typed solution, so this feature for signal slot won't make it, but PSR-14 this is already built-in the logic. Thanks for the report, it's so good to see that your ideas have made it all the way to a PHP PSR standard.

All the best,
Benni.

Actions #7

Updated by Benni Mack about 4 years ago

  • Sprint Focus changed from PRC to Needs Decision
Actions

Also available in: Atom PDF