User Tools

Site Tools


principles:interface_segregation_principle
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


principles:interface_segregation_principle [2018-09-26 12:10] – created 62.228.239.6
Line 1: Line 1:
 +====== Interface Segregation Principle ======
 +===== Variants and Alternative Names =====
  
 +
 +===== Context =====
 +  * [[contexts:]] 
 +
 +
 +===== Principle Statement =====
 +Don't expose methods to your clients, methods that they don't use.
 +
 +===== Description =====
 +
 +
 +===== Rationale =====
 +Exposing functionality that the client class does not need at most a security risk and at the very least noise for the client class.
 +You don't want your class's clients to recompile if some method they don't use changed.
 +
 +===== Strategies =====
 +/*How to make a design more compliant to this principle*/
 +
 +===== Caveats =====
 +
 +See section [[#contrary principles]].
 +
 +
 +===== Origin =====
 +
 +
 +===== Evidence =====
 +/* Comment out what is not applicable and explain the rest: */
 +
 +/*  * [[wiki:Proposed]]*/
 +/*  * [[wiki:Examined]]*/
 +/*  * [[wiki:Accepted]]*/
 +/*  * [[wiki:Questioned]]*/
 +
 +===== Relations to Other Principles =====
 +
 +==== Generalizations ====
 +
 +==== Specializations ====
 +
 +==== Contrary Principles ====
 +
 +==== Complementary Principles ====
 +
 +==== Principle Collections ====
 +
 +
 +===== Examples =====
 +
 +==== Coffee Maker ====
 +Let's say your coffee maker logic receives input from various sensors which are external components to it. Eg: tankOutOfWater() and waterHeated() from the WaterTank and HeatSensor components respectively. You don't want the WaterTank component to be able to access the waterHeated() method. You can do this, by making your business logic implement the interfaces TankObserver and TemperatureObserver, each exposing the methods that can be accessed by each component. Then the component only knows how to talk to the interface, so the rest methods of the concretion are transparent to it.
 +
 +===== Description Status =====
 +/* Choose one of the following and comment out the rest: */
 +[[wiki:Stub]]
 +/*[[wiki:Incomplete]]*/
 +/*[[wiki:Complete]]*/
 +
 +===== Further Reading =====
 +
 +
 +===== Discussion =====
 +
 +Discuss this wiki article and the principle on the corresponding [[talk:principles:Interface Segregation Principle|talk page]].
principles/interface_segregation_principle.txt · Last modified: 2021-10-18 21:55 by christian