Code Monkey home page Code Monkey logo

Comments (9)

joelhooks avatar joelhooks commented on August 17, 2024

I went ahead and made this change in my childinjectors branch on my fork.

from swiftsuspenders.

tschneidereit avatar tschneidereit commented on August 17, 2024

I see that you've since rolled back your change. What made you reconsider?

from swiftsuspenders.

joelhooks avatar joelhooks commented on August 17, 2024

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.

tschneidereit avatar tschneidereit commented on August 17, 2024

hehe ;)
Yeah, that API wasn't an easy design at all ...

from swiftsuspenders.

darscan avatar darscan commented on August 17, 2024

"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.

tschneidereit avatar tschneidereit commented on August 17, 2024

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.

darscan avatar darscan commented on August 17, 2024

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.

tschneidereit avatar tschneidereit commented on August 17, 2024

You absolutely insist on having the last word on this entire topic, don't you? ;)

(Obviously, being right helps with that ...)

from swiftsuspenders.

darscan avatar darscan commented on August 17, 2024

Yes.

from swiftsuspenders.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.