Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://305003]
[ovedpo15]: how to fast count all hash keys with value 1? (if possible without loop)
[LanX]: scalar grep {$_ ==1 } keys %hash
[ovedpo15]: maybe even better question is if it possible to pash element to array from left. I mean that the element will enter array[0] and all other elements will move right +1

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2018-03-24 21:19 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (299 votes). Check out past polls.