Tweak augment example to use $self as needed
[gitmo/moose-presentations.git] / moose-class / slides / index.html
index 1019d99..7759fd3 100644 (file)
@@ -52,7 +52,17 @@ img#me05 {top: 43px;left: 36px;}
 
 <div class="slide">
   <h1>Introduction to Moose</h1>
-  <h2><a href="git://git.moose.perl.org/moose-presentations.git"><tt>git://git.moose.perl.org/moose-presentations.git</tt></a></h2>
+  <h2>Dave Rolsky</a>
+</div>
+
+<div class="slide">
+  <h1>Introduce Yourselves</h1>
+
+  <ul>
+    <li>Your name</li>
+    <li>What you do with Perl</li>
+    <li>Why you're here today (optional)</li>
+  </ul>
 </div>
 
 <div class="slide">
@@ -208,7 +218,7 @@ use Moose;
   <ul>
     <li>AKA advice</li>
     <li>&quot;<strong>Before</strong> foo(), do this first&quot;</li>
-    <li>&quot;Do this <strong>after</strong> foo()</li>
+    <li>&quot;Do this <strong>after</strong> foo()&quot;</li>
     <li>&quot;Put this code <strong>around</strong> foo()&quot;</li>
   </ul>
 </div>
@@ -265,7 +275,7 @@ has weight =&gt; (
 );
 
 # kaboom
-Person-&gt;new( weight =&gt; 'fat' );</code></pre>
+Person-&gt;new( weight =&gt; 'heavy' );</code></pre>
 </div>
 
 <div class="slide">
@@ -290,8 +300,8 @@ has blog_uri =&gt; (
     <span class="highlight">handles =&gt; { 'blog_host' =&gt; 'host' },</span>
 );
 
-<span class="highlight">$person->blog_host;</span>
-# really calls $person->blog_uri->host</code></pre>
+<span class="highlight">$person-&gt;blog_host;</span>
+# really calls $person-&gt;blog_uri-&gt;host</code></pre>
 </div>
 
 <div class="slide">
@@ -832,6 +842,16 @@ has last_name =&gt; (
 );</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>
@@ -872,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>
@@ -931,11 +951,11 @@ 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>
-    <li>Calls <code>$new_object->BUILDALL($constructor_args)</code>
+    <li>Calls <code>$new_object-&gt;BUILDALL($constructor_args)</code>
         <br />... which calls all <code>BUILD</code> methods</li>    
     <li>Returns the object</li>
   </ol>
@@ -1046,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>
 
@@ -1086,8 +1107,7 @@ has first_name =&gt; ( <span class="highlight">is =&gt; 'ro'</span> );
 my $person =
     Person-&gt;new( first_name =&gt; 'Dave' );
 
-$person-&gt;first_name('Stevan');
-print $person-&gt;first_name; # Dave</code></pre>
+$person-&gt;first_name('Stevan'); # dies</code></pre>
 
 </div>
 
@@ -1106,7 +1126,7 @@ print $person-&gt;first_name; # Dave</code></pre>
 use Moose;
 
 # true
-Person->can('extends');</code></pre>
+Person-&gt;can('extends');</code></pre>
 
   <ul>
     <li>Not very hygienic</li>
@@ -1121,17 +1141,31 @@ use Moose;
 
 ...
 
-no Moose;
+<span class="highlight">no Moose;</span>
 
 # false
-Person->can('extends');</code></pre>
+Person-&gt;can('extends');</code></pre>
+</div>
+
+<div class="slide">
+  <h1>Cleaning Up Moose Droppings</h1>
+
+  <pre><code>package Person;
+<span class="highlight">use namespace::autoclean;</span>
+use Moose;
+
+...
+
+# false
+Person-&gt;can('extends');</code></pre>
 </div>
 
 <div class="slide">
   <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>
@@ -1141,13 +1175,13 @@ Person->can('extends');</code></pre>
   <h1>Immutability</h1>
 
   <ul>
-    <li><span style="font-family: URW Chancery L; font-size: 140%">Stevan's Incantation of Fleet-Footedness</span></li>
+    <li><span style="font-family: URW Chancery L; font-size: 120%">Stevan's Incantation of Fleet-Footedness</span></li>
   </ul>
 
   <pre><code>package Person;
 use Moose;
 
-<span class="highlight">__PACKAGE__->meta->make_immutable;</span></code></pre>
+<span class="highlight">__PACKAGE__-&gt;meta-&gt;make_immutable;</span></code></pre>
 </div>
 
 <div class="slide">
@@ -1333,7 +1367,7 @@ sub print {
 
 # or ...
 
-Person-&gt;meta-&gt;does('Printable')</code></pre>
+Person-&gt;meta-&gt;does_role('Printable')</code></pre>
 
 </div>
 
@@ -1393,69 +1427,17 @@ use Moose;
 </div>
 
 <div class="slide">
-  <h1>Method Aliasing</h1>
-
-  <pre><code>package FragileDancer;
-use Moose;
-
-<span class="highlight">with 'IsFragile' =>
-         { -alias =>
-               { break => 'break_bone' } },
-     'CanBreakdance' =>
-         { -alias =>
-               { break => 'break_it_down' } };</span></code></pre>
+  <h1>Conflicts Are a Smell</h1>
 
   <ul>
-    <li>Renames the roles' methods</li>
-    <li>Still conflicts, need to <code>exclude</code> as well</li>
-  </ul>
-</div>
-
-<div class="slide">
-  <h1>Method Exclusion</h1>
-
-  <pre><code>package FragileDancer;
-use Moose;
-
-<span class="highlight">with 'IsFragile' =>
-         { -alias =>
-               { break => 'break_bone' },
-           -excludes => 'break' },
-     'CanBreakdance' =>
-         { -alias =>
-               { break => 'break_it_down' },
-           -excludes => 'break' };</span></code></pre>
-</div>
-
-<div class="slide">
-  <h1>And then ...</h1>
-
-  <pre><code>package FragileDancer;
-use Moose;
-
-sub break {
-    my $self = shift;
-
-    $self->break_it_down;
-    if ( rand(1) &lt; 0.5 ) {
-        $self->break_bone;
-    }
-}</code></pre>
-</div>
-
-<div class="slide">
-  <h1>Still Full of Fail</h1>
-
-  <ul>
-    <li>Roles are also about semantics!</li>
-    <li>We've fulfilled the letter and lost the spirit</li>
+    <li>Roles are about semantics!</li>
     <li>Roles have a <em>meaning</em></li>
-    <li>Think twice before blindly aliasing and excluding methods!</li>
+    <li>Method name conflicts smell like bad design</li>
   </ul>
 </div>
 
 <div class="slide">
-  <h1>Hot Role-on-Role Action</h1>
+  <h1>Roles With Roles</h1>
 
   <pre><code>package Comparable;
 use Moose::Role;
@@ -1464,7 +1446,7 @@ requires 'compare';</code></pre>
 </div>
 
 <div class="slide">
-  <h1>Hot Role-on-Role Action</h1>
+  <h1>Roles With Roles</h1>
 
   <pre><code>package TestsEquality;
 use Moose::Role;
@@ -1473,7 +1455,7 @@ with 'Comparable';
 
 sub is_equal {
     my $self = shift;
-    return $self->compare(@_) == 0;
+    return $self-&gt;compare(@_) == 0;
 }</code></pre>
 </div>
 
@@ -1488,8 +1470,8 @@ with 'TestsEquality';
 # Satisfies the Comparable role
 sub compare { ... }
 
-Integer->does('TestsEquality'); # true
-Integer->does('Comparable'); # also true!</code></pre>
+Integer-&gt;does('TestsEquality'); # true
+Integer-&gt;does('Comparable'); # also true!</code></pre>
 </div>
 
 <div class="slide">
@@ -1511,11 +1493,11 @@ with 'HasSubProcess';
 <div class="slide">
   <h1>Delayed Conflict</h1>
 
-  <pre><code>package StateOfTexas;
+  <pre><code>package SysadminAssassin;
 with 'Killer';</code></pre>
 
   <ul>
-    <li><code>StateOfTexas</code> must implement its own <code>execute</code></li>
+    <li><code>SysadminAssassin</code> must implement its own <code>execute</code></li>
     <li>But loading the <code>Killer</code> role by itself does not cause an error</li>
   </ul>
 </div>
@@ -1596,7 +1578,7 @@ has [ 'left', 'right' ] => (
 
   <pre><code>use Moose::Util qw( apply_all_roles );
 
-my $fragile_person = Person->new( ... );
+my $fragile_person = Person-&gt;new( ... );
 apply_all_roles( $fragile_person,
                  'IsFragile' );</code></pre>
 
@@ -1752,8 +1734,8 @@ has first_name =&gt; (
     <span class="current incremental">required =&gt; 1,</span>
 );
 
-<span class="incremental">Person->new( first_name =&gt; undef ); # ok
-Person->new(); # kaboom</span></code></pre>
+<span class="incremental">Person-&gt;new( first_name =&gt; undef ); # ok
+Person-&gt;new(); # kaboom</span></code></pre>
 </div>
 
 <div class="slide">
@@ -1846,7 +1828,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',
@@ -1858,7 +1841,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>
 
@@ -1932,7 +1916,8 @@ has bank =&gt; (
 use Moose;
 
 has shoe_size =&gt; (
-    is =&gt; 'ro',
+    is       =&gt; 'ro',
+    required =&gt; 1,
 );</code></pre>
 </div>
 
@@ -2020,11 +2005,11 @@ has shoe_size => (
     <span class="highlight">init_arg =&gt; 'foot_size',</span>
 );
 
-Person->new( <span class="wrong">shoe_size =&gt; 13</span> );
+Person-&gt;new( <span class="wrong">shoe_size =&gt; 13</span> );
 
 my $person =
-    Person->new( <span class="right">foot_size =&gt; 13</span> );
-print $person->shoe_size;</code></pre>
+    Person-&gt;new( <span class="right">foot_size =&gt; 13</span> );
+print $person-&gt;shoe_size;</code></pre>
 </div>
 
 <div class="slide">
@@ -2038,7 +2023,7 @@ has shoes => (
     <span class="highlight">init_arg =&gt; undef,</span>
 );
 
-Person->new( <span class="wrong">shoes =&gt; Shoes-&gt;new</span> );</code></pre>
+Person-&gt;new( <span class="wrong">shoes =&gt; Shoes-&gt;new</span> );</code></pre>
 </div>
 
 <div class="slide">
@@ -2185,6 +2170,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>
@@ -2214,18 +2206,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>
 
@@ -2352,7 +2344,7 @@ after clear_password =&gt; sub {
         $self-&gt;$orig(
             $self-&gt;_munge_insert(@_) );
 
-    $new_user->_assign_uri;
+    $new_user-&gt;_assign_uri;
     return $new_user;
 };</code></pre>
 </div>
@@ -2416,6 +2408,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>
@@ -2424,19 +2417,21 @@ around run</span> =&gt; sub {
 <div class="slide">
   <h1>Augment and Inner</h1>
 
-  <pre><code>package Document;
+  <pre class="medium"><code>package Document;
 
 sub xml { '&lt;doc&gt;' . <span class="highlight">inner()</span> . '&lt;/doc&gt;' }
 
 package Report;
 extends 'Document';
 <span class="highlight">augment xml</span> =&gt;
-    sub { title() . <span class="highlight">inner()</span> . summary() };
+    sub { my $self = shift;
+          $self-&gt;title() . <span class="highlight">inner()</span> . $self-&gt;summary() };
 
 package TPSReport;
 extends 'Report';
 <span class="highlight">augment xml</span> =&gt;
-    sub { tps_xml() . <span class="highlight">inner()</span> };</code></pre>
+    sub { my $self = shift;
+          $self-&gt;tps_xml() . <span class="highlight">inner()</span> };</code></pre>
 </div>
 
 <div class="slide">
@@ -2558,11 +2553,11 @@ Item
     Undef
     Defined
         Value
-           Num
-             Int
-           Str
-             ClassName
-             RoleName
+            Str
+                Num
+                    Int
+                ClassName
+                RoleName
 </pre>
 </div>
 
@@ -2580,7 +2575,7 @@ Item
             CodeRef
             RegexpRef
             GlobRef
-              FileHandle
+                FileHandle
             Object
 </pre>
 </div>
@@ -2611,6 +2606,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>
@@ -2711,9 +2707,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>
@@ -2723,10 +2721,12 @@ subtype 'DateTime',
   <h1>Subtype Shortcuts - <code>role_type</code></h1>
 
   <pre><code>use Moose::Util::TypeConstraints;
-role_type 'Printable';
+role_type 'Printable';</coe></pre>
 
-subtype 'Printable',
-    as      'Object',
+<hr />
+
+<pre><code>subtype 'Printable',
+    as  'Object',
     where
         { Moose::Util::does_role(
               $_, 'Printable' ) },
@@ -2737,9 +2737,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>
+
+<hr />
 
-subtype 'Car',
+<pre><code>subtype 'Car',
     as      'Object',
     where   { all { $_-&gt;can($_) }
               qw( run break_down ) },
@@ -2750,12 +2752,14 @@ 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>
 
-my %ok = map { $_ =&gt; 1 }
+<hr />
+
+<pre><code>my %ok = map { $_ =&gt; 1 }
              qw( red blue green );
 
-subtype 'Color'
+subtype     'Color'
     as      'Str',
     where   { $ok{$_} },
     message { ... };</code></pre>
@@ -2831,7 +2835,7 @@ coerce 'My::DateTime',
     via  { [ $_ ] };</code></pre>
 
   <ul>
-    <li>Coerce instead of a union like <code style="white-space: nowrap">Int | ArrayRef[Int]</code></li>
+    <li>Instead of union - <code style="white-space: nowrap">Int | ArrayRef[Int]</code></li>
   </ul>
 </div>
 
@@ -2871,6 +2875,19 @@ no Moose;
 </div>
 
 <div class="slide">
+  <h1>Questions So Far?</h1>
+</div>  
+
+<div class="slide">
+  <h1>Exercises</h1>
+
+  <pre># cd exercises
+# perl bin/prove -lv t/05-types.t
+
+Iterate til this passes all its tests</pre>
+</div>
+
+<div class="slide">
   <h1>Typed Methods (Low-tech)</h1>
 
   <pre class="medium"><code>package Person;
@@ -3013,7 +3030,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>
@@ -3026,7 +3043,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>
@@ -3047,15 +3064,6 @@ has transaction_history => (
   <h1>Questions?</h1>
 </div>  
 
-<div class="slide">
-  <h1>Exercises</h1>
-
-  <pre># cd exercises
-# perl bin/prove -lv t/05-types.t
-
-Iterate til this passes all its tests</pre>
-</div>
-
 <div class="slide fake-slide0">
   <h1>Part 6: Advanced Attributes</h1>
 </div>
@@ -3153,7 +3161,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>
@@ -3165,11 +3173,22 @@ $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>
 
 <div class="slide">
+  <h1>Trigger Arguments</h1>
+
+  <ul>
+    <li><code>$self</code></li>
+    <li><code>$new_value</code></li>
+    <li><code>$old_value</code> - if one exists</li>
+  </ul>
+</div>
+
+<div class="slide">
   <h1>Delegation</h1>
 
   <ul>
@@ -3226,6 +3245,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>
@@ -3318,17 +3338,37 @@ has history =&gt; (
   <ul>
     <li>Delegate to <em>unblessed</em> Perl types</li>
     <li>Scalar, array or hash ref, etc</li>
+    <li>Treat Perl types as objects</li>
+    <li>Still uses <code>handles</code></li>
+    <li>Pretend that native Perl types have methods</li>
   </ul>
 </div>
 
 <div class="slide">
-  <h1>Native Delegation - Array</h1>
+  <h1>Native Delegation - Array(Ref)</h1>
+
+  <ul>
+    <li>Methods include:
+      <ul>
+        <li><code>push</code></li>
+        <li><code>shift</code></li>
+        <li><code>elements</code> - returns all elements</li>
+        <li><code>count</code></li>
+        <li><code>is_empty</code></li>
+        <li>quite a few more</li>
+      </ul>
+    </li>
+  </ul>
+</div>
+
+<div class="slide">
+  <h1>Native Delegation - Array(Ref)</h1>
 
   <pre><code>package Person;
 use Moose;
 has _favorite_numbers =&gt; (
     traits   =&gt; [ 'Array' ],
-    is       =&gt; 'ro',
+    is       =&gt; 'bare',
     isa      =&gt; 'ArrayRef[Int]',
     default  =&gt; sub { [] },
     init_arg =&gt; undef,
@@ -3340,23 +3380,71 @@ has _favorite_numbers =&gt; (
 </div>
 
 <div class="slide">
-  <h1>Native Delegation - Counter</h1>
+  <h1>Native Delegation - Array(Ref)</h1>
+
+  <pre><code>my $person = Person-&gt;new();
+
+$person-&gt;add_favorite_number(7);
+$person-&gt;add_favorite_number(42);
+
+print "$_\n"
+    for $person-&gt;favorite_numbers;
+
+# 7
+# 42</code></pre>
+</div>
+
+<div class="slide">
+  <h1>Native Delegation</h1>
+
+  <ul>
+    <li>Native types are ...
+      <ul>
+        <li>Number - <code>add</code>, <code>mul</code>, ...</li>
+        <li>String - <code>append</code>, <code>chop</code>, ...</li>
+        <li>Counter - <code>inc</code>, <code>dec</code>, ...</li>
+        <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> and <code>execute_method</code></li>
+      </ul>
+    </li>
+  </ul>
+</div>
+
+<div class="slide">
+  <h1>Curried Delegation</h1>
+
+  <ul>
+    <li>A delegation with some preset arguments</li>
+    <li>Works with object or Native delegation</li>
+  </ul>
+</div>
+
+<div class="slide">
+  <h1>Curried Delegation</h1>
 
-  <pre><code>package Stack;
+  <pre><code>package Person;
 use Moose;
-has depth =&gt; (
-    traits   =&gt; [ 'Counter' ],
-    is       =&gt; 'ro',
-    isa      =&gt; 'Int',
-    default  =&gt; 0,
-    init_arg =&gt; undef,
-    <span class="highlight">handles  =&gt;
-      { _inc_depth =&gt; 'inc',
-        _dec_depth =&gt; 'dec',
-      },</span>
+has account =&gt; (
+    is      =&gt; 'ro',
+    isa     =&gt; 'BankAccount',
+    handles =&gt; {
+        receive_100 =&gt;
+            <span class="highlight">[ 'deposit', 100 ]</span>
+        give_100    =&gt;
+            <span class="highlight">[ 'withdraw', 100 ]</span>
+    },
 );</code></pre>
 </div>
 
+<div class="slide">
+  <h1>Curried Delegation</h1>
+
+  <pre><code>$person-&gt;receive_100;
+# really is
+$person-&gt;account-&gt;deposit(100);</code></pre>
+</div>
 
 <div class="slide">
   <h1>Traits and Metaclasses</h1>
@@ -3383,7 +3471,7 @@ has depth =&gt; (
   <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>
@@ -3441,6 +3529,7 @@ print <span class="highlight">Person-&gt;meta
     <li>Use <code>weak_ref</code> to avoid circular references</li>
     <li>Use trigger to do an action post-attribute write</li>
     <li>Use delegations to hide "internal" objects</li>
+    <li>Use native delegations to treat Perl types as objects</li>
     <li>Traits and metaclasses let you extend Moose's core attribute features</li>
   </ul>
 </div>
@@ -3459,17 +3548,9 @@ print <span class="highlight">Person-&gt;meta
 Iterate til this passes all its tests</pre>
 </div>
 
-<div class="slide fake-slide0">
-  <h1>Part 7: Introspection</h1>
-</div>
-
-<div class="slide fake-slide0">
-  <h1>Part 8: A Tour of MooseX</h1>
-</div>
-
-<div class="slide fake-slide0">
-  <h1>Part 9: Writing Moose Extensions</h1>
-</div>
+<div class="slide">
+  <h1>Questions?</h1>
+</div>  
 
 <div class="slide fake-slide0">
   <h1>The End</h1>
@@ -3485,10 +3566,206 @@ Iterate til this passes all its tests</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>
+
+
+<div class="slide fake-slide0">
+  <h1>Bonus: A Brief Tour of MooseX</h1>
+</div>
+
+<div class="slide">
+  <h1>Notable MX Modules on CPAN</h1>
+
+  <ul>
+    <li><strong>Not comprehensive</strong></li>
+    <li>152 MooseX distributions on CPAN as of 02/02/2010</li>
+    <li>Some of them are crap</li>
   </ul>
 </div>
 
+<div class="slide">
+  <h1>Already Mentioned Several</h1>
+
+  <ul>
+    <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>    
+
+<div class="slide">
+  <h1>MooseX::Declare</h1>
+
+<pre><code>use MooseX::Declare;
+use 5.10.0; # for say
+
+class Person {
+    has greeting =&gt;
+        ( is =&gt; 'ro', isa =&gt; 'Str' );
+
+    method speak {
+        say $self-&gt;greeting;
+    }
+}</code></pre>
+</div>
+
+<div class="slide">
+  <h1>MooseX::Declare</h1>
+
+  <ul>
+    <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>
+
+<div class="slide">
+  <h1>MooseX::StrictConstructor</h1>
+
+  <ul>
+    <li>By default, unknown constructor arguments are ignored</li>
+    <li>MX::StrictConstructor turns these into an error</li>
+  </ul>
+</div>
+
+<div class="slide">
+  <h1>MooseX::StrictConstructor</h1>
+
+  <pre><code>package Person;
+
+use Moose;
+<span class="highlight">use MooseX::StrictConstructor;</span>
+
+has name =&gt; ( is =&gt; 'ro' );
+
+Person-&gt;new
+    ( na<span class="wrong">n</span>e =&gt; 'Ringo Shiina' ); # kaboom</code></pre>
+</div>
+
+<div class="slide">
+  <h1>MooseX::Traits</h1>
+
+  <ul>
+    <li>Combines object construction and role application</li>
+    <li>Makes it easy to create one-off customized objects</li>
+  </ul>
+</div>
+
+<div class="slide">
+  <h1>MooseX::Traits</h1>
+
+  <pre><code>package MyApp::Thingy;
+use Moose;
+
+<span class="highlight">with 'MooseX::Traits';</span>
+
+my $thing =
+    MyApp::Thingy-&gt;<span class="highlight">new_with_traits</span>
+        ( <span class="highlight">traits =&gt; [ 'Foo', 'Bar' ],</span>
+          size   =&gt; 42 );</code></pre>
+</div>
+
+<div class="slide">
+  <h1>MooseX::Getopt</h1>
+
+  <ul>
+    <li>Makes command-line interface programs easy!</li>
+    <li>Construct an object from CLI arguments</li>
+  </ul>
+</div>
+
+<div class="slide">
+  <h1>MooseX::Getopt</h1>
+
+  <pre><code>package App::CLI;
+use Moose;
+
+<span class="highlight">with 'MooseX::Getopt';</span>
+
+has file    =&gt;
+    ( is =&gt; 'ro', required =&gt; 1 );
+has filters =&gt;
+    ( is =&gt; 'ro', isa =&gt; 'ArrayRef[Str]' );
+
+sub run { ... }</code></pre>
+</div>
+
+<div class="slide">
+  <h1>MooseX::Getopt</h1>
+
+  <ul>
+    <li>Then call it like this:</li>
+  </ul>
+
+<pre><code>#!/usr/bin/perl
+
+use App::CLI;
+
+<span class="highlight">App::CLI-&gt;new_with_options()</span>-&gt;run();</code></pre>
+
+<pre>$ myapp-cli \
+   --file foo \
+   --filters compress \
+   --filters sanitize</pre>
+</div>
+
+<div class="slide">
+  <h1>MooseX::Clone</h1>
+
+  <pre><code>package Person;
+
+use Moose;
+<span class="highlight">with 'MooseX::Clone';</span>
+
+my $person = Person-&gt;new;
+my $clone  = <span class="highlight">$person-&gt;clone;</span></code></pre>
+</div>
+
+<div class="slide">
+  <h1>MooseX::NonMoose</h1>
+
+  <ul>
+    <li>Highly recommended for subclassing non-Moose parents</li>
+    <li>Gets all the little annoying details right</li>
+  </ul>
+</div>
+
+<div class="slide">
+  <h1>MooseX::Role::Parameterized</h1>
+
+  <pre><code>package HasCollection;
+<span class="current incremental">use MooseX::Role::Parameterized;</span>
+<span class="incremental">parameter type =&gt; ( isa     =&gt; 'Str',
+                    default =&gt; 'Item' );</span>
+<span class="incremental">role {
+    my $p = shift;
+
+    my $type =
+        'ArrayRef[' . $p-&gt;type() . ']';
+    has collection =&gt;
+        ( is  =&gt; 'ro',
+          isa =&gt; $type );
+};</span></code></pre>
+</div>
+
+<div class="slide">
+  <h1>MooseX::Role::Parameterized</h1>
+
+  <pre><code>package Person;
+
+use Moose;
+with HasCollection =&gt; { type =&gt; 'Int' };</code></pre>
+</div>
+
+<div class="slide fake-slide0">
+  <h1>The End (Really)</h1>
+</div>
+
 </div> 
 </body>
 </html>