Interface Segregation Principle - ISP

A class should not be forced to do what it does not do. What? Yes, the way you built interfaces can cause this side effect.

The Interface Segregation Principle (ISP) says says that class should not be forced to depend on method it does not use.

To table this, segregate a interfaces in more and specialized ones.

Example:

Imagine that you want to extract Bird behaviors for an interface.

interface Bird
{
    public void putEggs();
    public void peck();
    public void fly();
    public void land();
}

Seems good, right? But what about penguins, chickens or other birds that does not fly? To solve this we can segregate the Bird interfaces in more specialized ones:

interface Bird
{
    public void putEggs();
    public void peck();
}

interface Flying
{
    public void fly();
    public void land();
}

class Penguin implements Bird
{
    //...
}

class Chicken implements Bird
{
    //...
}

class Falcon implements Bird, Flying
{
    //...
}