Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Real live usage of inheritance?

by pjf (Curate)
on Nov 06, 2003 at 10:12 UTC ( #305003=note: print w/ replies, xml ) Need Help??


in reply to Real live usage of inheritance?

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.


Comment on Re: Real live usage of inheritance?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://305003]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2014-08-23 18:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (177 votes), past polls