Keep It Simple, Stupid | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The repetition of $new+$old was an artifact of quickly fitting several demonstrations in a single example. I wouldn't jump to separating out such simple expressions that are only used once so that you have to use the variable names to mentally map a large number of items being combined to what they were set to. If an expression is more complex than the ones in my example, then introducing a named variable often makes sense. But the benefit of a named variable usually depends heavily on the quality of the name. With such short expressions, the name of the variable is often going to be only slightly shorter and can be much less clear. I can put a lot of effort into coming up with names when coding. Great names versus unclear names makes an enormous difference in the clarity of code. So I'm not excited to introduce a new name for something so small as createLink($USER,'you') that is used only once. And part of the point I was making with the example was how things scale when the code deserves to be split over multiple lines. I find this makes interpolation break down as far as code readability; that is, I don't like reading several lines of strings each with several named variables interpolated and above this a long list of variables being declared and initialized. For example, it makes it hard to notice that you are doing work to assign a value to a variable that you are actually no longer using below. As for Interpolation.pm, you don't show how much code has to be added to create %createLink and %plural_of and then has to be understood. A function or method like createLink() is a general-purpose abstraction while you wouldn't define just %createLink and only use it, avoiding the duplication of making a createLink(). So I've never gone that route. But since interpolating into strings also doesn't scale well for me, that isn't surprising. - tye In reply to Re^3: Perl style: Arguing against three-argument join() (vars)
by tye
|
|