How to Explain Autofac Modules & Code Organization For Newbies

I've been writing a little bit about Autofac and why it's rad, but today I want to talk about Autofac modules. In my previous post on this, I talk about one of drawbacks to the constructor dependency pattern is that at some point in your application, generally in the entry point, you get allllll of this spaghetti code that is the setup for your code base. Essentially, we've balanced having nice clean testable classes with having a really messy spot in the code. But it's only ONE spot and the rest of your code is nice. So it's a decent trade off. But we can do better than that, can't we? What are Autofac Modules? We can use Autofac modules to organize some of the code that we have in our entry point into logical groupings. So an Autofac module…

2 Comments

Autofac Dependency Injection: Not as Difficult as You Think

I've written before about IoC and dependency injection, but these are older posts and my perspective and experience with these topics has fortunately been growing. I think they're incredibly important when you're building complex systems, but the concepts can offer some benefits in all of your programming! When you get in the habit of practicing this kind of thing, you can get some pretty flexible code... for free. We'll explore how Autofac can help here. So a quick recap on what I mean by dependency injection here... I'm mostly focused on passing interfaces into constructors (and yes, I'm going to be using C# terminology as I do in most of my programming examples, but these concepts are generally the same in other languages). The benefits here: You can write implementations that don't depend on other implementations... Just an API. Not…

4 Comments

End of content

No more pages to load