Beefy Boxes and Bandwidth Generously Provided by pair Networks
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
in thread Perl style: Arguing against three-argument join() by martin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-18 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found