edit contentious syntax
[gitmo/Moose.git] / lib / Moose / Cookbook / FAQ.pod
index c33896c..9a54c6a 100644 (file)
@@ -16,7 +16,7 @@ production using Moose, they have been running without
 issue now for well over a year. 
 
 At C<$work> we are re-writing our core offering to use Moose, 
-so it's continued development is assured. 
+so its continued development is assured. 
 
 Several other people on #moose either have apps in production 
 which use Moose, or are in the process of deploying sites 
@@ -73,31 +73,22 @@ Perl 6. Every C<BUILD> method in your inheritance chain is called
 (in the correct order) immediately after the instance is constructed. 
 This allows you to ensure that all your superclasses are initialized 
 properly as well. This is the best approach to take (when possible)
-because it makes sub classing your class much easier.
+because it makes subclassing your class much easier.
 
 If you need to affect the constructor's parameters prior to the 
 instance actually being constructed, you have a number of options.
 
-First, there are I<coercions> (See the L<Moose::Cookbook::Recipe5> 
-for a complete example and explaination of coercions). With 
-coercions it is possible to morph argument values into the correct 
-expected types. This approach is the most flexible and robust, but 
-does have a slightly higher learning curve.
+To change the parameter processing as a whole, you can use
+the C<BUILDARGS> method. The default implementation accepts key/value
+pairs or a hash reference. You can override it to take positional args,
+or any other format
 
-Second, using an C<around> method modifier on C<new> can be an 
-effective way to affect the contents of C<@_> prior to letting 
-Moose deal with it. This carries with it the extra burden for 
-your subclasses, in that they have to be sure to explicitly 
-call your C<new> and/or work around your C<new> to get to the 
-version from L<Moose::Object>. 
-
-The last approach is to use the standard Perl technique of calling 
-the C<SUPER::new> within your own custom version of C<new>. This, 
-of course, brings with it all the issues of the C<around> solution 
-as well as any issues C<SUPER::> might add.
-
-In short, try to use C<BUILD> and coercions, they are your best 
-bets.
+To change the handling of individual parameters, there are I<coercions>
+(See the L<Moose::Cookbook::Basics::Recipe5> for a complete example and
+explanation of coercions). With coercions it is possible to morph
+argument values into the correct expected types. This approach is the
+most flexible and robust, but does have a slightly higher learning
+curve.
 
 =head3 How do I make non-Moose constructors work with Moose? 
 
@@ -106,7 +97,7 @@ delegation.  Moose makes this easy using the C<handles> keyword,
 coercions, and C<lazy_build>, so subclassing is often not the
 ideal route.
 
-That said, the default Moose constructors is inherited from
+That said, the default Moose constructor is inherited from
 L<Moose::Object>. When inheriting from a non-Moose class, the
 inheritance chain to L<Moose::Object> is broken. The simplest way
 to fix this is to simply explicitly inherit from L<Moose::Object>
@@ -172,16 +163,15 @@ C<writer> attribute options. Here is some example code:
 Moose will still take advantage of type constraints, triggers, etc. 
 when creating these methods. 
 
-If you do not like this much typing, and wish it to be a default for
-your class, please see L<Moose::Policy>, and more specifically
-L<Moose::Policy::FollowPBP>. This will allow you to write:
+If you do not like this much typing, and wish it to be a default for your
+class, please see L<MooseX::FollowPBP>. This will allow you to write:
 
   has 'bar' => (
       isa => 'Baz',
       is  => 'rw',
   );
 
-And have Moose create seperate C<get_bar> and C<set_bar> methods
+And have Moose create separate C<get_bar> and C<set_bar> methods
 instead of a single C<bar> method.
 
 NOTE: This B<cannot> be set globally in Moose, as that would break 
@@ -213,7 +203,7 @@ coerce the value into a C<DateTime> object using the code in found
 in the C<via> block. 
 
 For a more comprehensive example of using coercions, see the
-L<Moose::Cookbook::Recipe5>.
+L<Moose::Cookbook::Basics::Recipe5>.
 
 If you need to deflate your attribute, the current best practice is to 
 add an C<around> modifier to your accessor. Here is some example code:
@@ -288,8 +278,23 @@ release.
 
 =head3 How do I get Moose to call BUILD in all my composed roles?
 
-See L<Moose::Cookbook::WTF> and specifically the B<How come BUILD 
-is not called for my composed roles?> question in the B<Roles> section.
+See L<Moose::Cookbook::WTF> and specifically the B<Why is BUILD 
+not called for my composed roles?> question in the B<Roles> section.
+
+=head3 What are Traits, and how are they different from Roles?
+
+In Moose, a trait is almost exactly the same thing as a role, except
+that traits typically register themselves, which allows you to refer
+to them by a short name ("Big" vs "MyApp::Role::Big").
+
+In Moose-speak, a I<Role> is usually composed into a I<class> at
+compile time, whereas a I<Trait> is usually composed into an instance
+of a class at runtime to add or modify the behavior of B<just that
+instance>.
+
+Outside the context of Moose, traits and roles generally mean exactly the
+same thing. The original paper called them Traits, however Perl 6 will call
+them Roles.
 
 =head1 AUTHOR
 
@@ -297,7 +302,7 @@ Stevan Little E<lt>stevan@iinteractive.comE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2006-2008 by Infinity Interactive, Inc.
+Copyright 2006-2009 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>