Commit | Line | Data |
b751d33f |
1 | = Intro (30 minutes) |
2 | |
3 | * concepts (ala Moose::Manual::Concepts) |
4 | |
5 | = Classes |
6 | |
7 | * Making a class use Moose |
8 | * extends |
9 | * overrides/super |
10 | * trivial attributes |
11 | ** has 'foo' => ( is => ... ) (ro & rw) |
12 | ** no other attribute features yet |
13 | * "no Moose" |
14 | * Immutability |
15 | |
16 | == Exercises |
17 | |
18 | * Build a Person class that uses Moose |
19 | ** first_name |
20 | ** last_name |
21 | ** assume both attributes are always provided |
22 | * build an Employee class that is a subclass of Person |
23 | ** job_title |
24 | |
25 | = Roles |
26 | |
27 | * Making a role |
28 | * roles as interfaces |
29 | * requires |
30 | * consuming roles in classes |
31 | * consuming roles in roles |
32 | * "no Moose::Role" |
33 | |
34 | == Exercises |
35 | |
36 | * build a role for Human |
37 | * make the Person class consume the role |
38 | * make the role require a "full_name" method |
39 | * implement this method for Person |
40 | * override it for Employee to include their title |
41 | |
42 | = Basic attributes |
43 | |
44 | * required |
45 | * default & builder |
46 | * lazy |
8d1ce1d7 |
47 | * predicate, clearer |
b751d33f |
48 | * init_arg |
8d1ce1d7 |
49 | * reader & writer |
50 | * attribute inheritance |
51 | * MX attribute naming modules |
b751d33f |
52 | |
53 | == Exercises |
54 | |
55 | * Go back to Person class |
56 | ** make first & last name required |
57 | * Go back to Employee |
58 | ** make title default to "Worker" |
8d1ce1d7 |
59 | ** add predicate & clearer for title |
b751d33f |
60 | ** add salary_level attribute, number from 1-10 |
61 | ** salary, lazy default of salary_level * 1,000, init_arg is undef |
62 | |
63 | = Method modifiers |
64 | |
65 | * before/after |
66 | ** before for state validation |
67 | ** after for additional state changes |
68 | * around |
69 | ** modifying arguments & return values |
26164c8d |
70 | * method modifiers in roles |
71 | ** requiring the wrapped method |
72 | * augment/inner |
b751d33f |
73 | |
74 | == Exercises |
75 | |
b751d33f |
76 | = Types |
77 | |
78 | * built-in types |
79 | * parameterizable types |
80 | * declaring subtypes |
81 | ** URI |
82 | ** Email |
83 | ** class names & role names |
84 | * coercions |
65f6c586 |
85 | * duck_type |
b751d33f |
86 | * attribute isa & does |
65f6c586 |
87 | * attribute coerce => 1 |
88 | * MX::Types |
b751d33f |
89 | |
90 | == Exercises |
91 | |
65f6c586 |
92 | * Add sane types to all existing attributes in Person, Employee, roles |
93 | * Add an email attribute. Make a new email type that does some minimal validate like /[^@]+\@[\w\-]+(?:\.[\w\-]+)+/ |
94 | |
8d1ce1d7 |
95 | = Advanced attributes |
96 | |
97 | * weak_ref |
98 | * triggers |
99 | * delegation |
100 | * metaclass & traits |
101 | |
102 | == Exercises |
103 | |
65f6c586 |
104 | * Make the bank account a proper object and delegate to it for deposit & withdraw |
105 | * Add an overdraft account like in the cookbook |
106 | * Make the overdraft account link bank to accounts which link to it as a weak_ref |
107 | * metaclass & traits? |
108 | |
b751d33f |
109 | = Introspection |
110 | |
65f6c586 |
111 | * List of attributes for a class |
112 | ** attribute options |
113 | ** associated methods |
114 | * List of methods for a class |
115 | ** associated attributes |
116 | ** check original_package for source of method (did it come from a role?) |
117 | ** $method->isa(...) to determine if it's wrapped/augmented/overridden |
118 | * List of parent classes, subclasses |
b751d33f |
119 | |
26164c8d |
120 | = Tour of MooseX |
121 | |
65f6c586 |
122 | * MX::AH |
123 | ** delegation for Perl built-ins |
124 | ** private accessor with public provides (_options as the attribute, get_option, set_option, options_list) |
125 | ** lazy default of an empty reference |
126 | * ::StrictConstructor |
127 | * ::Getopt |
128 | * ::Clone |
129 | * ::Declare |
0d769072 |
130 | * ::Workers ? |
131 | * ::NonMoose |
65f6c586 |
132 | * ::Singleton |
133 | * ::ClassAttribute |
134 | |
26164c8d |
135 | = Writing a MooseX Module |
b751d33f |
136 | |
137 | == Exercises |