Interface Segregation
On This Lesson 4 topics
The content for this lesson is written and waiting for review. The outline below shows what it covers. It will be published once it is approved.
In this lesson
keep interfaces small and focused.
Planned topics
- I: do not force a class to implement methods it does not use.
- A large interface makes many empty or throwing methods.
- Split into small interfaces, each for one role.
- Clients depend only on what they use.
- Example:
ReadableandWritableinstead of oneStorage.
Draft outline details
Demonstration
interface PriceReader { Money priceOf(Sku sku); }
interface PriceWriter { void save(Sku sku, Money price); }Check your understanding
What problem does a fat interface cause?
Show answer
Implementers must provide methods they do not need.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.