Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Delegation is better than inheiritance when the object doesn't want to export the full interface of the parent class. It is also useful when the object wants to change the behavior so much that it isn't a direct replacement. Also, it is helpful when the relationship needs to be dynamic, if the "parent" class is dynamic, or the referenced object needs change dynamically.

For example, many network client classes inheirit from IO::Socket::INET. This is convienent for both internal and external use. But it fixes the clients to only use IPv4 sockets. There are other types of sockets, like IO::Socket::INET6 and IO::Socket::SSL, that could be used if the inheiritance wasn't fixed.

Also, there is a need to change the socket but keep the same client object. Some protocols support negiotiating SSL over the existing TCP connection. The easiest way to support this is replace the reference to the IP socket with an SSL socket object.


In reply to Re: Re: Often Overlooked OO Programming Guidelines by iburrell
in thread Often Overlooked OO Programming Guidelines by Ovid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-18 17:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found