X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FManual%2FBestPractices.pod;h=f0edc9b0d40ad27db38288f84e285ead7cf88f75;hb=d5f016af3d56eec870efee8858352a4014879be2;hp=c11eda07e4dbee8ba396113e1bd58823c47c05b4;hpb=e4a134edb64bafc43edda49a25b4bd846c6f845e;p=gitmo%2FMoose.git diff --git a/lib/Moose/Manual/BestPractices.pod b/lib/Moose/Manual/BestPractices.pod index c11eda0..f0edc9b 100644 --- a/lib/Moose/Manual/BestPractices.pod +++ b/lib/Moose/Manual/BestPractices.pod @@ -13,35 +13,34 @@ and using them consistently makes everyone's life easier. Of course, as with any list of "best practices", these are really just opinions. Feel free to ignore us. -=head2 C and immutabilize +=head2 C and immutabilize -We recommend that you end your Moose class definitions by removing the -Moose sugar and making your class immutable. +We recommend that you remove the Moose sugar and end your Moose class +definitions by making your class immutable. package Person; use Moose; + use namespace::autoclean; # extends, roles, attributes, etc. # methods - no Moose; - __PACKAGE__->meta->make_immutable; 1; -The C bit is simply good code hygiene, as it removes all the -Moose keywords from your class's namespace. Once the class has been +The C bit is simply good code hygiene, as it removes +imported symbols from you class's namespace at the end of your package's +compile cycle, including Moose keywords. Once the class has been built, these keywords are not needed needed. The C call allows Moose to speed up a lot of things, most notably object construction. The trade-off is that you can no longer change the class definition. -A more generic way to unimport not only L's exports but also -those from type libraries and other modules is to use -L or L. +C may be used to unimport only Moose's imported symbols. +L provides finer-grained control than L. =head2 Never override C