The Interface Segregation Principle
When designing the interface of an object, we should limit to define what is strictly necessary, avoiding carrying around stuff that is not used. This is, in a nutshell, the Interface Segregation Principle, whose official version says:
Clients should not be forced to depend on methods they do not use.
Although JavaScript does not support interfaces as abstract types to define contracts through a typing system, as we saw in Chapter 5, Defining Contracts with Duck Typing, it may somehow be emulated through Duck Typing. In any case, this principle does not refer to the interfaces as a pure syntactic element, but to the whole set of public properties and methods of an object.
In the definition of our object interfaces, therefore, we should be careful to only define what actually is necessary. This avoids the exposure of members that could create ambiguity and confusion.
Let's consider the following code:
function Discounter(min, max, discountPercentage, gadget...