Skip to main content
Commonmark migration
Source Link

I don't know how Zend works, but regardless of the framework, hiding the dependencies locks our code to the DI container, obfuscate the code, makes the design opaque and oriented to magic. In general, makes our project harder to understand.

Parameterized constructors and setters make our code less oriented to magic and less prone to Poltergeist. Some containers allow us to drop these wonders from the code, but why should we?1

Regarding the ServiceLocator as alternative

For RAD, when Controllers ask for a lot of dependencies, when business logic is complex enough, instead of cluttering Controller constructor methods with 5+ dependencies, it is at times more convenient to pass the Service Locator / container as the dependency to the Controller and let code inside the Controller invoke various many objects via SL/DiC facilities.

I disagree for the next reasons:

  1. ServiceLocator is still hiding the dependencies and it doesn't make the testing easier either. Quite the opposite.

  2. If the controllers have so many dependencies, don't they have too many responsibilities as well? Is then ServiceLocator hiding my design weakness or just contributing to them?

  3. it is at times more convenient to pass the Service Locator/container as the dependency.

    Where did the supposed abstraction go?

  4. let code inside the Controller invoke various many objects via SL/DiC facilities.

    Where did IoC go?

Where did the supposed abstraction go?

  1. let code inside the Controller invoke various many objects via SL/DiC facilities.

    Where did IoC go?

What is the container doing for us? If we use the container here and there, where is the consistency?

In Java, Spring does the very same magic, but it doesn't prevent me from implementing constructors and setters and enforce the framework to use them all. My reasoning is that the more I fall into the Spring facilities the more I lock my developments to the framework. Ultimately, I'm not a Spring senior engineer.

Summarising, don't hide your dependencies. Make them obvious and obvious will be your designs and don't lock yourself to a specific tool.


1: This is the sweet we should avoid. It generates a "personal" technical debt that eventually reverts against you.

I don't know how Zend works, but regardless of the framework, hiding the dependencies locks our code to the DI container, obfuscate the code, makes the design opaque and oriented to magic. In general, makes our project harder to understand.

Parameterized constructors and setters make our code less oriented to magic and less prone to Poltergeist. Some containers allow us to drop these wonders from the code, but why should we?1

Regarding the ServiceLocator as alternative

For RAD, when Controllers ask for a lot of dependencies, when business logic is complex enough, instead of cluttering Controller constructor methods with 5+ dependencies, it is at times more convenient to pass the Service Locator / container as the dependency to the Controller and let code inside the Controller invoke various many objects via SL/DiC facilities.

I disagree for the next reasons:

  1. ServiceLocator is still hiding the dependencies and it doesn't make the testing easier either. Quite the opposite.

  2. If the controllers have so many dependencies, don't they have too many responsibilities as well? Is then ServiceLocator hiding my design weakness or just contributing to them?

  3. it is at times more convenient to pass the Service Locator/container as the dependency.

Where did the supposed abstraction go?

  1. let code inside the Controller invoke various many objects via SL/DiC facilities.

    Where did IoC go?

What is the container doing for us? If we use the container here and there, where is the consistency?

In Java, Spring does the very same magic, but it doesn't prevent me from implementing constructors and setters and enforce the framework to use them all. My reasoning is that the more I fall into the Spring facilities the more I lock my developments to the framework. Ultimately, I'm not a Spring senior engineer.

Summarising, don't hide your dependencies. Make them obvious and obvious will be your designs and don't lock yourself to a specific tool.


1: This is the sweet we should avoid. It generates a "personal" technical debt that eventually reverts against you.

I don't know how Zend works, but regardless of the framework, hiding the dependencies locks our code to the DI container, obfuscate the code, makes the design opaque and oriented to magic. In general, makes our project harder to understand.

Parameterized constructors and setters make our code less oriented to magic and less prone to Poltergeist. Some containers allow us to drop these wonders from the code, but why should we?1

Regarding the ServiceLocator as alternative

For RAD, when Controllers ask for a lot of dependencies, when business logic is complex enough, instead of cluttering Controller constructor methods with 5+ dependencies, it is at times more convenient to pass the Service Locator / container as the dependency to the Controller and let code inside the Controller invoke various many objects via SL/DiC facilities.

I disagree for the next reasons:

  1. ServiceLocator is still hiding the dependencies and it doesn't make the testing easier either. Quite the opposite.

  2. If the controllers have so many dependencies, don't they have too many responsibilities as well? Is then ServiceLocator hiding my design weakness or just contributing to them?

  3. it is at times more convenient to pass the Service Locator/container as the dependency.

    Where did the supposed abstraction go?

  4. let code inside the Controller invoke various many objects via SL/DiC facilities.

    Where did IoC go?

What is the container doing for us? If we use the container here and there, where is the consistency?

In Java, Spring does the very same magic, but it doesn't prevent me from implementing constructors and setters and enforce the framework to use them all. My reasoning is that the more I fall into the Spring facilities the more I lock my developments to the framework. Ultimately, I'm not a Spring senior engineer.

Summarising, don't hide your dependencies. Make them obvious and obvious will be your designs and don't lock yourself to a specific tool.


1: This is the sweet we should avoid. It generates a "personal" technical debt that eventually reverts against you.

spellcheck revision
Source Link
Laiv
  • 15k
  • 2
  • 34
  • 72

I don't know how Zend works, but regardless of the framework, hiding the dependencies locks our code to the DI container, obfuscate the code, makes the design opaque and oriented to magic. In general, makes our project harder to understand.

Parameterized constructors and setters make our code less oriented to magic and less prone to poltergeistPoltergeist. Some containers allow us to drop these wonders from the code, but why should we?1

Regarding the ServiceLocator as alternative

For RAD, when Controllers ask for a lot of dependencies, when business logic is complex enough, instead of cluttering Controller constructor methods with 5+ dependencies, it is at times more convenient to pass the Service Locator / container as the dependency to the Controller and let code inside the Controller invoke various many objects via SL/DiC facilities.

I disagree for the next reasons:

  1. ServiceLocator is still hiding the dependencies and it doesn't make the testing easier either. Quite the opposite.

  2. If the controllers have so many dependencies, don't they have too many responsabilities aswellresponsibilities as well? Is then ServiceLocator hiding my design weakness or just contributing to them?

  3. it is at times more convenient to pass the Service Locator / container as the dependency.

Where did the supposed abstraction did go?

  1. let code inside the Controller invoke various many objects via SL/DiC facilities.

    Where IoC did IoC go?

What is the container doing for us? If we use the container here and there, where is the consistency?

In Java, Spring does the very same magic, but it doesn't prevent me from implementing constructors and setters and enforce the framework to use them all. My reasoning is that the more I fall into the Spring facilitesfacilities the more I lock my developments to the framework. UltimatellyUltimately, I'm not a Spring senior engineer.

SummarizingSummarising, don't hide your dependencies. Make them obvious and obvious will be your designs and don't lock yourself to ana specific tool.


1: This is the sweet we should avoid. It generates a "personal" technical debt that eventually reversreverts against you.

I don't know how Zend works, but regardless of the framework, hiding the dependencies locks our code to the DI container, obfuscate the code, makes the design opaque and oriented to magic. In general, makes our project harder to understand.

Parameterized constructors and setters make our code less oriented to magic and less prone to poltergeist. Some containers allow us to drop these wonders from the code, but why should we?1

Regarding the ServiceLocator as alternative

For RAD, when Controllers ask for a lot of dependencies, when business logic is complex enough, instead of cluttering Controller constructor methods with 5+ dependencies, it is at times more convenient to pass the Service Locator / container as the dependency to the Controller and let code inside the Controller invoke various many objects via SL/DiC facilities.

I disagree for the next reasons:

  1. ServiceLocator is still hiding the dependencies and it doesn't make the testing easier either. Quite the opposite.

  2. If the controllers have so many dependencies, don't they have too many responsabilities aswell? Is then ServiceLocator hiding my design weakness or just contributing to them?

  3. it is at times more convenient to pass the Service Locator / container as the dependency.

Where the supposed abstraction did go?

  1. let code inside the Controller invoke various many objects via SL/DiC facilities.

    Where IoC did go?

What is the container doing for us? If we use the container here and there, where is the consistency?

In Java, Spring does the very same magic, but it doesn't prevent me from implementing constructors and setters and enforce the framework to use them all. My reasoning is that the more I fall into the Spring facilites the more I lock my developments to the framework. Ultimatelly, I'm not a Spring senior engineer.

Summarizing, don't hide your dependencies. Make them obvious and obvious will be your designs and don't lock yourself to an specific tool.


1: This is the sweet we should avoid. It generates a "personal" technical debt that eventually revers against you.

I don't know how Zend works, but regardless of the framework, hiding the dependencies locks our code to the DI container, obfuscate the code, makes the design opaque and oriented to magic. In general, makes our project harder to understand.

Parameterized constructors and setters make our code less oriented to magic and less prone to Poltergeist. Some containers allow us to drop these wonders from the code, but why should we?1

Regarding the ServiceLocator as alternative

For RAD, when Controllers ask for a lot of dependencies, when business logic is complex enough, instead of cluttering Controller constructor methods with 5+ dependencies, it is at times more convenient to pass the Service Locator / container as the dependency to the Controller and let code inside the Controller invoke various many objects via SL/DiC facilities.

I disagree for the next reasons:

  1. ServiceLocator is still hiding the dependencies and it doesn't make the testing easier either. Quite the opposite.

  2. If the controllers have so many dependencies, don't they have too many responsibilities as well? Is then ServiceLocator hiding my design weakness or just contributing to them?

  3. it is at times more convenient to pass the Service Locator/container as the dependency.

Where did the supposed abstraction go?

  1. let code inside the Controller invoke various many objects via SL/DiC facilities.

    Where did IoC go?

What is the container doing for us? If we use the container here and there, where is the consistency?

In Java, Spring does the very same magic, but it doesn't prevent me from implementing constructors and setters and enforce the framework to use them all. My reasoning is that the more I fall into the Spring facilities the more I lock my developments to the framework. Ultimately, I'm not a Spring senior engineer.

Summarising, don't hide your dependencies. Make them obvious and obvious will be your designs and don't lock yourself to a specific tool.


1: This is the sweet we should avoid. It generates a "personal" technical debt that eventually reverts against you.

deleted 117 characters in body
Source Link
Laiv
  • 15k
  • 2
  • 34
  • 72

I don't know how Zend works, but regardless of the framework, hiding the dependencies locks our code to the DI container, obfuscate the code, makes ourthe design opaque and oriented to magic. In general, hardmakes our project harder to understand.

Parameterized constructors and setters make our code less oriented to magic and less prone to poltergeist. Some containers allow us to drop these wonders from the code, but why should we?1

Regarding the ServiceLocator as alternative

For RAD, when Controllers ask for a lot of dependencies, when business logic is complex enough, instead of cluttering Controller constructor methods with 5+ dependencies, it is at times more convenient to pass the Service Locator / container as the dependency to the Controller and let code inside the Controller invoke various many objects via SL/DiC facilities.

I disagree for the next reasons:

  1. ServiceLocator is still hiding the dependencies and it doesn't make the testing easier either. Quite the opposite.

  2. If the controllers have so many dependencies, don't they have too many responsabilities aswell? Is then ServiceLocator hiding my design weakness or just contributing to them.?

  3. it is at times more convenient to pass the Service Locator / container as the dependency.

Where the supposed abstraction did go?

  1. let code inside the Controller invoke various many objects via SL/DiC facilities.

    Where IoC did go?

What is the container doing for meus? If we use the container here and there, where is the consistency?

In Java, Spring pretty much dodoes the very same magic, but it doesn't prevent me from implementing constructors and setters and enforce the framework to use them all. Moreover, in my code reviews I don't accept code oriented to magic.

The reasonMy reasoning is simple. If I ever decide to drop Spring fromthat the stack and go with pure DI,more I fall into the interface will remainSpring facilites the same. It just will take memore I lock my developments to build the injectors (among other things). If by any reason, the framework is incompatible with these premises. Ultimatelly, just hop to the nextI'm not a Spring senior engineer.

Summarizing, don't hide your dependencies. Make them obvious and obvious will be your designdesigns and don't lock yourself to an specific tool.


1: This is the sweet we should avoid. It generates a "personal" technical debt that eventually revers against you.

I don't know how Zend works, but regardless of the framework hiding the dependencies locks our code to the DI container, obfuscate the code, makes our design opaque and oriented to magic. In general, hard to understand.

Parameterized constructors and setters make our code less oriented to magic and less prone to poltergeist. Some containers allow us to drop these wonders from the code, but why should we?1

Regarding the ServiceLocator as alternative

For RAD, when Controllers ask for a lot of dependencies, when business logic is complex enough, instead of cluttering Controller constructor methods with 5+ dependencies, it is at times more convenient to pass the Service Locator / container as the dependency to the Controller and let code inside the Controller invoke various many objects via SL/DiC facilities.

I disagree for the next reasons:

  1. ServiceLocator is still hiding the dependencies and it doesn't make the testing easier either. Quite the opposite.

  2. If the controllers have so many dependencies, don't they have too many responsabilities? Is then ServiceLocator hiding my design weakness or just contributing to them.

  3. it is at times more convenient to pass the Service Locator / container as the dependency.

Where the abstraction did go?

  1. let code inside the Controller invoke various many objects via SL/DiC facilities.

    Where IoC did go?

What is the container doing for me? If we use the container here and there, where is the consistency?

In Java, Spring pretty much do the same magic, but it doesn't prevent me from implementing constructors and setters and enforce the framework to use them all. Moreover, in my code reviews I don't accept code oriented to magic.

The reason is simple. If I ever decide to drop Spring from the stack and go with pure DI, the interface will remain the same. It just will take me to build the injectors (among other things). If by any reason, the framework is incompatible with these premises, just hop to the next.

Summarizing, don't hide your dependencies. Make them obvious and obvious will be your design.


1: This is the sweet we should avoid. It generates a "personal" technical debt that eventually revers against you.

I don't know how Zend works, but regardless of the framework, hiding the dependencies locks our code to the DI container, obfuscate the code, makes the design opaque and oriented to magic. In general, makes our project harder to understand.

Parameterized constructors and setters make our code less oriented to magic and less prone to poltergeist. Some containers allow us to drop these wonders from the code, but why should we?1

Regarding the ServiceLocator as alternative

For RAD, when Controllers ask for a lot of dependencies, when business logic is complex enough, instead of cluttering Controller constructor methods with 5+ dependencies, it is at times more convenient to pass the Service Locator / container as the dependency to the Controller and let code inside the Controller invoke various many objects via SL/DiC facilities.

I disagree for the next reasons:

  1. ServiceLocator is still hiding the dependencies and it doesn't make the testing easier either. Quite the opposite.

  2. If the controllers have so many dependencies, don't they have too many responsabilities aswell? Is then ServiceLocator hiding my design weakness or just contributing to them?

  3. it is at times more convenient to pass the Service Locator / container as the dependency.

Where the supposed abstraction did go?

  1. let code inside the Controller invoke various many objects via SL/DiC facilities.

    Where IoC did go?

What is the container doing for us? If we use the container here and there, where is the consistency?

In Java, Spring does the very same magic, but it doesn't prevent me from implementing constructors and setters and enforce the framework to use them all. My reasoning is that the more I fall into the Spring facilites the more I lock my developments to the framework. Ultimatelly, I'm not a Spring senior engineer.

Summarizing, don't hide your dependencies. Make them obvious and obvious will be your designs and don't lock yourself to an specific tool.


1: This is the sweet we should avoid. It generates a "personal" technical debt that eventually revers against you.

deleted 221 characters in body
Source Link
Laiv
  • 15k
  • 2
  • 34
  • 72
Loading
Corrected some spelling and grammar
Source Link
Samuel
  • 9.2k
  • 1
  • 27
  • 43
Loading
deleted 11 characters in body
Source Link
Laiv
  • 15k
  • 2
  • 34
  • 72
Loading
added 142 characters in body; added 122 characters in body
Source Link
Laiv
  • 15k
  • 2
  • 34
  • 72
Loading
added 212 characters in body
Source Link
Laiv
  • 15k
  • 2
  • 34
  • 72
Loading
Source Link
Laiv
  • 15k
  • 2
  • 34
  • 72
Loading