User DocumentationOne minute descriptionTwo minute tutorial Five minute introduction Advanced Topics FAQ Container Components Terminology Mock Objects Inversion of Control Types PatternsInversion of ControlDependency Injection Constructor Injection Setter Injection Interface-Impl Separation Lifecycle Antipatterns Developer DocumentationHow To ContributeRelative Volunteering Release Process Project InformationSloganMailing lists Source Repositories Open Issues Blog entries Statistics Team Sister Projects TShirts MiscellaneousDifferentiatorsNirvana Full Sitemap |
Concrete Class DependencySymptomsA class depends on other concrete classes. In order to favour decoupling (and thereby testability) we recommend depending on interfaces instead.public class A { private final B b; public A(B b) { this.b = b; } } public class B { } CausesLazinessWhat to doIn order to reduce A's tight coupling, split B in an Interface-Implementation Separation.public interface B { } public class BImpl implements B { } |