Git Product home page Git Product logo

Comments (10)

nyctef avatar nyctef commented on August 15, 2024 1

I've used Autofac on Figleaf and Ninject on Compare. I have a slight preference for Ninject because Autofac lets you write builder.RegisterType<CompletelyUnrelatedType>().As<IInterfaceIActuallyWanted>(); which IIRC is a compile error with Ninject's API. Apart from that they're basically equivalent as far as I can tell - never used them in a performance-sensitive manner since we mostly just inject high-level services.

from tech-radar.

Michael-Upton avatar Michael-Upton commented on August 15, 2024 1

Whereas I disagree almost entirely. I find Autofac easier to read and use, more powerful (lists, factories, and lifetimes controlled in an intuitive way with IEnumerable<T>, Func<T>, and Lazy<T>/Owned<T>) and I prefer its opinionated approach (configure then build, the injectee doesn't get to control how things are injected in to it, etc.).

Autofac does decorators too (https://autofaccn.readthedocs.io/en/latest/advanced/adapters-decorators.html) - the registration is just potentially backwards to the way you're thinking of.

(as an aside, I think overuse of that decorator pattern is bad anyway - a lot of the time it strikes me as a way of using something very like inheritance without taking advantage of the language support, just because inheritance is bad. I'd prefer most things that use decoration to be using chaining/composition instead)

from tech-radar.

fffej avatar fffej commented on August 15, 2024 1

Sounds like this is a coin toss 😄 They both have almost the same amount of ⭐️ and questions on Stackoverflow.

There seems to be a slight preference for AutoFac (and from me I think the documentation for AutoFac looks great), so I'm going to suggest:

Adopt:

  • AutoFac

Endure (since I don't think there's any benefit for removing NInject from projects that already use it)

  • Ninject

PR welcome?

from tech-radar.

tugberkugurlu avatar tugberkugurlu commented on August 15, 2024 1

PR welcome?

I can PR this ✋

from tech-radar.

tugberkugurlu avatar tugberkugurlu commented on August 15, 2024

I would have thought that most of our codebases default to Autofac nowadays?

from tech-radar.

adrianbanks avatar adrianbanks commented on August 15, 2024

SQL Source Control uses Ninject (and so does SQL Compare Engine and the Oracle tools from doing a quick search).

from tech-radar.

ChrisHurley avatar ChrisHurley commented on August 15, 2024

We use Autofac on Clone. I've never used Ninject (when I look for comparisons, they mostly just note that Ninject is much slower than alternatives at resolving, or at least was).

from tech-radar.

ChrisHurley avatar ChrisHurley commented on August 15, 2024

(Sorry, fumbling around - didn't mean to do any of that)

from tech-radar.

ChrisLambrou avatar ChrisLambrou commented on August 15, 2024

Ninject also supports some common DI patterns way better than Autofac. The one I keep coming across is where you have two implementations of an interface, and you want everyone to use the first implementation (a decorator), except when constructing the first implementation, which needs to decorate an instance of the second implementation (the decorated). Personally I much prefer the usability and readability of Ninject over Autofac.

from tech-radar.

ChrisLambrou avatar ChrisLambrou commented on August 15, 2024

Aw, I was hoping that the decorator syntax might have improved since I last used it, based on your comment. But it's still as poor as I remember it. It involves naming things, being obliged to make those names match across statements, and one of the lambdas directly invokes a constructor, which is just the kind of thing I want a DI system to stop me having to do.

To be honest, whenever I've flipped between Ninject and Autofac as I've switched projects, they're essentially interchangeable in all the ways that really matter. It probably doesn't matter which one we pick, as long as we just pick one.

from tech-radar.

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.