title: Inheritance - Handling child specific code in base class
body: <p>We have a parent class - Platform. All the specific device class are inherited from this parent Class - Device1, Device2, ..... DeviceN. </p>
  
  <p>Based on the device input, we create an object of the respective Device class and work accordingly.</p>
  
  <p>Few things which I observed in this code is the handling of device specific behavior in the base class (Platform class). Example,</p>
  
  <pre><code>function doSomething
  {
      initiateSomething();
      .
      if ($base-&gt;getPlatform() eq 'Device1')
      {
          ........
      }
      startSomething();
      doneSomething();
  }
  </code></pre>
  
  <p>This type of conditional device specific code is spreaded over various places in the parent class. This code is specific to Device1 and not applicable for other devices. I thought of putting this device specific code in Device1 class as a function and calling it here, but that also did not work. Because this function is implemented only for Device1, so running this code for other Devices fails. </p>
  
  <p>Your help will be highly appreciated.</p>