there is some collections of related bindings for each sub-system and so it makes sense to group those bindings into a re-usable object. In Zenject this re-usable object is called an installer.
public class FooInstaller : MonoInstaller {
public override void InstallBindings() {
Container.Bind<Bar>().AsSingle();
Container.BindInterfacesTo<Foo>().AsSingle();
// etc...
}
}
public class BarInstaller : Installer<BarInstaller> {
public override void InstallBindings() {
...
}
}
public class FooInstaller : MonoInstaller {
public override void InstallBindings() {
BarInstaller.Install(Container);
}
}
BarInstaller is of type Installer<> (note the generic arguments) and not MonoInstaller, which is why we can simply call BarInstaller.Install(Container) and don't require that BarInstaller be added to our scene already.
the reason why we use installers as opposed to just having all our bindings declared all at once for each scene, is to make them re-usable.
use installer as a prefab or use ScriptableObjectInstaller