<?xml version="1.0" encoding="windows-1252"?>
<node id="209601" title="Re: Re: Perl Style Guides for Large Projects" created="2002-10-31 19:18:29" updated="2005-08-10 15:18:05">
<type id="11">
note</type>
<author id="131165">
djantzen</author>
<data>
<field name="doctext">
&lt;p&gt;
From a brief perusal of the Slash style guide I see that chunks of the P5EE guide are borrowed directly from it (e.g., sections on parentheses, braces, functions vs methods), so at least there's already some consensus among your sources. I seem to recall the P5EE guide having a whole section on object-orientation though, conspicuously absent in the notes available now. I have found that to be very helpful before; hopefully it will reappear at some point. But I have some suggestions for managing development in a large OO project:
&lt;ul&gt;
&lt;li&gt; Adopt a standard terminology for describing things not enforced by &lt;code&gt;perl&lt;/code&gt; itself, i.e.: public/private/protected variables and methods; static vs instance methods; container classes like arrays of user-defined objects. I've found it helpful to borrow terms from Java/C++ to describe how a method is supposed to operate. POD can contain anything, so &lt;code&gt;public static void foobar(String str)&lt;/code&gt; is perfectly legit, even if &lt;code&gt;perl&lt;/code&gt; and &lt;code&gt;pod2html&lt;/code&gt; don't have a clue as to the meaning.
&lt;br&gt;&lt;br&gt;
&lt;li&gt; Define a standard model of exception handling. Personally I like the C++/Java style of try/catch/finally as opposed to eval/die, and so I lean toward using modules like &lt;a href="http://search.cpan.org/author/BIRNEY/bioperl-1.0.2/examples/exceptions/Error.pm"&gt;
Error&lt;/a&gt; or &lt;a href="http://search.cpan.org/author/PJORDAN/Exception-1.4/Exception.pm"&gt;
Exception&lt;/a&gt;, but what matters is that everyone can count on code choking in the same way.
&lt;br&gt;&lt;br&gt;
&lt;li&gt; Decide upon a standard form of constructor. On my project, much to my frustration, I've found in a number of cases that modules previously written (yes, some were mine)
were not written to support full inheritance with respect to initialization of state. While inheritance of methods is 
very easy to attain, it takes more careful planning to ensure that child classes will be able to utilize the superclass's initialization code. Whether you want to follow Java's model where each constructor's first act is to call &lt;code&gt;super()&lt;/code&gt; all the way up to &lt;code&gt;java.lang.Object&lt;/code&gt; or to try an approach like separating instantiation from initialization (my favored method nowadays), what matters is that you avoid the situation where a programmer wanting to subclass an existing module needs to read the code for the proposed superclass. And to do this requires a standard format for constructors. (See [id://176963])
&lt;br&gt;&lt;br&gt; 
&lt;li&gt; Create a module for argument checking that all programmers can use when validating data coming into a method. This keeps a major source of redundant code in one place, and ensures that you know something about the safety  of your code across the whole project. It also means that you can simply turn off argument checking if you want to for speed. 
&lt;br&gt;
&lt;/ul&gt;
&lt;p&gt;
Good luck, [fever]</field>
<field name="root_node">
209555</field>
<field name="parent_node">
209565</field>
</data>
</node>
