Fix a few small typos
[gitmo/moose-presentations.git] / moose-class / slides / index.html
index 7495ce3..b065633 100644 (file)
@@ -842,6 +842,16 @@ has last_name => (
 );</code></pre>
 </div>
 
+<div class="slide">
+    <h1>More Why Moose?</h1>
+
+    <ul>
+      <li>Less code == fewer bugs</li>
+      <li>Moose is well-tested, test your own code, not Moose</li>
+      <li>Focus on <strong>what</strong>, not <strong>how</strong></li>
+    </ul>
+</div>
+
 <div class="slide fake-slide0">
   <h1>Part 1: Moose Classes</h1>
 </div>
@@ -882,7 +892,7 @@ use Moose;</code></pre>
   <h1>BUILDARGS</h1>
 
   <ul>
-    <li>Takes <code>@_</code>, returns a hash reference of attribute names/value</li>
+    <li>Takes <code>@_</code>, returns a hash reference of attribute name/value pairs</li>
     <li>Accepts a hash or hashref; throws otherwise</li>
     <li>Provide your own for other cases</li>
     <li><strong>Always</strong> call <code>$class-&gt;SUPER::BUILDARGS(@_)</code> as a fallback!</li>
@@ -941,7 +951,7 @@ sub BUILD {
 
   <pre><code>Person-&gt;new(@_)</code></pre>
 
-  <ol>
+  <ol style="margin-top: 0">
     <li>Calls <code>Person-&gt;BUILDARGS(@_)</code> to turn <code>@_</code> into a hashref</li>
     <li>Blesses a reference</li>
     <li>Populates attributes based on the hashref from #1</li>
@@ -1056,6 +1066,7 @@ use Moose;
     <li>Mostly like <code>$self-&gt;SUPER::work(@_)</code></li>
     <li><strong>But</strong> cannot change <code>@_</code>!</li>
     <li>Binds the parent's method at compile time</li>
+    <li>Parent determined by checking <code>Child-&gt;meta()-&gt;superclasses()</code></li>
   </ul>
 </div>
 
@@ -1141,7 +1152,8 @@ Person->can('extends');</code></pre>
   <h1>No Moose</h1>
 
   <ul>
-    <li><code>no Moose</code> at the end of a package is a best practice</li>
+    <li>Cleaning up is a best practice</li>
+    <li>Say <code>no Moose</code> at the end of a package</li>
     <li>Or <code>use namespace::autoclean</code> at the top</li>
     <li>Just do it</li>
   </ul>
@@ -1856,7 +1868,8 @@ has packages =&gt; (
 use Moose;
 
 my $highlander_bank =
-    Bank-&gt;new( name =&gt; 'Spire FCU' );
+    Bank-&gt;new(
+        name =&gt; 'Clan MacLeod Trust' );
 
 has bank =&gt; (
     is      =&gt; 'rw',
@@ -1868,7 +1881,8 @@ has bank =&gt; (
   <h1>Builder</h1>
 
   <ul>
-    <li>A method <em>name</em> which returns the default</li>
+    <li>A method <em>name</em></li>
+    <li>When called, this method returns the default value</li>
   </ul>
 </div>
 
@@ -1942,7 +1956,8 @@ has bank =&gt; (
 use Moose;
 
 has shoe_size =&gt; (
-    is =&gt; 'ro',
+    is       =&gt; 'ro',
+    required =&gt; 'ro',
 );</code></pre>
 </div>
 
@@ -2195,6 +2210,13 @@ has first_name =&gt; (
     <li>Attributes can have a <code>default</code> or <code>builder</code></li>
     <li>Attributes with a default or builder can be <code>lazy</code></li>
     <li>Attributes can have a <code>clearer</code> and/or <code>predicate</code></li>
+  </ul>
+</div>
+
+<div class="slide">
+  <h1>Basic Attributes Summary</h1>
+
+  <ul>
     <li>An attribute's constructor name can be changed with <code>init_arg</code></li>
     <li>A subclass can alter its parents' attributes</li>
     <li>Attribute accessor names can be changed</li>
@@ -2224,18 +2246,18 @@ Iterate til this passes all its tests</pre>
 
   <ul>
     <li>Apply to an existing method</li>
-    <li>... from a parent class, the current class, or a role</li>
+    <li>... that comes from a parent class, the current class, or a role</li>
     <li>Roles can provide modifiers that are applied at composition time</li>
   </ul>
 </div>
 
 <div class="slide">
-  <h1>What is a Method Modifier</h1>
+  <h1>What Are Method Modifiers For?</h1>
 
   <ul>
     <li>"Inject" behavior</li>
     <li>Add behavior to generated methods (accessors, delegations)</li>
-    <li>Provide roles which modify existing behavior</li>
+    <li>Added from a role, can modify existing behavior</li>
   </ul>
 </div>
 
@@ -2426,6 +2448,7 @@ around run</span> =&gt; sub {
   <ul>
     <li>Inverted <code>super</code></li>
     <li>From least- to most-specific</li>
+    <li>Like Mason's autohandler feature</li>
     <li>Grandparent to parent to child</li>
     <li>Not allowed in roles</li>
   </ul>
@@ -2568,11 +2591,10 @@ Item
     Undef
     Defined
         Value
-           Num
-             Int
-           Str
-             ClassName
-             RoleName
+            Str
+                Num
+                    Int
+                ClassName
 </pre>
 </div>
 
@@ -2590,7 +2612,7 @@ Item
             CodeRef
             RegexpRef
             GlobRef
-              FileHandle
+                FileHandle
             Object
 </pre>
 </div>
@@ -2621,6 +2643,7 @@ undef</code></pre>
   <ul>
     <li><code>Value</code> is true when <code>! ref $thing</code></li>
     <li><code>Value</code> and <code>Str</code> are effectively the same, but <code>Str</code> is more expressive</li>
+    <li><code>Num</code> is true when a <code>$scalar</code> looks like a number</li>
     <li>An overloaded object which numifies does not pass the <code>Num</code> constraint!</li>
     <li>Perl 5's overloading is hopelessly broken</li>
   </ul>
@@ -2721,9 +2744,11 @@ has start_date =&gt; (
   <h1>Subtype Shortcuts - <code>class_type</code></h1>
 
   <pre><code>use Moose::Util::TypeConstraints;
-class_type 'DateTime';
+class_type 'DateTime';</code></pre>
 
-subtype 'DateTime',
+<hr />
+
+<pre><code>subtype 'DateTime',
     as      'Object',
     where   { $_-&gt;isa('DateTime') },
     message { ... };</code></pre>
@@ -2733,9 +2758,11 @@ subtype 'DateTime',
   <h1>Subtype Shortcuts - <code>role_type</code></h1>
 
   <pre><code>use Moose::Util::TypeConstraints;
-role_type 'Printable';
+role_type 'Printable';</coe></pre>
+
+<hr />
 
-subtype 'Printable',
+<pre><code>subtype 'Printable',
     as      'Object',
     where
         { Moose::Util::does_role(
@@ -2747,9 +2774,11 @@ subtype 'Printable',
   <h1>Subtype Shortcuts - <code>duck_type</code></h1>
 
   <pre><code>use Moose::Util::TypeConstraints;
-duck_type Car =&gt; qw( run break_down );
+duck_type Car =&gt; qw( run break_down );</code></pre>
 
-subtype 'Car',
+<hr />
+
+<pre><code>subtype 'Car',
     as      'Object',
     where   { all { $_-&gt;can($_) }
               qw( run break_down ) },
@@ -2760,9 +2789,11 @@ subtype 'Car',
   <h1>Subtype Shortcuts - <code>enum</code></h1>
 
   <pre><code>use Moose::Util::TypeConstraints;
-enum Color =&gt; qw( red blue green ) );
+enum Color =&gt; qw( red blue green ) );</code></pre>
+
+<hr />
 
-my %ok = map { $_ =&gt; 1 }
+<pre><code>my %ok = map { $_ =&gt; 1 }
              qw( red blue green );
 
 subtype 'Color'
@@ -3023,7 +3054,7 @@ has transaction_history => (
   <ul>
     <li>Type names are exported functions, catches typos early</li>
     <li>Types must be pre-declared</li>
-    <li>Types are stored with namespaces internally, but externally are short</li>
+    <li>Types are stored with namespaces internally, but you use short names</li>
     <li>Import existing Moose types as functions from <code>MooseX::Types::Moose</code></li>
     <li>Still need string names for things like <code>ArrayRef['Email::Address']</code></li>
   </ul>
@@ -3036,7 +3067,7 @@ has transaction_history => (
     <li><span class="right">Catches typos at compile time</span></li>
     <li><span class="right">Automatic namespacing</span></li>
     <li><span class="wrong">One more thing to install and learn</span></li>
-    <li><span class="wrong">Every name gets types twice (declared and then defined)</span></li>
+    <li><span class="wrong">Every name is typed twice (declared and then defined)</span></li>
     <li><span class="wrong">Still stuck with strings when referring to class or role names</span></li>
     <li><span class="wrong">Coercion gotcha from earlier still applies to types exported from <code>MooseX::Types::Moose</code></span></li>
   </ul>
@@ -3163,7 +3194,7 @@ $alice-&gt;friend($bob);</code></pre>
 
   <pre><code>after salary_level =&gt; {
     my $self = shift;
-    return unless @_;
+    <span class="highlight">return unless @_;</span>
     $self-&gt;clear_salary;
 };</code></pre>
 </div>
@@ -3175,7 +3206,8 @@ $alice-&gt;friend($bob);</code></pre>
 
   <pre><code>has salary_level =&gt; (
     is      =&gt; 'rw',
-    trigger =&gt; sub { $_[0]-&gt;clear_salary },
+    trigger =&gt;
+        sub { $_[0]-&gt;clear_salary },
 );</code></pre>
 </div>
 
@@ -3236,6 +3268,7 @@ has lungs =&gt; (
   <h1>Array Reference</h1>
 
   <ul>
+    <li>1-to-1 mapping</li>
     <li>Takes each method name and creates a simple delegation from the delegating class to the delegatee attribute</li>
   </ul>
 </div>
@@ -3396,7 +3429,7 @@ print "$_\n"
         <li>Bool - <code>set</code>, <code>toggle</code>, ...</li>
         <li>Hash - <code>get</code>, <code>set</code>, ...</li>
         <li>Array - already saw it</li>
-        <li>Code - <code>execute</code>, that's it</li>
+        <li>Code - <code>execute</code> and <code>execute_method</code></li>
       </ul>
     </li>
   </ul>
@@ -3461,7 +3494,7 @@ $person-&gt;account-&gt;deposit(100);</code></pre>
   <h1>Traits and Metaclasses</h1>
 
   <ul>
-    <li>Can add/alter/remove attribute parameter (from <code>has</code>)</li>
+    <li>Can add/alter/remove an attribute parameter (from <code>has</code>)</li>
     <li>Can change behavior of created attribute</li>
   </ul>
 </div>
@@ -3550,7 +3583,7 @@ Iterate til this passes all its tests</pre>
 
   <ul>
     <li><strong>Not comprehensive</strong></li>
-    <li>128 MooseX distributions on CPAN as of 09/24/2009</li>
+    <li>152 MooseX distributions on CPAN as of 02/02/2010</li>
     <li>Some of them are crap</li>
   </ul>
 </div>
@@ -3559,11 +3592,11 @@ Iterate til this passes all its tests</pre>
   <h1>Already Mentioned Several</h1>
 
   <ul>
-    <li>MooseX::NonMoose - best solution for subclassing non-Moose parents</li>
-    <li>MooseX::Declare - <em>real</em> Perl 5 OO</li>
-    <li>MooseX::FollowPBP and MooseX::SemiAffordanceAccessor</li>
-    <li>MooseX::Params::Validate and MooseX::Method::Signatures</li>
-    <li>MooseX::Types</li>
+    <li><code>MooseX::NonMoose</code> - best solution for subclassing non-Moose parents</li>
+    <li><code>MooseX::Declare</code> - <em>real</em> Perl 5 OO</li>
+    <li><code>MooseX::FollowPBP</code> and <code>MooseX::SemiAffordanceAccessor</code></li>
+    <li><code>MooseX::Params::Validate</code> and <code>MooseX::Method::Signatures</code></li>
+    <li><code>MooseX::Types</code></li>
   </ul>
 </div>    
 
@@ -3574,8 +3607,8 @@ Iterate til this passes all its tests</pre>
 use 5.10.0; # for say
 
 class Person {
-    has greeting
-        =&gt; ( is =&gt; 'ro', isa =&gt; 'Str' );
+    has greeting =&gt;
+        ( is =&gt; 'ro', isa =&gt; 'Str' );
 
     method speak {
         say $self-&gt;greeting;
@@ -3590,6 +3623,7 @@ class Person {
     <li>Still experimental-ish, but seeing more and more use</li>
     <li><strong>Not</strong> a source filter!</li>
     <li>Hooks into the Perl parser rather than filtering all your code</li>
+    <li>But not supported by <code>PPI</code>, <code>perltidy</code>, etc.</li> (yet?)
   </ul>
 </div>
 
@@ -3597,7 +3631,7 @@ class Person {
   <h1>MooseX::StrictConstructor</h1>
 
   <ul>
-    <li>By default, unknown constructor arguments are ignore</li>
+    <li>By default, unknown constructor arguments are ignored</li>
     <li>MX::StrictConstructor turns these into an error</li>
   </ul>
 </div>
@@ -3659,7 +3693,7 @@ use Moose;
 has file    =&gt;
     ( is =&gt; 'ro', required =&gt; 1 );
 has filters =&gt;
-    ( is =&gt; 'ro', isa =&gt; 'Str' );
+    ( is =&gt; 'ro', isa =&gt; 'ArrayRef[Str]' );
 
 sub run { ... }</code></pre>
 </div>
@@ -3753,7 +3787,7 @@ with HasCollection =&gt; { type =&gt; 'Int' };</code></pre>
     <li>mailing list - <a href="mailto:moose@perl.org">moose@perl.org</a></li>
     <li>Slides and exercises are in Moose's git repo:
         <br />
-        <span style="white-space: nowrap">git://jules.scsys.co.uk/gitmo/moose-presentations</span></li>
+        <span style="font-size:80%; white-space: nowrap">git://jules.scsys.co.uk/gitmo/moose-presentations</span></li>
   </ul>
 </div>