develooper Front page | perl.moose | Postings from July 2011

Moose documentation, "methods" and all that jazz...

Thread Next
Meir Guttman
July 3, 2011 02:53
Moose documentation, "methods" and all that jazz...
Message ID:
Hi all!


First I should mention that I am a Perl newbie, using Perl for less than two
years! I learned Perl by doing, never attending a formal course. And
although I am using objects daily (how can one NOT using these?), I never
created an OO package. This is my first post to this list.


I recently came to realize that it might be beneficial to implement a
certain package as an OO one. My first stop was, as suggested by the CPAN
Moose page, Moose::Manual and all its hyper-links. Here my enthusiasm


These pages deal a lot with "Attributes". In fact, four of these chapters,
under different names, explain many aspects of these. Nevertheless, no
explanation is offered as to the accessibility to these attributes. What are
the scoping rules?


As opposed to "attributes", "methods" get next to nothing treatment! The
only coverage of methods is in the "concepts" chapter and it is literally





A method is very straightforward. Any subroutine you define in your class is
a method.


Methods correspond to verbs, and are what your objects can do. For example,
a User can login.


sub login { ... }




That's it folks! You will not find a "Methods" chapter there!


I couldn't find a non-trivial example as to how to write a useful method or
how to INVOKE one in your script. Yes, I did look at the "Cookbook"
(Moose::Cookbook::Basics::Recipexxx)! But again, much about attributes
there, very little about methods.


One example: You see a lot of "my $self = shift;" in the code examples of
some methods, but not a single word about what is it, of what use is it and
why do you need it. (It seems to be a common convention to use this variable


Another: You will fleetingly find terms such as "privately accessible..."
(those entities with a name starting in an underscore?) and "publicly
accessible..." (those that do not?). What do these mean? Why do you need and
where do you use one or the other? Can you "privately access" a "publicly
accessible" entity? Not a word!


In short, a lot to be desired...


Can somebody point me to a better source?




Please, don't flame me! Even though I should know a lot more about many more
things in Perl, basic and advanced, an introduction such as Moose::Manual
should be peppered with hyper-links to even basic concepts such as packages,
and so. Bear with me...

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About