Oops, removed the wrong slides
[gitmo/moose-presentations.git] / moose-class / slides / index.html
index 25bf289..3c0ba31 100644 (file)
@@ -52,7 +52,7 @@ img#me05 {top: 43px;left: 36px;}
 
 <div class="slide">
   <h1>Introduction to Moose</h1>
-  <h2>Dave Rolsky</a>
+  <h2>Dave Rolsky</h2>
 </div>
 
 <div class="slide">
@@ -71,7 +71,7 @@ img#me05 {top: 43px;left: 36px;}
   <ul>
     <li><strong>Declarative</strong> OO sugar</li>
     <li>Introspectable</li>
-    <li>Extensible (188 MooseX::* on CPAN)</li>
+    <li>Extensible (202 MooseX::* on CPAN)</li>
     <li>Community approved (1200+ downstream dependents on CPAN)</li>
   </ul>
 </div>
@@ -1344,7 +1344,9 @@ $person-&gt;print();</code></pre>
 <pre><code>package Person;
 use Moose;
 
-<span class="highlight">with 'Printable';</span></code></pre>
+<span class="highlight">with 'Printable';</span>
+
+sub as_string { $_[0]-&gt;first_name() }</code></pre>
 </div>
 
 <div class="slide">
@@ -1355,6 +1357,8 @@ use Moose;
 
 <span class="delete">with 'Printable';</span>
 
+sub as_string { $_[0]-&gt;first_name() }
+
 <span class="highlight">has has_been_printed =&gt; ( is =&gt; 'rw'  );
 
 sub print {
@@ -1499,18 +1503,6 @@ with 'HasSubProcess';
 </div>
 
 <div class="slide">
-  <h1>Delayed Conflict</h1>
-
-  <pre><code>package SysadminAssassin;
-with 'Killer';</code></pre>
-
-  <ul>
-    <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>
-
-<div class="slide">
   <h1>Roles as Interfaces</h1>
 
   <ul>
@@ -1660,8 +1652,6 @@ requires 'compare';
   <h1>Real Examples</h1>
 
   <ul>
-    <li>Column and ColumnAlias both <em>do</em> ColumnLike</li>
-    <li>ColumnLike things can be used in certain parts of queries</li>
     <li>All queries <em>do</em> HasWhereClause</li>
     <li>Select <em>does</em> Comparable and Selectable (for subselects)</li>
     <li>A where clause requires its components to <em>do</em> Comparable</li>
@@ -1723,6 +1713,15 @@ has 'is_ripped' =&gt; ( is =&gt; 'rw' );</code></pre>
 </div>
 
 <div class="slide">
+  <h1>Read-only vs Read-write</h1>
+
+  <ul>
+    <li>Read-only is preferred</li>
+    <li>Minimize state in your application</li>
+  </ul>
+</div>
+
+<div class="slide">
   <h1>Required-ness</h1>
 
   <ul>
@@ -1808,6 +1807,7 @@ use Moose;
 
 has bank =&gt; (
     is      =&gt; 'rw',
+    # THIS WILL NOT WORK
     <span class="wrong">default =&gt; Bank-&gt;new(
                    name =&gt; 'Spire FCU' ),</span>
 );</code></pre>
@@ -1830,22 +1830,6 @@ has packages =&gt; (
 </div>
 
 <div class="slide">
-  <h1>What if I Want to Share?</h1>
-
-  <pre><code>package Person;
-use Moose;
-
-my $highlander_bank =
-    Bank-&gt;new(
-        name =&gt; 'Clan MacLeod Trust' );
-
-has bank =&gt; (
-    is      =&gt; 'rw',
-    default =&gt; sub { $highlander_bank },
-);</code></pre>
-</div>
-
-<div class="slide">
   <h1>Builder</h1>
 
   <ul>
@@ -2050,15 +2034,7 @@ Person-&gt;new( <span class="wrong">shoes =&gt; Shoes-&gt;new</span> );</code></
 
   <ul>
     <li>By default, subclasses inherit attribute as-is</li>
-    <li>Can change some attribute parameters in subclasses
-      <ul>
-        <li>default</li>
-        <li>builder</li>
-        <li>required</li>
-        <li>lazy</li>
-        <li>others we've not yet covered</li>
-      </ul>
-    </li>
+    <li>Can change attribute parameters in subclasses</li>
   </ul>
 </div>   
 
@@ -2411,62 +2387,6 @@ around run</span> =&gt; sub {
 </div>
 
 <div class="slide">
-  <h1>Augment and Inner</h1>
-
-  <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>
-</div>
-
-<div class="slide">
-  <h1>Augment and Inner</h1>
-
-  <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 { 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 { my $self = shift;
-          $self-&gt;tps_xml() . <span class="highlight">inner()</span> };</code></pre>
-</div>
-
-<div class="slide">
-  <h1>Augment and Inner</h1>
-
-  <ul>
-    <li>When we call <code>$tps-&gt;xml</code> ...
-      <ul>
-        <li><code>Document-&gt;xml</code></li>
-        <li><code>Report-&gt;xml</code></li>
-        <li><code>TPSReport-&gt;xml</code></li>
-      </ul>
-    </li>
-  </ul>
-</div>
-
-<div class="slide">
-  <h1>Augment and Inner Usage</h1>
-
-  <ul>
-    <li>Call <code>inner()</code> to "fill in the blank"</li>
-    <li>Requires designing for subclassing</li>
-    <li>Call <code>inner()</code> in the terminal class, just in case</li>
-  </ul>
-</div>
-
-<div class="slide">
   <h1>Method Modifiers Summary</h1>
 
   <ul>
@@ -2490,27 +2410,13 @@ extends 'Report';
         <li>alter parameters passed to the original method</li>
         <li>alter the return value of the original method</li>
         <li>not call the original method at all (or call a <em>different</em> method)</li>
+        <li>When using modifiers in a role, require the modified method</li>
       </ul>
     </li>
   </ul>
 </div>
 
 <div class="slide">
-  <h1>Method Modifiers Summary</h1>
-
-  <ul>
-    <li>When using modifiers in a role, require the modified method</li>
-    <li>Use <code>augment</code> and <code>inner</code> to invert the normal subclassing flow ...
-      <ul>
-        <li>Least- to most-specific (parents to children)</li>
-        <li>Build in "insertability" (stick more stuff in the "middle")</li>
-      </ul>
-    </li>
-    <li>Always call <code>inner</code> in the most specific subclass to allow for future extension</li>
-  </ul>
-</div>
-
-<div class="slide">
   <h1>Questions?</h1>
 </div>  
 
@@ -2726,7 +2632,7 @@ class_type 'DateTime';</code></pre>
   <h1>Subtype Shortcuts - <code>role_type</code></h1>
 
   <pre><code>use Moose::Util::TypeConstraints;
-role_type 'Printable';</coe></pre>
+role_type 'Printable';</code></pre>
 
 <hr />
 
@@ -2835,7 +2741,8 @@ coerce 'My::DateTime',
 <div class="slide">
   <h1>Coercion Examples</h1>
 
-  <pre><code>coerce 'ArrayRef[Int]',
+  <pre><code># BAD CODE - DO NOT COPY
+coerce 'ArrayRef[Int]',
     from 'Int',
     via  { [ $_ ] };</code></pre>
 
@@ -3373,7 +3280,6 @@ has history =&gt; (
 use Moose;
 has _favorite_numbers =&gt; (
     traits   =&gt; [ 'Array' ],
-    is       =&gt; 'bare',
     isa      =&gt; 'ArrayRef[Int]',
     default  =&gt; sub { [] },
     init_arg =&gt; undef,
@@ -3436,7 +3342,7 @@ has account =&gt; (
     isa     =&gt; 'BankAccount',
     handles =&gt; {
         receive_100 =&gt;
-            <span class="highlight">[ 'deposit', 100 ]</span>
+            <span class="highlight">[ 'deposit', 100 ]</span>,
         give_100    =&gt;
             <span class="highlight">[ 'withdraw', 100 ]</span>
     },
@@ -3540,6 +3446,10 @@ print <span class="highlight">Person-&gt;meta
 </div>
 
 <div class="slide">
+  <h1>Questions?</h1>
+</div>  
+
+<div class="slide">
   <h1>Exercises</h1>
 
   <pre># cd exercises
@@ -3570,7 +3480,7 @@ Iterate til this passes all its tests</pre>
 
   <ul>
     <li><strong>Not comprehensive</strong></li>
-    <li>177 MooseX distributions on CPAN as of 09/21/2010</li>
+    <li>188 MooseX distributions on CPAN as of 02/03/2011</li>
     <li>Some of them are crap</li>
   </ul>
 </div>
@@ -3591,7 +3501,7 @@ Iterate til this passes all its tests</pre>
   <h1>MooseX::Declare</h1>
 
 <pre><code>use MooseX::Declare;
-use 5.10.0; # for say
+use 5.12.0; # for say
 
 class Person {
     has greeting =&gt;
@@ -3610,7 +3520,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?)
+    <li>But not supported by <code>PPI</code>, <code>perltidy</code>, etc. (yet?)</li>
   </ul>
 </div>