concept Code in category dependency injection

This is an excerpt from Manning's book Dependency Injection.
You can compose classes into an application in several ways. When we discussed late binding, we used a configuration file and a bit of dynamic object instantiation to manually compose the application from the available modules. We could also have used Configuration as Code using a DI Container. We’ll return to these in chapter 12.
Listing 4.6
Currency,Money, and theICurrencyConverterinterfacepublic interface ICurrencyConverter { Money Exchange(Money money, Currency targetCurrency); } public class Currency { public readonly string Code; public Currency(string code) { if (code == null) throw new ArgumentNullException("code"); this.Code = code; } } public class Money { public readonly decimal Amount; public readonly Currency Currency; public Money(decimal amount, Currency currency) { if (currency == null) throw new ArgumentNullException("currency"); this.Amount = amount; this.Currency = currency; } }
As we stated in section 12.2.4, none of the available approaches are mutually exclusive. Although you might find a single Composition Root to contain a mix of all configuration styles, a Composition Root should either be focused around Pure DI with, perhaps, a few late-bound types, or around Auto-Registration with, optionally, a limited amount of Configuration as Code, Pure DI, and configuration files. A Composition Root that focuses around Configuration as Code is pointless and should therefore be avoided.