User Documentation

One minute description
Two minute tutorial
Five minute introduction
Advanced Topics
FAQ
Container
Components
Terminology
Mock Objects
Inversion of Control Types

Patterns

Inversion of Control 
Dependency Injection 
Constructor Injection 
Setter Injection 
Interface Implementation Separation 
Lifecycle 
Antipatterns

Developer Documentation

 Current build status
How To Contribute
Relative Volunteering
Release Process

Project Information

Slogan
Mailing lists
Source Repositories
Open Issues
Blog entries 
Statistics
Team
Sister Projects
TShirts

Miscellaneous

Differentiators
Nirvana

Full Sitemap

Feeds


Site
News
Concrete Class Dependency

Symptoms

A 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 {
}

Causes

Laziness

What to do

In order to reduce A's tight coupling, split B in an Interface Implementation Separation.

public interface B {
}

public class BImpl implements B {
}