CSE Roadmap

Common tier · about 2 hours · 6 parts

Part 4 of 6 · 1 min read

Choosing the cut

Group methods by who calls them together.

Splitting by gut feeling gives odd results. A steady method has three steps.

First, list the callers. Second, for each caller, write the methods it calls. Third, group methods that the same callers use together, and name each group by its role, such as Bookable or Describable.

Take the Place interface with four methods. Suppose the scheduler calls book, the menu calls describe, and the cleaning team's screen calls clean and unlock together. The groups are then Bookable, Describable and Maintainable (clean and unlock). Three small interfaces replace one big one, and each caller sees one of them.

Two cautions apply. If two groups are always used together by every caller, they probably belong in one interface. And a class may implement several small interfaces, so a Room that is bookable, describable and maintainable simply lists all three.

Check yourself: 1. What are the three steps of the method? 2. When should two groups be merged? 3. In the example, which methods form Maintainable?