Property Injection
Exposes dependencies by using properties via [[getters]] and [[setters]]. Allows replacing the Dependency during the [[lifetime]] of the object.
The flexibility is a main advantage, but it should always be used only for [[optional dependencies]]. It can easily break the encapsulation and make dependencies hidden.
Pitfalls:
- Breaks Encapsulation
public class Customer
{
public Customer()
{}
public ILogger logger { get; set; } = new Logger();
}