title: In the context of Autofac: What is the difference between a Service and a Component?
body: <p>What exactly is the difference between a <code>Service</code> and a <code>Component</code>? And how does the extension method <code>RegisterComponent()</code> relate to this definitions? </p>
  
  <p>Autofac's glossary defines it as follows:</p>
  
  <p><strong>Component</strong></p>
  
  <blockquote>
    <p>A body of code that declares the Services it provides and the
    Dependencies it consumes</p>
  </blockquote>
  
  <p><strong>Service</strong></p>
  
  <blockquote>
    <p>A well-defined behavioural contract shared between a providing and a
    consuming Component</p>
  </blockquote>
  
  <p>This confuses me.. Would it be correct to say, that a component <em>uses</em> several services? Something like the example below?</p>
  
  <pre><code>public interface IServiceA
  {
      void DoSomething();
  }
  
  public ServiceA : IServiceA
  {
      void DoSomething()
      {
          // Do some magic 
      }
  }
  
  public class ComponentA
  {
      private readonly IServiceA serviceA;
  
      public ComponentA(IServiceA serviceA)
      {
          this.serviceA = serviceA;
      }
  
      public void SomeOperation()
      {
          this.serviceA.DoSomething();
      }
  }
  </code></pre>
  
  <p>Or is a component always an implementation of a service/interface? I just don't get it. </p>
  
  <p>I would be thankful if somebody could clarify with a catchable example. </p>