Comments (9)
I went ahead and made this change in my childinjectors branch on my fork.
from swiftsuspenders.
I see that you've since rolled back your change. What made you reconsider?
from swiftsuspenders.
shaun yelled at me. ;) - not really, he sent me links and didn't like the change. I still don't like it, but it is consistant with SmartyPants and others so it is cool. I know it was debated a lot.
from swiftsuspenders.
hehe ;)
Yeah, that API wasn't an easy design at all ...
from swiftsuspenders.
"shaun yelled at me" hahaha!! that prick! but seriously, if getInstance didn't throw an error the world would become a strange and unpredictable place. The word "or" is the clue here. "Retrieve an instance from the container if a rule exists OR instantiate a new instance if one does not". There would be no way to tell the two scenarios apart.
This is especially dangerous with singletons - you wouldn't be able to tell if you are being given a singleton (as you might expect due to some design) or a new instance. "instantiate" already causes some confusion in this regard: people map a singleton and then use "instantiate" expecting to be given the same instance that other parts of the system will be given.. but that's not what happens of course. "getInstance" is the remedy to this scenario, and having it fall back to "instantiate" behavior just muddies the waters :)
from swiftsuspenders.
I fully concur!
I also agree about instantiate being a bit unfortunate. I think 2.0 will see some interface cleanup during which instantiate might just as well get lost.
from swiftsuspenders.
Ah yes, but instantiate is still useful: MediatorMap, CommandMap - places where we actually want new instances (regardless of rules) with fully satisfied dependencies (including ctor args).
from swiftsuspenders.
You absolutely insist on having the last word on this entire topic, don't you? ;)
(Obviously, being right helps with that ...)
from swiftsuspenders.
Yes.
from swiftsuspenders.
Related Issues (20)
- Named injections, map.toValue(null), satisfies() and getInstance() HOT 6
- Metadata.xml HOT 5
- loggable warning HOT 4
- Reflector HOT 1
- Support destruction of instances and teardown of entire containers HOT 21
- Building the SWC HOT 7
- ApplicationDomain::getDefinition Explodes Fantastically HOT 1
- Teardown nulls the _mappings dict
- DescribeTypeReflector VerifyError: Error #1068: String and * cannot be reconciled. HOT 3
- Asymmetry between satisfies & satisfiesDirectly HOT 2
- More specific InjectorError sub types HOT 4
- Null values passed to Injected constructor with multiple name-quailified injections HOT 13
- Can't build with Maven HOT 3
- Versioning HOT 6
- Feature Request -- "Mapping"-specific injections
- InstantiateUnmapped Performance HOT 2
- Injector still needs an interface ... HOT 6
- docs HOT 1
- Updated build script to preserve code comments in SWC HOT 2
- No issue , is suggest HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftsuspenders.