Inheritance is often explained in terms of cars and animals because those learning it are often familiar with such concepts. However my life as a programmer would be much more difficult if it weren't for the powers that inheritance provides. I have too many cases to list here, but some examples that immediately spring to mind:
- Users - Many systems have different types of users. Staff, clients, admins, auditors, and so on. Very often these all have a common set of methods and properties, and some are even sub-classes of each other (eg, admins are a special type of staff). This is one area that keeps coming up again and again.
- CPAN modules - CPAN is great, but what happens when you find a module that does almost what you want, but not quite? You want it to do just a little bit more, or something a little bit differently? This is an excellent opportunity for inheritance. Without having to change the exist code you can add new features and functionality to your favourite CPAN modules.
- The Finance::Quote::Yahoo::* modules all inherit from a common base. Yahoo provides excellent market information, but it varies from exchange to exchange. By inheriting from a common base, much time and effort is saved.
- Portlets - I've worked for a number of portal businesses over my career, and guess what? Each 'portlet' or property inherits from a common class.
- Much much more - CPAN provides a wealth of examples for using inheritance. Like any tool, the more you use it, the more familiar you become with its best applications.