Personally I prefer the Attack->heavy approach over Attack->new("heavy"). Why? Because when (not "if"!) you mistype it as "haevy", then Perl will automatically generate an error message for you. You don't need to write that logic to check the string is valid; Perl will for you.
To an extent I agree with hippo's answer, that it's nice for constructors to be called new, but I don't think that warrants throwing out the whole approach. Instead you could just name the method Attack->new_heavy. This is perfectly clear, and similar to things like new_from_file or new_from_xml you see all the time.
In reply to Re: Convenient Constructors - a Moo question
by tobyink
in thread Convenient Constructors - a Moo question
by blindluke
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |