Review main Abandoned

61587[WIP][TASK] Introduce constants for aspect names

Oli Bartsch CR 0 V 0 Hard +258 −207 updated 12/13/19, 20:51

Commit message

This adds public constants for the names of all currently
existing aspects and replaces all occurrences with them.

As this is public API, besides the well known advantages
of constants (technically), this features some benefits such as:
- Reduction of the error rate due to typos
- Enable IDE support (autocompletion, search for occurrences, ...)
- Possibility to easily change a name on one central place

Note: The constants are added in the Context class as this is the
central point. It would be also possible to add them to the
corresponding Aspect classes. But having them in a central point
provides more clarity.

Possible TODOs:
- Also update rst files
- Also introduce constants for aspect property names

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 64

Show 44 more files

Review log 913

  1. Oli Bartsch uploaded patch set 1 08/30/19, 21:53

  2. TYPO3com voted on patch set 1 V +1 08/30/19, 22:03 Completed build in 10m 10s on Fri, 30 Aug, 10:03 PM Test Summary: 47248 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35966

  3. Alexander Schnitzler commented on patch set 1 08/31/19, 07:45

    Replacing strings with variables/constants is a good thing but I think those constants should be bound to the aspects, not the context object. Also, we have an interface for aspects that we could use to enforce that every aspect defines a proper name. Those names can still be defined as constants in the aspect classes but with a public static function like getIdentifier(), we enforce that we have an api that allows to query the identifier of aspects. That way, one cannot miss to define a new identifier for new aspects. Additionally, we don't really want to have all those switch..case statements that need to be fostered. It's a hard binding between classes which we should avoid. Instead we could introduce an aspect registry all aspects need to be registered with. That registry handles all available instances and is to be asked for aspects by identifier. That would also streamline the overall handling of aspects. At the moment, aspects are created during runtime when they are requested and don't exist. This should be avoided. I didn't have a look at this class before, so all this is not directly related to your patch. It's more or less a comment on the whole class and its implementation. While your introduction of constants reduce the possibility for errors, I think we should think further here and do an overall architectural cleanup.
  4. Oliver Klee commented on patch set 1 08/31/19, 10:39

    Context.php:62

    Each of these should have a separate @var string to help static code analysis.

    Context.php:137

    Can't we use $name instead of constant in all cases of this switch?
  5. Oli Bartsch uploaded patch set 2 09/01/19, 20:28

  6. Oli Bartsch commented on patch set 2 09/01/19, 20:31

    Context.php:62 Reply

    Done

    Context.php:137 Reply

    Done
  7. TYPO3com voted on patch set 2 V +1 09/01/19, 20:39 Completed build in 10m 14s on Sun, 1 Sep, 08:39 PM Test Summary: 47248 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35977

  8. Oli Bartsch commented on patch set 2 09/01/19, 21:10

    > Patch Set 1: > > Replacing strings with variables/constants is a good thing but I think those constants should be bound to the aspects, not the context object. Also, we have an interface for aspects that we could use to enforce that every aspect defines a proper name. Those names can still be defined as constants in the aspect classes but with a public static function like getIdentifier(), we enforce that we have an api that allows to query the identifier of aspects. That way, one cannot miss to define a new identifier for new aspects. > > Additionally, we don't really want to have all those switch..case statements that need to be fostered. It's a hard binding between classes which we should avoid. Instead we could introduce an aspect registry all aspects need to be registered with. That registry handles all available instances and is to be asked for aspects by identifier. > > That would also streamline the overall handling of aspects. At the moment, aspects are created during runtime when they are requested and don't exist. This should be avoided. > > I didn't have a look at this class before, so all this is not directly related to your patch. It's more or less a comment on the whole class and its implementation. While your introduction of constants reduce the possibility for errors, I think we should think further here and do an overall architectural cleanup. First of all, thank you for your detailed answer. I mostly agree with your proposals. As you can see at my "note" section I have already thought about the possibility to bind the the constants to their aspect. Unfortunately there are some edge cases. For example the `UserApsect` currently features two types - frontend and backend user. Therefore the "one identifier constant per aspect" and the corresponding getIdentifier() method won't work for now. We should try to find a solution for this because this is in my opinion a valid use case also for upcoming aspects. Same applies to the registry attempt. I like the idea much but this needs still some considerations. While we are on it we should also take the aspect properties into account. There we currently have the same behaviour. Strings and the switch..case construct. For the overall architectural cleanup, how would the approach you suggest look like? Abandoned this patch and crate a new epic issue with some sub tasks?
  9. Oli Bartsch uploaded patch set 3 09/13/19, 15:33

  10. TYPO3com voted on patch set 3 V +1 09/13/19, 15:43 Completed build in 09m 26s on Fri, 13 Sep, 03:43 PM Test Summary: 47556 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-36432

  11. Oli Bartsch uploaded patch set 4 10/25/19, 16:49

  12. TYPO3com voted on patch set 4 V +1 10/25/19, 17:00 Completed build in 10m 42s on Fri, 25 Oct, 05:00 PM Test Summary: 48059 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-37715

  13. Oli Bartsch abandoned the change 12/13/19, 20:51

    Because of its heavy impact abandon for now. May be reopened in the future.