Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Python OO v Moose

by choroba (Abbot)
on Feb 06, 2013 at 11:34 UTC ( #1017388=note: print w/ replies, xml ) Need Help??


in reply to Python OO v Moose

There should be some =pod in the Perl code to pair with the docstrings. Also, use ASCII single quotes ' (or nothing before the fat comma):

package OurClass; =pod =cut use Moose; has arg1 => (is => 'rw'); has arg2 => (is => 'rw'); sub printargs { my $self = shift; say $self->$_ for qw/arg1 arg2/; } no Moose;
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: Python OO v Moose
Select or Download Code
Re^2: Python OO v Moose
by Ea (Friar) on Feb 06, 2013 at 12:33 UTC
    The single quote strangeness was due to a copy/paste from GoogleDocs. I'll have to keep that in mind when using that to share code. The """ is starting to make more sense now. I'm not sure if I have any preferences for documentation style yet. I like POD for the space it gives the text, except when I don't want to look at it, especially since I tend to prefer keeping the documentation near the methods. Javadoc is easily hidden in Eclipse, but I'm a little put off by its differentness. I haven't seen a style that really grabs me so far.

    I was in two minds in the printargs method. It looks better the way you've written it. I was trying to keep it simple so that people with no knowledge of Perl could see how it works, but I do like the for line. Likewise, I'd used lots of whitespace in the attribute distributions to make it 'friendlier'.

    Sometimes I can think of 6 impossible LDAP attributes before breakfast.

      I used to intersperse my pod and code, but eventually grew to dislike that, so now place all my pod at the end of the file.

      Yes, there's something to be said for keeping documentation and code close together, but having them in the same file is close enough for me. Putting all the pod at the end I think encourages me to write documentation that flows better as a document - making the pod less a list of methods, and more a how-to.

      package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1017388]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2014-08-20 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (115 votes), past polls