Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pool-aware interface and trait #9

Closed
wants to merge 1 commit into from

Conversation

garex
Copy link

@garex garex commented Oct 13, 2016

Ok let's try here.

@michaelcullum
Copy link
Member

@Crell Merge if you wish

@Crell
Copy link
Collaborator

Crell commented Oct 13, 2016

I'm skeptical here. Certainly it can be done, but is it wise? How often will you be side-injecting a cache pool? It's not like the logger where it's more common to have a blanket "if it's loggable give it a logger" routine in your DI Container.

@garex
Copy link
Author

garex commented Oct 13, 2016

@Crell how do you inject cache pool usually? As a constructor param?

I think cache is an often used feature, which can have it's own trait same as logger. Because it's a infrastructure layer.

@Crell
Copy link
Collaborator

Crell commented Oct 13, 2016

Yes, constructor injection is preferred in virtually all cases. Setter injection is really only useful for cases like the logger, or maybe ContainerAware (which is usually a code smell), where an optional dependency can be passed in by a DI Container or factory selectively, based on the presence of an interface. The use cases for that pattern are, IMO, very slim, and I don't think cache is one of them. I'm actually hard pressed to think of any other than than ContainerAware or LoggerAware, now that I think of it...

@garex
Copy link
Author

garex commented Oct 14, 2016

@Crell cache could be optional. That's why we have null-objects adapters both in stash and in symfony/cache.

@garex garex mentioned this pull request Oct 14, 2016
@Crell Crell closed this Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants