title: Understanding Adapter Pattern
body: <p>I am trying to understand Adapter pattern and its use in real world. After going through various articles on internet and www.dofactory.com, I created this sample code. I just want to know whether my understanding is correct. In the example below I have created MSDAO object in the Adaptor class. Later I changed it to OracleDAO.</p>
  
  <pre class="lang-cs prettyprint-override"><code>class Client
  {
    static void Main(string[] args)
    {
      ITarget objAdapter = new Adapter();
      object dummyObject = objAdapter.GetData();
    }
  }
  
  Interface ITarget
  {
    public void GetData();
  }
  
  //Decision to use MSDAO
  
  class Adapter : ITarget
  {
    public void GetData()
    {
      MSDAO objmsdao = new MSDAO();
      objmsdao.GetData();
    }
  }
  
  //After a month, the decision to use OracaleDAO was taken, so the code change
  
  class Adapter : ITarget
  {
    public void GetData()
    {
      OracleDAO objoracledao = new OracleDAO();
      objoracledao.GetData();
    }
  }
  </code></pre>