Improve highlighting on native traits sample code
[gitmo/moose-presentations.git] / moose-class / slides / index.html
index 056d33b..46ac36a 100644 (file)
@@ -2015,7 +2015,7 @@ 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>By default, subclasses inherit attributes as-is</li>
     <li>Can change attribute parameters in subclasses</li>
   </ul>
 </div>   
@@ -2600,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>
@@ -2614,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(
@@ -2630,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 ) },
@@ -2645,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'
@@ -2664,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',
@@ -2944,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>
@@ -3172,8 +3201,12 @@ has account =&gt; (
     },</code></pre>
 
   <ul>
-    <li><code>$person-&gt;receive_money</code> = <code>$person-&gt;account-&gt;deposit</code></li>
-    <li><code>$person-&gt;give_money</code> = <code>$person-&gt;account-&gt;withdraw</code></li>
+    <li><code>$person-&gt;receive_money</code>
+      <br/>
+      &nbsp;&nbsp;&nbsp;&nbsp;= <code>$person-&gt;account-&gt;deposit</code></li>
+    <li><code>$person-&gt;give_money</code>
+      <br/>
+      &nbsp;&nbsp;&nbsp;&nbsp;= <code>$person-&gt;account-&gt;withdraw</code></li>
   </ul>
 </div>
 
@@ -3261,7 +3294,7 @@ has history =&gt; (
   <pre><code>package Person;
 use Moose;
 has _favorite_numbers =&gt; (
-    traits   =&gt; [ 'Array' ],
+    <span class="highlight">traits   =&gt; [ 'Array' ],</span>
     isa      =&gt; 'ArrayRef[Int]',
     default  =&gt; sub { [] },
     init_arg =&gt; undef,
@@ -3340,82 +3373,6 @@ $person-&gt;account-&gt;deposit(100);</code></pre>
 </div>
 
 <div class="slide">
-  <h1>Traits and Metaclasses</h1>
-
-  <ul>
-    <li>The ultimate in customization</li>
-    <li>Per attribute metaclasses</li>
-    <li>Per attribute roles applied to the attribute metaclass</li>
-    <li>Change the meta-level behavior</li>
-  </ul>
-</div>
-
-<div class="slide">
-  <h1>Traits and Metaclasses</h1>
-
-  <ul>
-    <li>The default metaclass is <code>Moose::Meta::Attribute</code></li>
-    <li>Controls accessor generation, defaults, delegation, etc.</li>
-    <li>Adding a role to this metaclass (or replacing it) allows for infinite customization</li>
-  </ul>
-</div>
-
-<div class="slide">
-  <h1>Traits and Metaclasses</h1>
-
-  <ul>
-    <li>Can add/alter/remove an attribute parameter (from <code>has</code>)</li>
-    <li>Can change behavior of created attribute</li>
-  </ul>
-</div>
-
-<div class="slide">
-  <h1>Simple Trait Example</h1>
-
-  <pre><code>package Person;
-use Moose;
-use MooseX::LabeledAttributes;
-
-has ssn =&gt; (
-    <span class="highlight">traits =&gt; [ 'Labeled' ],</span>
-    is     =&gt; 'ro',
-    isa    =&gt; 'Str',
-    <span class="highlight">label  =&gt; 'Social Security Number',</span>
-);
-print <span class="highlight">Person-&gt;meta
-            -&gt;get_attribute('ssn')-&gt;label;</span></code></pre>
-</div>
-
-<div class="slide">
-  <h1>Simple Metaclass Example</h1>
-
-  <pre><code>package Person;
-use Moose;
-use MooseX::LabeledAttributes;
-
-has ssn =&gt; (
-    <span class="highlight">metaclass =&gt;
-        'MooseX::Meta::Attribute::Labeled',</span>
-    is        =&gt; 'ro',
-    isa       =&gt; 'Str',
-    <span class="highlight">label     =&gt; 'Social Security Number',</span>
-);
-print <span class="highlight">Person-&gt;meta
-            -&gt;get_attribute('ssn')-&gt;label;</span></code></pre>
-</div>
-
-<div class="slide">
-  <h1>Traits vs Metaclass</h1>
-
-  <ul>
-    <li>Can apply any mix of traits to an attribute</li>
-    <li>But just one metaclass</li>
-    <li>Traits (aka roles) can cooperate</li>
-    <li>Metaclasses require you to pick just one</li>
-  </ul>
-</div>
-
-<div class="slide">
   <h1>Advanced Attributes Summary</h1>
 
   <ul>
@@ -3423,7 +3380,6 @@ print <span class="highlight">Person-&gt;meta
     <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>
 
@@ -3656,12 +3612,13 @@ with HasCollection =&gt; { type =&gt; 'Int' };</code></pre>
   </p>
 
   <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>
+    <li><a href="http://metacpan.org/release/Catalyst-Runtime">Catalyst</a></li>
+    <li><a href="http://metacpan.org/release/CHI">CHI</a></li>
+    <li><a href="http://metacpan.org/release/Devel-REPL">Devel::REPL</a></li>
+    <li><a href="http://metacpan.org/release/Dist-Zilla">Dist::Zilla</a></li>
+    <li><a href="http://metacpan.org/release/Email-Sender">Email::Sender</a></li>
+    <li><a href="http://metacpan.org/release/Fey">Fey</a></li>
+    <li><a href="http://metacpan.org/release/Net-Twitter">Net::Twitter</a></li>
   </ul>
 </div>
 
@@ -3670,7 +3627,7 @@ with HasCollection =&gt; { type =&gt; 'Int' };</code></pre>
 
   <ul>
     <li><a href="http://moose.perl.org/">http://moose.perl.org/</a></li>
-    <li><a href="http://search.cpan.org/dist/Moose/lib/Moose/Manual.pod">Moose::Manual</a> and <a href="http://search.cpan.org/dist/Moose/lib/Moose/Cookbook.pod">Moose::Cookbook</a></li>
+    <li><a href="https://metacpan.org/module/Moose::Manual">Moose::Manual</a> and <a href="https://metacpan.org/module/Moose::Cookbook">Moose::Cookbook</a></li>
     <li><a href="irc://irc.perl.org/#moose">irc://irc.perl.org/#moose</a></li>
     <li>mailing list - <a href="mailto:moose@perl.org">moose@perl.org</a></li>
     <li>Slides and exercises are in Moose's git repo:
@@ -3689,7 +3646,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