Interface Segregation Principle
The interface segregation principle in SOLID: give each client a small interface holding only the methods it calls.
The interface segregation principle is the I in SOLID. It says that no class should be forced to depend on methods it does not use. A large interface makes every implementer write methods it has no use for, and makes every caller depend on methods it never calls.
The topic starts with that rule and a Worker interface that forces a robot to pretend it eats, in Python, Java and TypeScript. It then splits the interface step by step, shaping each piece around the code that calls it. Two examples follow: the Xerox printer job where the principle was first described, and Python's collections.abc, a standard library built from small interfaces.
The last cards show the opposite mistake, an interface per method, and give you a storage interface to split.
By the end you can spot a forced method, split an interface by the clients that use it, and judge when splitting has gone too far.
Contents
8 cardsnot started