Automatic Module Discovery With Autofac – Simplified Registration
If you're familiar with Autofac and module registration but want to make things easier, automatic module discovery might be for you! Let's see how it works!
If you're familiar with Autofac and module registration but want to make things easier, automatic module discovery might be for you! Let's see how it works!
An progress pulse update into the development of Macerus RPG and ProjectXyz game framework leveraging Unity3D. Part 1 of the progress pulse series.
In Unity3D, the scripts we write and attach to GameObjects inherit from a base class called MonoBehaviour (and yes, that says Behaviour with a U in it, not the American spelling like Behavior... Just a heads up). MonoBehaviour instances can be attached to GameObjects in code by calling the AddComponent method, which takes a type parameter or type argument, and returns the new instance of the attached MonoBehaviour that it creates. This API usage means that: We cannot attach existing instances of a MonoBehaviour to a GameObject Unity3D takes care of instantiating MonoBehaviours for us (thanks Unity!) ... We can't pass parameters into the constructor of a MonoBehaviour because Unity3D only handles parameterless constructors (boo Unity!) So what's the problem with that? It kind of goes against some design patterns I'm a big fan of, where you pass your object's…
Why Consider Using Autofac With Unity3D? I think using a dependency injection framework is really valuable when you're building a complex application, and in my opinion, a game built in Unity is a great example of this. Using Autofac with Unity3D doesn't need to be a special case. I wrote a primer for using Autofac, and in it I discuss reasons why it's valuable and some of the reasons you'd consider switching to using a dependency container framework. Now it doesn't need to be Autofac, but I love the API and the usability, so that's my weapon of choice. Building a game can result in many complex systems working together. Not only that, if you intend to build many games it's a great opportunity to refactor code into different libraries for re-usability. If we're practicing writing good code using constructor…
Looking to get started with Autofac in your C# projects? Here's a quick primer on what it is and how to get going for your next project
Background The very first thing I want to say is that I don’t think singletons are inherently bad–even if it means I am cast away from the rest of the programming world. There’s a time and a place for the singleton. It’s really common for people to get caught up with their perspective on something that they outright refuse to acknowledge the other side of it. I’d also like to point out that if you have a strong opinion on something and you find that other people also have a strongly opposing opinion on the same thing, there’s probably good take away points from either side. In this post though, I’m going to focus on why singletons are “bad”, because for me it means acknowledging one of the two main perspectives–that they are the best thing since cat videos met…