import moose website
[gitmo/moose-htdocs.git] / ppw_roles_talk / roles.xul
CommitLineData
720accfe 1<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="chrome://global/skin/" type="text/css"?><?xml-stylesheet href="takahashi.css" type="text/css"?><page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="presentation" xmlns:html="http:/www.w3.org/1999/xhtml" orient="vertical" onkeypress="Presentation.onKeyPress(event);">
2<html:textarea id="builtinCode" style="visibility: collapse"><![CDATA[
3Horizontal
4Code Reuse
5with
6Møøse::Role
7----
8Stevan Little
9stevan.little@iinteractive.com
10http://www.iinteractive.com/moose
11http://search.cpan.org/~stevan/
12----
13Roles
14----
15
16----
17Classes
18----
19Roles
20do /not/
21inherit.
22----
23Inheritance is
24
25vertical reuse.
26----
27Roles
28compose.
29----
30Composition is
31
32horizontal reuse.
33----
34...
35----
36When
37to use
38Roles
39----
40My general rule
41of thumb is ...
42----
43s/MI/Roles/g
44----
45When
46to /not/ use
47Roles
48----
49When a class
50just makes
51more sense.
52----
53Roles are /not/ a
54replacement for
55inheritance.
56----
57How Roles
58Work
59----
60Roles are
61orphans.
62----
63Roles are
64composed.
65----
66Local class
67overrides role.
68----
69Role overrides
70inherited class.
71----
72Roles can
73conflict.
74----
75Method conflicts
76must be
77disambiguated.
78----
79Attribute conflicts
80cannot be
81disambiguated.
82----
83How
84to use
85Roles
86----
87 package My::Role;
88 use Moose::Role;
89
90 has my_attr => (is => 'rw');
91
92 requires 'a_method';
93
94 sub my_method { ... }
95----
96 package My::Class;
97 use Moose;
98
99 with 'My::Role';
100
101 sub a_method { ... }
102----
103 my $o = My::Class->new(
104 my_attr => '...'
105 );
106
107 $o->my_method();
108----
109Role
110Examples
111----
112Behavior
113Reuse
114----
115 package My::App::Conversions;
116 use Moose::Role;
117
118 sub decimal_to_percentage { ... }
119 sub percentage_to_decimal { ... }
120----
121Attribute
122Reuse
123----
124 package My::App::WithDBICSchema;
125 use Moose::Role;
126
127 has 'schema' => (
128 is => 'ro',
129 isa => 'DBIx::Class::Schema',
130 lazy => 1,
131 default => sub {
132 My::App::DB->connect(...)
133 }
134 );
135----
136Abstract
137Interfaces
138----
139 package My::App::Iterator::Abstract;
140 use Moose::Role;
141
142 requires 'has_next';
143 requires 'next';
144 requires 'peek';
145----
146Partial
147“Classes”
148----
149 package My::App::Report::Base;
150 use Moose::Role;
151
152 requires 'calculate';
153
154 sub run {
155 my $self = shift;
156 $self->setup;
157 $self->calculate;
158 $self->teardown;
159 }
160
161 sub setup { ... }
162 sub teardown { ... }
163----
164Modules
165which use
166Roles
167----
168MooseX::Getopt
169----
170 package My::App;
171 use Moose;
172
173 with 'MooseX::Getopt';
174
175 has 'foo' => (is => 'rw', isa => 'Int');
176
177 sub run { ... }
178
179 package main;
180 My::App->new_with_options->run
181----
182 stevan>./my_app.pl --foo 10
183----
184MooseX::Storage
185----
186MooseX::AttributeHelpers
187----
188Thank You
189for coming.
190----
191And always
192remember ...
193----
194Roles
195
196Classes
197]]></html:textarea>
198
199
200
201
202
203
204
205
206
207
208
209<deck flex="1" id="deck">
210
211<vbox flex="1"
212 onmousemove="Presentation.onMouseMoveOnCanvas(event);">
213 <toolbox id="canvasToolbar">
214 <toolbar>
215 <toolbarbutton oncommand="Presentation.home()" label="|&lt;&lt;"
216 observes="canBack"/>
217 <toolbarbutton oncommand="Presentation.back()" label="&lt;"
218 observes="canBack"/>
219 <toolbarbutton oncommand="Presentation.forward()" label="&gt;"
220 observes="canForward"/>
221 <toolbarbutton oncommand="Presentation.end()" label="&gt;&gt;|"
222 observes="canForward"/>
223 <toolbarseparator/>
224 <hbox align="center">
225 <textbox id="current_page" size="4"
226 oninput="if (this.value) Presentation.showPage(parseInt(this.value)-1);"/>
227 <description value="/"/>
228 <description id="max_page"/>
229 </hbox>
230 <toolbarseparator/>
231 <vbox flex="2">
232 <spacer flex="1"/>
233 <scrollbar id="scroller"
234 align="center" orient="horizontal"
235 oncommand="Presentation.showPage(parseInt(event.target.getAttribute('curpos')));"
236 onclick="Presentation.showPage(parseInt(event.target.getAttribute('curpos')));"
237 onmousedown="Presentation.onScrollerDragStart();"
238 onmousemove="Presentation.onScrollerDragMove();"
239 onmouseup="Presentation.onScrollerDragDrop();"/>
240 <spacer flex="1"/>
241 </vbox>
242 <toolbarseparator/>
243 <spacer flex="1"/>
244 <toolbarseparator/>
245 <toolbarbutton id="toggleEva" label="Eva"
246 type="checkbox"
247 autoCheck="false"
248 oncommand="Presentation.toggleEvaMode();"/>
249 <toolbarseparator/>
250 <toolbarbutton label="Edit"
251 oncommand="Presentation.toggleEditMode();"/>
252 <toolbarbutton oncommand="Presentation.reload();" label="Reload"/>
253 </toolbar>
254 </toolbox>
255 <vbox flex="1" id="canvas"
256 onclick="Presentation.onPresentationClick(event);">
257 <spacer flex="1"/>
258 <hbox flex="1">
259 <spacer flex="1"/>
260 <vbox id="content"/>
261 <spacer flex="1"/>
262 </hbox>
263 <spacer flex="1"/>
264 </vbox>
265</vbox>
266
267
268<vbox flex="1" id="edit">
269 <toolbox>
270 <toolbar>
271 <toolbarbutton label="New Page"
272 oncommand="Presentation.addPage()"/>
273 <spacer flex="1"/>
274 <toolbarseparator/>
275 <toolbarbutton label="View"
276 oncommand="Presentation.toggleEditMode();"/>
277 <toolbarbutton oncommand="Presentation.reload();" label="Reload"/>
278 </toolbar>
279 </toolbox>
280 <textbox id="textField" flex="1" multiline="true"
281 oninput="Presentation.onEdit()"/>
282 <hbox collapsed="true">
283 <iframe id="dataLoader" onload="if (window.Presentation) Presentation.onDataLoad();"/>
284 </hbox>
285</vbox>
286
287</deck>
288
289
290<broadcasterset>
291 <broadcaster id="canBack"/>
292 <broadcaster id="canForward"/>
293</broadcasterset>
294
295<commandset>
296 <command id="cmd_forward"
297 oncommand="if (Presentation.isPresentationMode) Presentation.forward();"/>
298 <command id="cmd_back"
299 oncommand="if (Presentation.isPresentationMode) Presentation.back();"/>
300 <command id="cmd_home"
301 oncommand="if (Presentation.isPresentationMode) Presentation.home();"/>
302 <command id="cmd_end"
303 oncommand="if (Presentation.isPresentationMode) Presentation.end();"/>
304</commandset>
305<keyset>
306 <key keycode="VK_ENTER" command="cmd_forward"/>
307 <key keycode="VK_RETURN" command="cmd_forward"/>
308 <key keycode="VK_PAGE_DOWN" command="cmd_forward"/>
309 <key keycode="VK_RIGHT" command="cmd_forward"/>
310 <key keycode="VK_DOWN" command="cmd_forward"/>
311 <!-- key keycode="VK_BACK_SPACE" command="cmd_back"/-->
312 <key keycode="VK_PAGE_UP" command="cmd_back"/>
313 <!-- <key keycode="VK_BACK_UP" command="cmd_back"/>-->
314 <!-- <key keycode="VK_BACK_LEFT" command="cmd_back"/>-->
315 <key keycode="VK_HOME" command="cmd_home"/>
316 <key keycode="VK_END" command="cmd_end"/>
317 <key key="n" modifiers="accel" oncommand="Presentation.addPage();"/>
318 <key key="r" modifiers="accel" oncommand="window.location.reload();"/>
319 <key key="e" modifiers="accel" oncommand="Presentation.toggleEditMode();"/>
320 <key key="a" modifiers="accel" oncommand="Presentation.toggleEvaMode();"/>
321</keyset>
322
323
324<script src="takahashi.js" type="application/x-javascript" />
325</page>
326<!-- ***** BEGIN LICENSE BLOCK *****
327 - Version: MPL 1.1
328 -
329 - The contents of this file are subject to the Mozilla Public License Version
330 - 1.1 (the "License"); you may not use this file except in compliance with
331 - the License. You may obtain a copy of the License at
332 - http://www.mozilla.org/MPL/
333 -
334 - Software distributed under the License is distributed on an "AS IS" basis,
335 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
336 - for the specific language governing rights and limitations under the
337 - License.
338 -
339 - The Original Code is the Takahashi-Method-based Presentation Tool in XUL.
340 -
341 - The Initial Developer of the Original Code is SHIMODA Hiroshi.
342 - Portions created by the Initial Developer are Copyright (C) 2005
343 - the Initial Developer. All Rights Reserved.
344 -
345 - Contributor(s): SHIMODA Hiroshi <piro@p.club.ne.jp>
346 -
347 - ***** END LICENSE BLOCK ***** -->
348
349