title: c# interface segregation principle example confusion
body: <p>I'm fairly new to programming and i'm having trouble to understand how to apply effectively the principle showed in the following link (the ATM one):</p>
  
  <p><a href="http://www.objectmentor.com/resources/articles/isp.pdf" rel="nofollow noreferrer">http://www.objectmentor.com/resources/articles/isp.pdf</a></p>
  
  <p>Basically it starts with a design that does not complain the ISP (Interface Segregation Principle), and moves forward to refactor the behavior into different interfaces.</p>
  
  <p>My question is: <strong>Don't we use interfaces to express common behaviour among not so (or not) related abstractions?</strong></p>
  
  <p>What's the point of encapsulating methods in an interface, if not even one is going to be shared with the classes that are going to implement them? In which scenario this could be consider useful?</p>
  
  <p>If we continue the line of the example, the following code is given:</p>
  
  <pre><code>public interface ITransaction
  {
      void Execute();
  }
  
  public interface IDepositUi
  {
      void RequestDepositAmount();
  }
  
  public class DepositTransaction : ITransaction
  {
      private IDepositUi depositUI;
  
      public DepositTransaction(IDepositUi ui)
      {
          depositUI = ui;
      }
  
      public virtual void Execute()
      {
          /*code*/
          depositUI.RequestDepositAmount();
          /*code*/
      }
  }
  
  public interface WithdrawalUI
  {
      void RequestWithdrawalAmount();
  }
  
  public class WithdrawalTransaction : ITransaction
  {
      private WithdrawalUI withdrawalUI;
  
      public WithdrawalTransaction(WithdrawalUI ui)
      {
          withdrawalUI = ui;
      }
  
      public virtual void Execute()
      {
          /*code*/
          withdrawalUI.RequestWithdrawalAmount(); /*code*/
      }
  }
  
  public interface TransferUI
  {
      void RequestTransferAmount();
  }
  
  public class TransferTransaction : ITransaction
  {
      private TransferUI transferUI;
  
      public TransferTransaction(TransferUI ui)
      {
          transferUI = ui;
      }
  
      public virtual void Execute()
      {
          /*code*/
          transferUI.RequestTransferAmount();
          /*code*/
      }
  }
  
  public interface UI : IDepositUi, WithdrawalUI, TransferUI
  {
  }
  </code></pre>
  
  <p>As far as i understand this, in order to use the previous design we should have something like:</p>
  
  <pre><code>UI impui = new IMPLEMENTATIONUI(); // Some UI implementation
  DepositTransaction dt = new DepositTransaction(Gui);
  dt.Execute();
  </code></pre>
  
  <p>Now, wouldn't we need that the IMPLEMENTATIONUI implements every single method? And if so, wouldn't it break the SRP?.</p>