remove statements about the next recipe (which tend to become wrong over time)
[gitmo/Moose.git] / lib / Moose / Cookbook / Style.pod
index b29b4d9..1e5059b 100644 (file)
@@ -2,11 +2,12 @@
 
 =head1 NAME
 
-Moose::Cookbook::Style - How to cook Moose with style
+Moose::Cookbook::Style - The latest in trendy Moose cuisine
 
 =for authors
 
-Please annotate all bad examples with comments so that they won't be copied by accodent
+Please annotate all bad examples with comments so that they won't be copied by
+accident
 
 =cut
 
@@ -93,8 +94,9 @@ the C<init_arg> to C<undef> instead of overwriting it in C<BUILD>.
 
 =head2 Use C<BUILDARGS> to alter C<@_> processing
 
-If you need to change the way L<@_> is processed, use C<BUILDARGS>, instead of
-wrapping C<new>. This ensures the behavior is subclassible, it keeps this logic
+If you need to change the way C<@_> is processed, for example for
+C<< Class->new( $single_param ) >>, use C<BUILDARGS> instead of wrapping
+C<new>. This ensures the behavior is subclassable, it keeps this logic
 independent of the other aspects of construction, and can be made efficient
 using C<make_immutable>.
 
@@ -125,12 +127,14 @@ Instead, prefix type name with your project namespace, or class name:
 
 Or with L<MooseX::Types>:
 
+    use MooseX::Types::Moose qw(Object);
+
     use MooseX::Types (
         -declare => [qw(Person)],
     );
     
     subtype Person() => ( # note parenthesis, "Person" is a function, not a string
-        as 'Object',
+        as Object, # MooseX::Types::Moose exported it
         where { $_->can("name") },
     );
 
@@ -157,7 +161,7 @@ Will add a coercion to B<all> attributes like:
         coerce => 1,
     );
 
-in a specific way.
+when the actual coercion applies only to your specific cases.
 
 =head1 Clean up your package
 
@@ -171,4 +175,35 @@ For instance:
 
 will return true, even though C<has> is not a method.
 
+If you choose L<namespace::clean>, make sure to keep the C<meta> method if you
+want to use it for introspection:
+
+    use namespace::clean -except => "meta";
+
+=head1 Accept no substitutes
+
+By substitutes I mean hacks instead of "proper" solutions.
+
+When you have a tricky requirement, refrain from abusing Moose or MooseX:: or
+whatever it is you are using.
+
+Instead, drop by IRC and discuss it. Most of the time a crazy idea can either
+be simplified, or it will spawn a clean, reliable feature to whatever package
+you are using.
+
+This will improve your code and also share the benefit with others.
 
+=head1 AUTHOR
+
+Yuval (nothingmuch) Kogman
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2006-2009 by Infinity Interactive, Inc.
+
+L<http://www.iinteractive.com>
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=cut