Skip to content
Ameen Abozaid
In reviewJNR-004-L04

Interface Segregation

  • Lesson 4 of 7
  • 10 min read
  • Junior
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: Readable and Writable instead of one Storage.
Draft outline details

Demonstration

java
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.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.