Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Damian Conway's ten rules for when to use OO

by petdance (Parson)
on Jun 24, 2001 at 21:19 UTC ( #91080=perlmeditation: print w/ replies, xml ) Need Help??

On Saturday, June 23rd, Damian Conway had a little free-for-all workshop that he gave at College of DuPage in Wheaton, IL. Although the whole day was fascinating, the most useful part for me was his discussion of ``Ten criteria for knowing when to use object-oriented design''. Apparently, Damian was once a member of Spinal Tap, because his list goes to eleven.

Damian said that this list, in expanded form, is going to be part of the standard Perl distribution soon.

  1. Design is large, or is likely to become large
  2. When data is aggregated into obvious structures, especially if there's a lot of data in each aggregate
    For instance, an IP address is not a good candidate: There's only 4 bytes of information related to an IP address. An immigrant going through customs has a lot of data related to him, such as name, country of origin, luggage carried, destination, etc.
  3. When types of data form a natural hierarchy that lets us use inheritance.
    Inheritance is one of the most powerful feature of OO, and the ability to use it is a flag.
  4. When operations on data varies on data type
    GIFs and JPGs might have their cropping done differently, even though they're both graphics.
  5. When it's likely you'll have to add data types later
    OO gives you the room to expand in the future.
  6. When interactions between data is best shown by operators
    Some relations are best shown by using operators, which can be overloaded.
  7. When implementation of components is likely to change, especially in the same program
  8. When the system design is already object-oriented
  9. When huge numbers of clients use your code
    If your code will be distributed to others who will use it, a standard interface will make maintenence and safety easier.
  10. When you have a piece of data on which many different operations are applied
    Graphics images, for instance, might be blurred, cropped, rotated, and adjusted.
  11. When the kinds of operations have standard names (check, process, etc)
    Objects allow you to have a DB::check, ISBN::check, Shape::check, etc without having conflicts between the types of check.

Comment on Damian Conway's ten rules for when to use OO
Select or Download Code
Re: Damian Conway's ten rules for when to use OO
by mrmick (Curate) on Jun 25, 2001 at 17:24 UTC
    This is great! I often find myself wondering whether to use OO for a particular project. I'll try this and see if it works for me.

    **UPDATE**
    Nice to see I get --'d for saying something positive here. I really don't care about the XP's. Just sometimes amused and curious about others' motives.

    Mick
Re: Damian Conway's ten rules for when to use OO
by ambrus (Abbot) on Jun 22, 2005 at 20:56 UTC

    As of perl 5.8.7, it's already in perl core, namely perldoc perlmodstyle. The details in the text somewhat differ from the verison you've posted here though.

      Hardly surprising, four years later.

      xoxo,
      Andy

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (17)
As of 2014-07-31 13:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (248 votes), past polls