Interface Segregation Principle
noun
say it: “IN-ter-fays seg-ruh-GAY-shun PRIN-suh-pul” /ˈɪntərˌfeɪs ˌsɛɡrəˈɡeɪʃən ˈprɪnsəpəl/
The principle that a big interface should be split into small ones, so no class has to keep a promise it can't and no code depends on methods it doesn't use.
What is Interface Segregation Principle?
The Interface Segregation Principle says to prefer several small interfaces over one big one, so classes aren't forced to provide methods they don't need.
// Instead of one IMachine with Print, Scan and Fax:
public interface IPrinter { void Print(string doc); }
public interface IScanner { string Scan(); }
public class BasicPrinter : IPrinter { public void Print(string doc) { } }
In a sentence
- “Following the interface segregation principle, only courses with labs keep the lab promise now.”
Level: Freelancer · More OOP terms at this level
Updated