title: understanding single responsibility principal SRP in clean code example
body: <p>currently i'm reading the clean code Book of Uncle Bob,in the function section when looking to the following example:-<br/></p>
  
  <pre><code>public Money calculatePay(Employee e)
  throws InvalidEmployeeType {
      switch (e.type) {
          case COMMISSIONED:
              return calculateCommissionedPay(e);
          case HOURLY:
              return calculateHourlyPay(e);
          case SALARIED:
              return calculateSalariedPay(e);
          default:
              throw new InvalidEmployeeType(e.type);
      }
  }
  </code></pre>
  
  <p>Uncle Bob said:-<br/></p>
  
  <blockquote>
    <p>There are several problems with this function. First, it’s large, and
    when new employee types are added, it will grow. Second, it very
    clearly does more than one thing. Third, it violates the Single
    Responsibility Principle7 (SRP) because there is more than one reason
    for it to change. Fourth, it violates the Open Closed Principle8 (OCP)
    because it must change whenever new types are added</p>
  </blockquote>
  
  <p>he states a solution as following:-<br/></p>
  
  <pre><code>public abstract class Employee {
      public abstract boolean isPayday();
      public abstract Money calculatePay();
      public abstract void deliverPay(Money pay);
  }
  -- -- -- -- -- -- -- -- -
  public interface EmployeeFactory {
      public Employee makeEmployee(EmployeeRecord r) throws InvalidEmployeeType;
  }
  -- -- -- -- -- -- -- -- -
  public class EmployeeFactoryImpl implements EmployeeFactory {
      public Employee makeEmployee(EmployeeRecord r) throws InvalidEmployeeType {
          switch (r.type) {
              case COMMISSIONED:
                  return new CommissionedEmployee(r);
              case HOURLY:
                  return new HourlyEmployee(r);
              case SALARIED:
                  return new SalariedEmploye(r);
              default:
                  throw new InvalidEmployeeType(r.type);
          }
      }
  }
  </code></pre>
  
  <p>I can not fully understand the idea from the example and there is some question in my head i can not find answers to :-<br/></p>
  
  <p>1- in first code when new employee is added it will grow. true but also this occurs in the solution so what is the difference ?<br/><br/>
  2- how the first example does more than one thing . it only calculate payment "functions at the same level of abstraction" notice that if we consider throw error is another thing to do , the solution does it too<br/><br/></p>