From the course: Advanced Design Patterns: Design Principles

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Interface segregation principle

Interface segregation principle

- [Instructor] Our next principle is the interface segregation principle. Which says that classes should not be forced to depend on methods that they don't use. You can also look at this principle as all about the disadvantages of what we might call a polluted interface. Let's say we're creating an implementation for a new company producing vending machines. Their first machine brews coffee and so let's create a simple interface for the machine. This interface has a method to take money from the customer and it also supports a brew coffee method. Through some quick innovation and ingenuity the coffee vending machine is updated to support the brewing of hot chocolate and even hot tea. So let's expand the interface to include these new offerings with two new methods; brewHotChocolate and brewTea. Let's say down the road the company creates a brand new vending machine which is aimed at the cold beverage market. It…

Contents