title: Purpose of having API wrapped around interface
body: <p>I am working on a piece of C# web application that has a page (MainPage) with a small area to display a gadget. There are several kinds of gadgets implementing a main interface (IMainInterface) and an optional interface (IOptionalInterface).</p>
  
  <p>In MainPage, when interacting with the gadget class, it uses following syntax:</p>
  
  <pre><code>MyAPI api = new MyAPI();
  api.SomeMethod(gadgetClassName, param);
  </code></pre>
  
  <p>And in api.SomeMethod(...), it does following:</p>
  
  <pre><code>//  use reflection to get an IMainInterface based on gadgetClassName
  Type t = Type.GetType(gadgetClassName);
  
  IMainInterface gadget = (IMainInterface)t.InvokeMember(
      gadgetClassName,
      BindingFlags.CreateInstance,
      null,
      null,
      null);
  return gadget.SomeMethod(param)
  </code></pre>
  
  <p>Looking at this MyAPI class, it contains a whole bunch of methods that map to the corresponding methods defined in IMainInterface and IOptionalInterface. </p>
  
  <p>My question, is this MyAPI class really neccesary? Wouldn't it be less overhead if MainPage accesses interfaces(IMainInterface and IOptionalInterface) directly?</p>
  
  <p><strong>Update</strong>: seeing some of the answers, I realized that I wasn't explicit that the "several kinds of gadget" means different classes (e.g. CalendarGadget, TaskGadget).</p>
  
  <p><strong>Update 2</strong>: Added more code sample</p>