<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>
<div class="slide">
<h1>Object Construction a la Moose</h1>
- <pre><code>Person->new(@_)</code></pre>
+ <pre><code>Person->new(@args)</code></pre>
<ol style="margin-top: 0">
- <li>Calls <code>Person->BUILDARGS(@_)</code> to turn <code>@_</code> into a hashref</li>
+ <li>Calls <code>Person->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->BUILDALL($constructor_args)</code>
<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>
<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>
...
</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>
</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>
<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>
<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>
<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>
<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>
use Moose;
has _favorite_numbers => (
traits => [ 'Array' ],
- is => 'bare',
isa => 'ArrayRef[Int]',
default => sub { [] },
init_arg => undef,
</div>
<div class="slide">
+ <h1>Questions?</h1>
+</div>
+
+<div class="slide">
<h1>Exercises</h1>
<pre># cd exercises
<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>