-
Notifications
You must be signed in to change notification settings - Fork 44
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
ContainerInterface name #1
Comments
In the Java world, we also have the javax.inject namespace defined by JSR330. It defines a |
Yes interesting, something like However it's really not close to the usual language of dependency injection and containers in PHP. I've never seen that word in that context before. |
Summary of current options:
|
My vote would be |
Personally, I'd go with @taylorotwell I noticed MS "retired" that content. Wonder if they have moved away from calling it such? To me, a I know that is a strange example, but that's how I look at service location. The container is the same if dependencies are injected into a class, or a class uses the container to "pull dependencies in." The container behaves no differently and the Interface is the same. For that reason, I would shy away from naming an Interface after usage. Might be better for the name to focus on the Container's job. |
Hi, I agree with Amy about the If you call the interface |
Related: http://paul-m-jones.com/archives/5853 What differentiate a SL and a DI Container is how they are used. So I'd agree with Paul Jones and use the generic name However it's totally possible to use a Container as a ServiceLocator, so my conclusion would be: use a name that contains
@AmyStephen every container has a different way of defining entries. That's a very hard thing to standardize. And that's not needed for basic container interoperability like replacing an implementation by another, or chaining. So let's keep that for another future interface. @moufmouf Agreed, using |
+1 for not sticking with the term "Service". Service is way too generic and too many people have a completely different understanding what a service should be. I am also not that happy with ReadableContainerInterface, I am not sure if we really need to "mark" the interface being read-only and since we return objects we can indeed change their state (if the container returns singleton instances). So the name might imply something that is not true or at least can be misunderstood. I just had a look how the Spring Framework guys named their interface. It`s called IBeanFactory, also pretty generic and sort of straight to the point. If you look closely the interface is a factory, the implementation of the interface is what it turns it into a DIC or a service locator or whatever. So as a conclusion I think I would mostly prefer the ContainerInterface. |
@moufmouf - Glad to hear of your experiences as I also use the container in much the same way, storing class instances and data. Not all dependencies are class instances so having other values in the container is very helpful. I agree with everything @shochdoerfer said. The only problem is, if it's named Earlier, someone mentioned The challenge might be in standardizing how |
Rather than separation of concerns, it's more a question of interface segregation principle (the I from SOLID).
Frameworks getting entries from the container do not necessarily need to put entries in it. Actually, the current ReadableContainerInterface has enough methods to be used as it is. Adding And of course, it would be very complex. I'm ok to start thinking at a way to define container entries (a |
On Sun, Dec 22, 2013 at 10:12 AM, Matthieu Napoli
Starting to agree with @taylorotwell that the Interface should be named |
The interface segregation principle has more to do with not forcing implentors to implement methods they don't need. I don't think it really applies to this discussion that much since most definitely all containers offer both read and write. Anyways, to get away from bike shedding, this argument has largely been solved in many other ecosystems and we shouldn't delve into a huge "not invented here" syndrome with every PHP interop discussion. On Sun, Dec 22, 2013 at 10:20 AM, AmyStephen notifications@github.com
|
Just as a side note: would everyone involved here be OK to make a final decision on that subject in january? Given all the holidays and so, I figure it's better to not rush it since we might all not be able to follow everything. Regarding the name, even though I disagree I still think the discussions are sane and interesting. And about NIH:
I don't see a de facto solution. But for me, this interface could be named And it has been said, but having |
@mnapoli I will also use Good to set a date, January makes sense -- maybe folks would be willing to describe the larger picture of how service providers, services, and containers fit together. I tend to disagree that we should avoid Having said that, in the end, I've got no problem adopting the potato interface. Interoperability is the goal. |
January is fine for me. We should take the time which is needed for the final decision. Or at least the time needed to let me convince you that "BakedPotatoesGeneratorInterface" is not the right choice ;) |
I don't see a use case for standardization of a "writable" container interface. That's really something tightly coupled with how the framework/user wants to code his own DIC stuff, and I don't see any space for standardization there. I'd rather go with Why?
class LocatorInterface
{
public function get($request);
public function has($request);
} That's my idea for it so far |
+1 @Ocramius |
I pretty much like the |
I like @Ocramius's proposal fine. Though, as I voiced in another thread, choosing method names by selecting the most popular method names used among containers is the exact opposite approach we should be using. |
Was thinking about this over and over again. I am still not yet that happy with the suggestions. I do not like the name LocatorInterface as for me it implies at the implementation is "locating" an object which is not what`s really happening. To me this sounds like the implementation is about searching for the requested object. What is really happening is that the implementation of the interface creates objects or manages object instances. For that reason I would prefer either ObjectFactory as mentioned before or ObjectStore. For the latter @AmyStephen might probably argue that we need writeable methods again ;) |
@shochdoerfer what about configs and scalars that may come from the locator (not values, constants)? Also, no, I don't want to force write access on implementations. I also don't see how that would increase interoperability: a ZF2 app does not write services into the SF2 or Silex containers, and the opposite wouldn't happen either. |
Nope. We shouldn't imply that the container-thingy has to create anything or that the things have to be objects.
Good points, especially the "denies the idea that the object actually 'contains' something". I think I think |
Hey all, thanks @jeremeamia for re-viving this thread after the holidays. I especially agree with what you said. It seems we are moving forward. I set up a quick summary of the options (and opinions expressed) in the wiki: https://github.com/container-interop/container-interop/wiki/ContainerInterface-name Please note this is not a vote, this is just to try to see where we are after all these discussions. Before you jump at me ;) :
(given this is the wiki, everyone should have write access) Just a side-note to express my |
We're not working on DIC here - this is service location. Standardizing DIC is way out of scope for now, given that there's not even a single container out there that has anything in common with the others (at least from what I know, and I worked with a lot of 'em). There's no DIC people here, only locators so far. Container is a no-go. If my object produces non-shared instances then it's not a container. It does not contain stuff. |
Really? Was not aware of that. At least in the projects` README.md it is stated that the project "tries to bring interoperability between DI containers" Should that be changed then?
Does that mean I have to leave for now? |
@shochdoerfer ofc not :D I just think it makes little sense to standardize something for which I didn't see a "simil-silver-bullet" around yet. And yes, that's as far as we can go without creating something bloated :P |
@Ocramius like @shochdoerfer I'm a bit confused about what you said. Is that what you are trying to say:
We still have to keep in mind that everybody's goal here is container interoperability, not SL standardization. Thanks to the discussion, I'm beginning to like
class MyController {
public function __construct(LocatorInterface $locator) {
$this->locator = $locator;
}
// ...
} Here |
A dependency injection container (DIC) and a service locator are the exact same thing. Only in PHP have I ever seen arguments that they are somehow different. |
Still contains stuff, and still is redundant: the only interfaces I saw not
|
Those were nice 5 days without emails :), maybe it's time to get to a vote? That raises several questions:
I'd suggest to use a range voting: rate each option with either:
Then we add the points and voilà. |
@mnapoli I am fine with that procedure. |
I definitely agree with range voting. Maybe we could even extend the range.
Anyway, extending the range can be more complex to voters, and if there are people preferring to stay with -1, 0, +1, I'll be glad to go with that range. |
Voting is fine, but does anyone really disagree with Given the discussion of what the On Sun, Jan 19, 2014 at 11:28 AM, David Négrier notifications@github.comwrote:
|
Yeap, I disagree with Marco Pivetta On 19 January 2014 19:14, AmyStephen notifications@github.com wrote:
|
@AmyStephen: indeed, it is likely that ContainerInterface will be the way to go. My understanding is that all propositions have received critics but ContainerInterface is only strongly opposed by Marco so far, while most of the other members of this discussion think this is maybe not optimal, but mostly ok. However, the wiki page clearly states "this is not a vote". Therefore, I would feel inconfortable turning that wiki page into a decision. Especially, I don't want anyone to fill bad about it. So a vote might be the best way to avoid trouble. Also, if we arrive to push this far enough, we will certainly have the chance to discuss once more the naming of that interface on the FIG mailing list, for a PSR :) |
I agree that a vote is sane :) @moufmouf I'd rather stay with a simpler vote format (-1/0/+1) if that's ok with you? That would be consistent with the poll and simpler to vote. |
@mnapoli Ok for staying with (-1/0/+1). This was just a proposition, and as long as we get the vote done, I'll be more than happy. Shall we get the vote started now? Where should we vote? In this thread? In a dedicated app/website? |
OK vote started, I suggest to open it for 2 weeks (like the FIG IIRC). I used the wiki like for the poll, at least everyone has read/write access and we can keep the discussion out of it. Link: https://github.com/container-interop/container-interop/wiki/%231-interface-name:-Vote Please cast your votes ;) |
Came to the discussion pretty late, had a read through comments and added my vote to the wiki as requested. |
@happyaccidents I am sorry to say that but the vote is limited to people having participated in the discussion before it started :/ I wish it where otherwise because I know your interest on the subject, but I believe we have to stand by what was said to keep things proper, and avoid exceptions potentially leading to other exceptions (where would be the limit). |
@mnapoli that's fine, only just read your tweet to join so my fault, not a problem |
@mnapoli Do we need to keep the vote open until Feb 3, even though (I think) everyone who participated previously has now added their vote to the wiki page? |
@dongilbert I checked, everybody voted, I see no reason to wait unless someone wants to change his mind? So it looks like @happyaccidents thanks |
Here is the detailed result, which shows
|
I have renamed the interface: https://github.com/container-interop/container-interop/blob/master/src/Interop/Container/ContainerInterface.php Thank you everyone who participated! The discussion was definitely constructive and not unnecessary, I'm glad we came to a reasonable compromise. Now to be tagging a v1.0 with
I invite you all to check out those issues. I'll close this one! |
@mnapoli can you rename the milestone? :) |
@Ocramius done :) |
Why is this still being called a container? |
@J7mbo https://github.com/container-interop/container-interop/wiki/%231-interface-name:-Vote Let's not reopen that discussion as it has already been a lengthy one finished a year ago. You can re-read the whole thread if you want to understand people's opinions. See also the meta-document: https://github.com/container-interop/container-interop/blob/master/docs/ContainerInterface-meta.md#interface-name |
@J7mbo This issue has been closed for 1 year now. Regarding container-interop, the Now, we are trying to move container-interop to the PHP-FIG (https://groups.google.com/forum/#!forum/php-fig), so of course, we can discuss naming of the interface of the soon-to-come PSR. I would prefer if you ask this question on the PHP-FIG mailing list rather than in this thread that should remain closed. Of course, the |
@moufmouf Actually I'd prefer to be in a discussion: Please don't assume that I'm out for an aggressive attack that you have to 'defend' against. I think The reasons for that are that a container implies something that holds objects - if you place objects in this box, you're already advocating the service locator pattern and creating a god object. Let's not even get onto how Laravel names things. Call it a container and we're really not progressing in teaching best practice to the PHP community - which is what FIG is supposed to be standing up for. It should be Injector imho, however the decision has already been made. |
To be honest, most of the people that discussed in this thread have little to do with Symfony anyway.
Yes, we are. The fact is that the only possible interface for an Injector or a DIC or a Container is indeed a locator. Even in "higher level" libraries having a single location where the injector is used, SL is how this is achieved (see, for example, Additionally, an interface without
I actually agree with that, but a vote has already been set for the name, even if I disagree with it. From now on it's either accept or reject the proposal for it, and we may reconsider naming if the voting fails, I'd say.
No, you are confusing http://www.phptherightway.com/ with FIG. FIG is about Framework-Interoperability, which (in other words) means "let's stop stepping on each other work and let's work together", where the
Injector does not apply, mainly because then we'd design an interface for a factory, and tbh, If you want to explore the injector concept more, then feel free to write down a new proposal that deals with DI configuration/setup and all the details that can be commonly adopted by all frameworks. |
@Ocramius Ah yes, I was confusing FIG and phptherightway ;D Thanks for your response |
Hi! Sorry to bother 12 participants, but this seemed like the most appropriate place to ask this. Nowhere in the inline or otherwise docs have I managed to find whether methods implementing |
@XedinUnknown Could you please open a new issue? It's a different discussion, and people involved in this one might not be interested in this new one (especially since it involves a lot of people) |
So far, we have chosen to call the main interface ReadableContainerInterface.
The rational behind it is that "ContainerInterface" might be too generic.
We thought about "SimpleContainerInterface" but deemed it was too generic.
This thread is open to add new suggestions.
So far, I have just started looking at other languages.
Spring (in the Java world) has a "BeanFactory" interface, with a "getBean" method.
Add other suggestions (or what other frameworks do below)
Edit:
The text was updated successfully, but these errors were encountered: