title: Avoiding anemic domain model - a real example
body: <p>I am trying to understand Anemic Domain Models and why they are supposedly an anti-pattern.</p>
  
  <p>Here is a real world example.</p>
  
  <p>I have an Employee class, which has a ton of properties - name, gender, username, etc</p>
  
  <pre><code>public class Employee
  {
      public string Name { get; set; }
      public string Gender { get; set; }
      public string Username { get; set; }
      // Etc.. mostly getters and setters
  }
  </code></pre>
  
  <p>Next we have a system that involves rotating incoming phone calls and website enquiries (known as 'leads') evenly amongst sales staff. This system is quite complex as it involves round-robining enquiries, checking for holidays, employee preferences etc. So this system is currently seperated out into a service: EmployeeLeadRotationService.</p>
  
  <pre><code>public class EmployeeLeadRotationService : IEmployeeLeadRotationService
  {
       private IEmployeeRepository _employeeRepository;
       // ...plus lots of other injected repositories and services
  
       public void SelectEmployee(ILead lead)
       {
           // Etc. lots of complex logic
       }
  }
  </code></pre>
  
  <p>Then on the backside of our website enquiry form we have code like this:</p>
  
  <pre><code>public void SubmitForm()
  {
      var lead = CreateLeadFromFormInput();
  
      var selectedEmployee = Kernel.Get&lt;IEmployeeLeadRotationService&gt;()
                                   .SelectEmployee(lead);
  
      Response.Write(employee.Name + " will handle your enquiry. Thanks.");
  }
  </code></pre>
  
  <p>I don't really encounter many problems with this approach, but supposedly this is something that I should run screaming from because it is an <strong>Anemic Domain Model</strong>.</p>
  
  <p>But for me its not clear where the logic in the lead rotation service should go. Should it go in the lead? Should it go in the employee? </p>
  
  <p>What about all the injected repositories etc that the rotation service requires - how would they be injected into the employee, given that most of the time when dealing with an employee we don't need any of these repositories?</p>