Course contentsShow
← Software Engineering
Lesson 217 of 1,9336. SOLID PrinciplesFree lesson

Splitting Interfaces by Client Needs

Learn to segregate interfaces into smaller, focused contracts tailored to specific client requirements and use cases.

Splitting Interfaces by Client Needs

What you'll learn: How to break down large interfaces into smaller, client-specific ones that each serve a focused purpose.

The Core Problem

In the previous lesson, you learned that "fat interfaces" force clients to depend on methods they never use. The solution? Split one bloated interface into multiple smaller interfaces, each tailored to what a specific client actually needs.

Think of it like a restaurant menu. A fat interface is like forcing every customer to order from a massive 200-item menu covering breakfast, lunch, dinner, desserts, and drinks—even if they only want coffee. Splitting by client needs means offering a "breakfast menu," "lunch menu," and "beverage menu" so each customer only sees what's relevant to them.

How to Split Effectively

Group methods by client usage patterns. Look at which clients call which methods. If Printer only needs print() and scan(), while Fax only needs send() and receive(), create separate interfaces:

  • IPrintable with print() and scan()
  • IFaxable with send() and receive()

Focus on client perspective, not implementation. Don't split based on how you'll build it—split based on what each client role needs to accomplish. A document editor needs printing capabilities; a network service needs faxing capabilities.

Use descriptive names. Call your interfaces by what they do for the client: IDocumentRenderer, IReportGenerator, INotificationSender. This makes their purpose immediately clear.

The Result

After splitting, each client depends only on the narrow interface it actually uses. Your code becomes more flexible—you can change IFaxable without affecting anything that only uses IPrintable. Changes stay contained, and clients aren't burdened by unrelated functionality.

Key Takeaway: Split large interfaces into smaller ones grouped by what each client actually needs, creating focused contracts that reduce unnecessary dependencies and increase flexibility.