summaryrefslogtreecommitdiff
path: root/pod/perlootut.pod
diff options
context:
space:
mode:
authorDave Rolsky <autarch@urth.org>2011-03-23 10:00:05 -0500
committerDave Rolsky <autarch@urth.org>2011-09-08 21:47:22 -0500
commitce843b44a895d1ad6b70399e1f60ef994a5947a1 (patch)
treecef2d9221f49206c393eb1688553296c8bd2affd /pod/perlootut.pod
parentdbfe29416ae22f393039d7e661b8a11632e590a0 (diff)
downloadperl-ce843b44a895d1ad6b70399e1f60ef994a5947a1.tar.gz
Add Damian's list of when to use OO - copied from PBP
Here's the email from Teri Finn at O'Reilly giving us permission to do so: ------------------------------------------------------------------------- Dave, O'Reilly Media is happy to grant you the permissions you have requested below. If you are able to include the copyright notice in the attribution that would be great. Damian Conway wrote about when to use OO in Perl Best Practices, Copyright © 2004, Published by O'Reilly Media, Inc. His list of criteria for doing so is: Our best to you on your project. Teri Finn O'Reilly Media, Inc. ----- Original Message ----- From: "Dave Rolsky" <autarch@urth.org> To: permissions@oreilly.com Cc: damian@conway.org Sent: Sunday, March 6, 2011 6:58:34 PM GMT -08:00 US/Canada Pacific Subject: Usage of text from Perl Best Practices Hi, ORA, I'm working on the Perl 5 core documentation, specifically on a new OO tutorial. I'd like to include Damian's "when to use OO" list as published in Perl Best Practices (pages 320-321). I don't want to include the entire text verbatim, just the bullet points. I wrote to Damian and he is okay with having this included in the docs, just as an FYI. To do this, I'd need permission to include the text and distribute it under the same license as Perl 5 itself, which is currently version 1 of the Artistic license. I would of course credit Damian and note the book, something like .... Damian Conway wrote about when to use OO in Perl Best Practices. His list of criteria for doing so is: Thanks, -dave
Diffstat (limited to 'pod/perlootut.pod')
-rw-r--r--pod/perlootut.pod58
1 files changed, 58 insertions, 0 deletions
diff --git a/pod/perlootut.pod b/pod/perlootut.pod
index e1cfedbbca..062706d5d8 100644
--- a/pod/perlootut.pod
+++ b/pod/perlootut.pod
@@ -373,6 +373,64 @@ Perl does not have any built-in way to express roles. In the past,
people just bit the bullet and used multiple inheritance. Nowadays,
there are several good choices on CPAN for using roles.
+=head2 When to Use OO
+
+Object Orientation is not the best solution to every problem. In I<Perl
+Best Practices> (copyright 2004, Published by O'Reilly Media, Inc.),
+Damian Conway provides a list of criteria to use when deciding if OO is
+the right fit for your problem:
+
+=over 4
+
+=item
+
+The system being designed is large, or is likely to become large.
+
+=item
+
+The data can be aggregated into obvious structures, especially if
+there's a large amount of data in each aggregate.
+
+=item
+
+The various types of data aggregate form a natural hierarchy that
+facilitates the use of inheritance and polymorphism.
+
+=item
+
+You have a piece of data on which many different operations are
+applied.
+
+=item
+
+You need to perform the same general operations on related types of
+data, but with slight variations depending on the specific type of data
+the operations are applied to.
+
+=item
+
+It's likely you'll have to add new data types later.
+
+=item
+
+The typical interactions between pieces of data are best represented by
+operators.
+
+=item
+
+The implementation of individual components of the system is likely to
+change over time.
+
+=item
+
+The system design is already object-oriented.
+
+=item
+
+Large numbers of other programmers will be using your code modules.
+
+=back
+
=head1 PERL OO SYSTEMS
As we mentioned before, Perl's built-in OO system is very minimal, but