Skip to content
This repository was archived by the owner on Aug 8, 2022. It is now read-only.
This repository was archived by the owner on Aug 8, 2022. It is now read-only.

Convert Utility classes to Services for Dependency Injection #178

Open
@thomaszbz

Description

@thomaszbz

As a follow-up to #176, I suggest to not only rename Utility classes but also to convert them to stateless services which we can inject to objects which actually need them.

The big advantage is that we can mock these services for Unit Testing. As long as we can't mock them, the unit of code we test is actually not a unit of the code but close to all code in some cases. Plus, do we end up testing a lot of code from the core in our test suite. I'm not talking of class testing (which I also consider to be attractive), but we should get closer to an object model which allows class testing. Plus, should we have an opportunity to test code whithout having to run it against the DBMS.

While performing the refactoring of the object model of our Ajax classes, I already started using Services for Dependency Injection using the corresponding namespace DependencyInjection and Daofor new classes, but I named them with suffix Utility for consistency.

DI by TYPO3 is still to come (there's only extbase DI), but as long as we don't use it we can still pseudo-inject dependencies to controllers using init functions. This is not nice for the moment, but it should prepare for easy refactoring for real DI (I'm referring to objects which are not supposed to have access to the object container).

Comments on this issue are welcome.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions