summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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