Doh, slide on Bool was totally wrong
[gitmo/moose-presentations.git] / moose-class / slides / index.html
index 9ae74e4..7c57d21 100644 (file)
@@ -71,7 +71,8 @@ img#me05 {top: 43px;left: 36px;}
   <ul>
     <li><strong>Declarative</strong> OO sugar</li>
     <li>Introspectable</li>
-    <li>Extensible (MooseX::* on CPAN)</li>
+    <li>Extensible (177 MooseX::* on CPAN)</li>
+    <li>Community approved (1222 downstream dependents on CPAN)</li>
   </ul>
 </div>
 
@@ -892,8 +893,8 @@ use Moose;</code></pre>
   <h1>BUILDARGS</h1>
 
   <ul>
-    <li>Takes <code>@_</code>, returns a hash reference of attribute name/value pairs</li>
-    <li>Accepts a hash or hashref; throws otherwise</li>
+    <li>Processes <code>new</code>'s <code>@_</code>, returns a hash reference of attribute name/value pairs</li>
+    <li>Accepts a hash or hashref; errors 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>
   </ul>
@@ -967,6 +968,7 @@ sub BUILD {
   <ul>
     <li>Technically it's a hash reference</li>
     <li><span class="wrong">If you <em>ever</em> treat it as one <strong>you are doing it wrong!</strong></span></li>
+    <li>Moose probably provides a feature to do what you need</li>
   </ul>
 </div>
 
@@ -976,6 +978,7 @@ sub BUILD {
   <ul>
     <li>Like <code>DESTROY</code>, but Moose makes sure all <code>DEMOLISH</code> methods in a hierarchy are called</li>
     <li>Called in normal inheritance order, children to parents</li>
+    <li><em>Never</em> called by you, only by Perl itself</li>
   </ul>
 </div>
 
@@ -1039,6 +1042,7 @@ extends 'LWP';</code></pre>
   <ul>
     <li><code>override</code> is another method modifier</li>
     <li>An alternative to Perl's <code>SUPER::</code></li>
+    <li><em>Declares</em> your intent to override a method</li>
   </ul>
 </div>
 
@@ -1050,13 +1054,13 @@ use Moose;
 
 <span class="current incremental">extends 'Person';</span>
 
-<span class="incremental">override</span> work =&gt; sub {
+<span class="incremental">override</span> <span class="incremental">work</span> <span class="incremental">=&gt; sub {
     my $self = shift;
 
     die "Pay me first"
         unless $self-&gt;got_paid;
-    <span class="incremental">super();</span>
-}<span class="incremental">;</span></code></pre>
+    super();
+}</span><span class="incremental">;</span></code></pre>
 </div>
 
 <div class="slide">
@@ -1107,8 +1111,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>
 
@@ -1428,64 +1431,12 @@ 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>
-
-  <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-&gt;break_it_down;
-    if ( rand(1) &lt; 0.5 ) {
-        $self-&gt;break_bone;
-    }
-}</code></pre>
-</div>
-
-<div class="slide">
-  <h1>Still Full of Fail</h1>
+  <h1>Conflicts Are a Smell</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>
 
@@ -1578,7 +1529,7 @@ use Moose;
 
 <span class="incremental">with 'HasSize';
 
-has size => ( is => 'ro' );</span></code></pre>
+has size =&gt; ( is =&gt; 'ro' );</span></code></pre>
 </div>
 
 <div class="slide">
@@ -1592,7 +1543,7 @@ requires 'size';
 package Shirt;
 use Moose;
 
-has size => ( is => 'ro' );
+has size =&gt; ( is =&gt; 'ro' );
 
 with 'HasSize';</code></pre>
 </div>
@@ -1614,9 +1565,9 @@ with 'HasSize';</code></pre>
   <pre><code>package Comparison;
 use Moose;
 
-has [ 'left', 'right' ] => (
-    is   => 'ro',
-    <span class="highlight">does => 'Comparable',</span>
+has [ 'left', 'right' ] =&gt; (
+    is   =&gt; 'ro',
+    <span class="highlight">does =&gt; 'Comparable',</span>
 );
 </code></pre>
 
@@ -1913,7 +1864,7 @@ has bank =&gt; (
 sub _build_bank {
     my $self = shift;
     return Bank-&gt;new(
-        name => 'Spire FCU' );
+        name =&gt; 'Spire FCU' );
 }</code></pre>
 </div>
 
@@ -1970,7 +1921,7 @@ use Moose;
 
 has shoe_size =&gt; (
     is       =&gt; 'ro',
-    required =&gt; 'ro',
+    required =&gt; 1,
 );</code></pre>
 </div>
 
@@ -1980,7 +1931,7 @@ has shoe_size =&gt; (
   <pre><code>has shoes =&gt; (
     is      =&gt; 'ro',
     <span class="highlight">lazy    =&gt; 1,</span>
-    builder => '_build_shoes',
+    builder =&gt; '_build_shoes',
 );
 
 sub _build_shoes {
@@ -2053,7 +2004,7 @@ has account =&gt; (
   <pre><code>package Person;
 use Moose;
 
-has shoe_size => (
+has shoe_size =&gt; (
     is       =&gt; 'ro',
     <span class="highlight">init_arg =&gt; 'foot_size',</span>
 );
@@ -2071,7 +2022,7 @@ print $person-&gt;shoe_size;</code></pre>
 <pre><code>package Person;
 use Moose;
 
-has shoes => (
+has shoes =&gt; (
     is       =&gt; 'ro',
     <span class="highlight">init_arg =&gt; undef,</span>
 );
@@ -2470,19 +2421,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">
@@ -2635,15 +2588,12 @@ Item
   <h1>Bool</h1>
 
   <h2>True</h2>
-  <pre><code>1
-924.1
-'true'
-{}</code></pre>
+  <pre><code>1</code></pre>
 
   <h2>False</h2>
   <pre><code>0
-0.0
 '0'
+''
 undef</code></pre>
 
   <ul>
@@ -2803,7 +2753,7 @@ duck_type Car =&gt; qw( run break_down );</code></pre>
   <h1>Subtype Shortcuts - <code>enum</code></h1>
 
   <pre><code>use Moose::Util::TypeConstraints;
-enum Color =&gt; qw( red blue green ) );</code></pre>
+enum Color =&gt; qw( red blue green );</code></pre>
 
 <hr />
 
@@ -2926,6 +2876,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;
@@ -3056,9 +3019,9 @@ coerce <span class="highlight">ArrayOfInt</span>
 
 use MyApp::Types qw( ArrayOfInt );
 
-has transaction_history => (
-    is  => 'rw',
-    isa => ArrayOfInt,
+has transaction_history =&gt; (
+    is  =&gt; 'rw',
+    isa =&gt; ArrayOfInt,
 );</code></pre>
 </div>
 
@@ -3102,15 +3065,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>
@@ -3251,7 +3205,7 @@ $alice-&gt;friend($bob);</code></pre>
 
 has lungs =&gt; (
     is      =&gt; 'ro',
-    isa     => 'Lungs',
+    isa     =&gt; 'Lungs',
     <span class="highlight">handles =&gt; [ 'inhale', 'exhale' ],</span>
 );</code></pre>
 
@@ -3582,10 +3536,6 @@ print <span class="highlight">Person-&gt;meta
 </div>
 
 <div class="slide">
-  <h1>Questions?</h1>
-</div>  
-
-<div class="slide">
   <h1>Exercises</h1>
 
   <pre># cd exercises
@@ -3595,8 +3545,20 @@ print <span class="highlight">Person-&gt;meta
 Iterate til this passes all its tests</pre>
 </div>
 
+<div class="slide">
+  <h1>CYOA</h1>
+
+  <p>
+    If there is time, keep going ...
+  </p>
+
+  <p>
+    Otherwise, jump to slide 269 ...
+  </p>
+</div>
+
 <div class="slide fake-slide0">
-  <h1>Part 7: A Brief Tour of MooseX</h1>
+  <h1>Bonus: A Brief Tour of MooseX</h1>
 </div>
 
 <div class="slide">
@@ -3604,7 +3566,7 @@ Iterate til this passes all its tests</pre>
 
   <ul>
     <li><strong>Not comprehensive</strong></li>
-    <li>152 MooseX distributions on CPAN as of 02/02/2010</li>
+    <li>177 MooseX distributions on CPAN as of 09/21/2010</li>
     <li>Some of them are crap</li>
   </ul>
 </div>
@@ -3790,18 +3752,21 @@ with HasCollection =&gt; { type =&gt; 'Int' };</code></pre>
   <h1>Questions?</h1>
 </div>  
 
-<!--
-<div class="slide fake-slide0">
-  <h1>Part 8: Introspection</h1>
-</div>
+<div class="slide">
+  <h1>Moose-using Modules</h1>
 
-<div class="slide fake-slide0">
-  <h1>Part 9: Writing Moose Extensions</h1>
-</div>
--->
+  <p>
+    For further reading, a few modules which use Moose ...
+  </p>
 
-<div class="slide fake-slide0">
-  <h1>The End</h1>
+  <ul>
+    <li><a href="http://search.cpan.org/dist/Catalyst-Runtime">Catalyst</a></li>
+    <li><a href="http://search.cpan.org/dist/CHI">CHI</a></li>
+    <li><a href="http://search.cpan.org/dist/Devel-REPL">Devel::REPL</a></li>
+    <li><a href="http://search.cpan.org/dist/Email-Sender">Email::Sender</a></li>
+    <li><a href="http://search.cpan.org/dist/Fey">Fey</a></li>
+    <li><a href="http://search.cpan.org/dist/Net-Twitter">Net::Twitter</a></li>
+  </ul>
 </div>
 
 <div class="slide">
@@ -3818,6 +3783,10 @@ with HasCollection =&gt; { type =&gt; 'Int' };</code></pre>
   </ul>
 </div>
 
+<div class="slide fake-slide0">
+  <h1>The End</h1>
+</div>
+
 </div> 
 </body>
 </html>