Add mention of Specio
[gitmo/moose-presentations.git] / moose-class / slides / index.html
index c8c2e21..1f2c059 100644 (file)
@@ -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>
@@ -950,10 +950,10 @@ sub BUILD {
 <div class="slide">
   <h1>Object Construction a la Moose</h1>
 
-  <pre><code>Person-&gt;new(@_)</code></pre>
+  <pre><code>Person-&gt;new(@args)</code></pre>
 
   <ol style="margin-top: 0">
-    <li>Calls <code>Person-&gt;BUILDARGS(@_)</code> to turn <code>@_</code> into a hashref</li>
+    <li>Calls <code>Person-&gt;BUILDARGS(@args)</code> to turn <code>@args</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-&gt;BUILDALL($constructor_args)</code>
@@ -1032,7 +1032,7 @@ extends 'LWP';</code></pre>
         <li>No <code>DEMOLISH()</code></li>
       </ul>
     </li>
-    <li>But see <code>MooseX::NonMoose</code> for a workaround</li>
+    <li>But <code>MooseX::NonMoose</code> fixes all of this</li>
   </ul>
 </div>  
 
@@ -1155,8 +1155,8 @@ Person-&gt;can('extends');</code></pre>
   <h1>Cleaning Up Moose Droppings</h1>
 
   <pre><code>package Person;
-<span class="highlight">use namespace::autoclean;</span>
 use Moose;
+<span class="highlight">use namespace::autoclean;</span>
 
 ...
 
@@ -1234,8 +1234,6 @@ use Moose;
 
 # perl bin/prove -lv t/00-prereq.t
 
-# perl install-moose (if needed)
-
 ## Read the instructions in t/01-classes.t
 
 # perl bin/prove -lv t/01-classes.t
@@ -1487,34 +1485,6 @@ Integer-&gt;does('Comparable'); # also true!</code></pre>
 </div>
 
 <div class="slide">
-  <h1>Name Conflicts Between Roles</h1>
-
-  <pre><code>package HasSubProcess;
-use Moose::Role;
-
-<span class="highlight">sub execute { ... }</span>
-
-package Killer;
-use Moose::Role;
-
-with 'HasSubProcess';
-
-<span class="highlight">sub execute { ... }</span></code></pre>
-</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>
@@ -1725,6 +1695,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>
@@ -2036,16 +2015,8 @@ Person-&gt;new( <span class="wrong">shoes =&gt; Shoes-&gt;new</span> );</code></
   <h1>Attribute Inheritance</h1>
 
   <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>By default, subclasses inherit attributes as-is</li>
+    <li>Can change attribute parameters in subclasses</li>
   </ul>
 </div>   
 
@@ -2421,9 +2392,9 @@ around run</span> =&gt; sub {
         <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>
+    <li>When using modifiers in a role, require the modified method</li>
   </ul>
 </div>
 
@@ -2629,11 +2600,15 @@ has start_date =&gt; (
   <h1>Subtype Shortcuts - <code>class_type</code></h1>
 
   <pre><code>use Moose::Util::TypeConstraints;
-class_type 'DateTime';</code></pre>
+
+class_type 'DateTime';
+
+</code></pre>
 
 <hr />
 
-<pre><code>subtype     'DateTime',
+<pre><code>
+subtype     'DateTime',
     as      'Object',
     where   { $_-&gt;isa('DateTime') },
     message { ... };</code></pre>
@@ -2643,11 +2618,15 @@ class_type 'DateTime';</code></pre>
   <h1>Subtype Shortcuts - <code>role_type</code></h1>
 
   <pre><code>use Moose::Util::TypeConstraints;
-role_type 'Printable';</code></pre>
+
+role_type 'Printable';
+
+</code></pre>
 
 <hr />
 
-<pre><code>subtype 'Printable',
+<pre><code>
+subtype 'Printable',
     as  'Object',
     where
         { Moose::Util::does_role(
@@ -2659,11 +2638,15 @@ role_type 'Printable';</code></pre>
   <h1>Subtype Shortcuts - <code>duck_type</code></h1>
 
   <pre><code>use Moose::Util::TypeConstraints;
-duck_type Car =&gt; qw( run break_down );</code></pre>
+
+duck_type Car =&gt; qw( run break_down );
+
+</code></pre>
 
 <hr />
 
-<pre><code>subtype 'Car',
+<pre><code>
+subtype 'Car',
     as      'Object',
     where   { all { $_-&gt;can($_) }
               qw( run break_down ) },
@@ -2674,11 +2657,15 @@ 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 />
 
-<pre><code>my %ok = map { $_ =&gt; 1 }
+<pre><code>
+my %ok = map { $_ =&gt; 1 }
              qw( red blue green );
 
 subtype     'Color'
@@ -2693,7 +2680,9 @@ subtype     'Color'
   <pre><code>package Person;
 
 <span class="highlight">my $posint =
-    subtype as 'Int', where { $_ &gt; 0 };</span>
+    subtype
+        as 'Int',
+        where { $_ &gt; 0 };</span>
 
 has size =&gt; (
     is  =&gt; 'ro',
@@ -2752,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>
 
@@ -2850,7 +2840,7 @@ sub work {
   <h1>Digression: The Type Registry</h1>
 
   <ul>
-    <li>Types are actually <code>Moose::Meta::TypeConstraints</code> <em>objects</em></li>
+    <li>Types are actually <code>Moose::Meta::TypeConstraint</code> <em>objects</em></li>
     <li>Stored in an interpreter-global registry mapping names to objects</li>
   </ul>
 </div>
@@ -2972,10 +2962,21 @@ has transaction_history =&gt; (
 </div>
 
 <div class="slide">
+  <h1>Specio</h1>
+
+  <ul>
+    <li>My attempt to replace <code>MooseX::Types</code> <strong>and</strong> built-in types</li>
+    <li>Third-system effect?</li>
+    <li>Still alpha - needs some work</li>
+  </ul>
+</div>
+
+<div class="slide">
   <h1>Recommendation</h1>
 
   <ul>
-    <li>Use <code>MooseX::Types</code></li>
+    <li>Use <code>MooseX::Types</code> for now</li>
+    <li>Switch to <code>Specio</code> when it's ready?</li>
     <li>Compile time error catching and automatic namespacing are huge wins</li>
     <li>Docs from <code>Moose::Util::TypeConstraints</code> are 98% compatible with <code>MooseX::Types</code> anyway</li>
     <li>A function exported by a type library works wherever a type name would</li>
@@ -3290,7 +3291,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,
@@ -3457,6 +3457,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
@@ -3508,7 +3512,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;
@@ -3700,7 +3704,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="font-size:80%; white-space: nowrap">git://jules.scsys.co.uk/gitmo/moose-presentations</span></li>
+        <span style="font-size:80%; white-space: nowrap">git://git.moose.perl.org/moose-presentations.git</span></li>
   </ul>
 </div>
 
@@ -3714,7 +3718,7 @@ with HasCollection =&gt; { type =&gt; 'Int' };</code></pre>
 
 <!--
 
-Copyright 2009 David Rolsky. All Rights Reserved.
+Copyright 2009-2013 David Rolsky. All Rights Reserved.
 
 This work is licensed under a Creative Commons Attribution-Share Alike
 3.0 United States License See