Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I inheriting from a concrete class in Perl?
    primarykey
    data
    text
    <p>Our software represents each device as a concrete class. So let's say I have a class named <code>Cpu-Version-1</code>, which is derived from a abstract baseclass called <code>Device</code>. Now, the CPU vendor wants to release the economic version of this CPU ( <code>Cpu-Version-2</code> ), which is a feature reduced version of <code>Cpu-Version-1</code> (obviously for a lower price ). 90% code of <code>Cpu-Version-2</code> is same as of <code>Cpu-Version-1</code>, but the remaining 10% code is no longer same. i.e. these are the features that have been removed in <code>Cpu-Version-2</code> and so I should no longer represent it.</p> <p>Now what would be the best way to design this class? I could inherit <code>Cpu-Version-2</code> from <code>Cpu-Version-1</code> (even though the inheritance is imperfect, since these two devices are peers). This would force me to override a lot of methods of cpu-version-1 to do nothing ( which looks ugly and somehow doesn't feel right). Also I don't think I could change the baseclass (<code>Cpu-Version-1</code> or it's base) since the code is already in production and requires lot of approvals and justification. How would you make this design decision if you were me?</p> <p>How do we make <code>Cpu-Version-2</code> as much reusable and maintainable? Is there any OOP principles that you would follow? Or is it better tradeoff to take the easy wayout and override all the non-applicable methods of <code>Cpu-Version-1</code> to do nothing? I code in object-oriented Perl.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload