Well, using it for interpolation is just one example. Let's say I have to use a property over and over. It gets pretty tiresome to keep typing out $self->get_value1 especially if it has a long property name. Also, I find $self-> adds visual clutter and makes the code harder to read in general. Creating these scalars does feel a bit dirty, though. I would like to get away from it. Maybe I should concentrate on making more regular use of my editor's autocomplete feature and just live with the uglier code.
| [reply] [d/l] [select] |
Let's say I have to use a property over and over.
I should have made this a little more clear: If we're just talking about one property copied into one scalar that gets used many times, or maybe even two or three properties/scalars, then doing so is probably still acceptable. But as soon as you do this more than that, then I'd start considering it "too much".
Maybe I should concentrate on making more regular use of my editor's autocomplete feature and just live with the uglier code.
I coded in Java for many years, where AbstractClassNameImplementationFactory.withReallyLongAndDescripiveMethodNames() are common - this seems horrible to some, but once you get good at using the editor's autocomplete, you hardly notice this stuff anymore. The same can apply in Perl, if you look at it the right way, i.e. reconsider your notion of "ugly" - $self->method_name (and the fact this doesn't interpolate) is just part of Perl's OO style, if you accept Perl's OO then consider accepting that part too :-)
Also, there are other things you can do, for example in Perl it's very common to use $obj->prop and $obj->prop("newval") instead of $obj->get_prop() and $obj->set_prop("newval"), respectively. And it's also possible to shorten $self to $s or similar, so instead of $self->get_foo(), now you've got $s->foo, already a lot shorter.
| [reply] [d/l] [select] |