3.4.6 How to Implement Multiple Interfaces

Unlike inheritance, classes can implement multiple interfaces. Let's say we have another interface named ITransactionable that has some members to implement.

Our Booth is an ICleanable already, but could also be an ITransactionable. To do this, we will add it to the Booth class header using a comma.

Of course we will need to make sure the class implements the ITransactionable interfaces, but now we have made sure that the Booth has members related to being cleanable and being capable of making transactions.


Giving a class multiple interfaces allows us to treat an object like different things if we need it to. Say we want all cleanable things to do something, we can treat a Booth object as an ICleanable and everything else in that class that doesn't have to do with an ICleanable goes away. Then later if we want to treat it as an ITransactionable we can do that and everything not related to being able to perform a transaction goes away.


Using multiple interfaces is a common solution for avoiding what is called "fat interfaces". Fat interfaces are interfaces that have too many members. The problem with having too many members is that it makes interfaces pointless. Ultimately, the goal of an interface is to lock down specific functionality of an object by treating it as a specific thing. The more we add to an interface the more general the implementation become and defeats the purpose of limiting functionality in the first place.