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.
- Design is large, or is likely to become large
- 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.
- When types of data form a natural hierarchy that lets us use
Inheritance is one of the most powerful feature of OO, and the ability
to use it is a flag.
- When operations on data varies on data type
GIFs and JPGs might have their cropping done differently, even though
they're both graphics.
- When it's likely you'll have to add data types later
OO gives you the room to expand in the future.
- When interactions between data is best shown by operators
Some relations are best shown by using operators, which can be overloaded.
- When implementation of components is likely to change, especially in the same program
- When the system design is already object-oriented
- 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.
- When you have a piece of data on which many different operations
Graphics images, for instance, might be blurred, cropped, rotated, and adjusted.
- 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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||