Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Commonly accepted style guide?

by sauoq (Abbot)
on Sep 25, 2005 at 07:21 UTC ( #494878=note: print w/replies, xml ) Need Help??

in reply to Commonly accepted style guide?

  • What items do you unconciously look for as signals that what you're reading merits a closer look?

Firstly and most commonly: poor function names. Secondly and almost as common: poor variable names. Thirdly: poorly written comments.

If I see @n[$i] I get very worried.

  • Are there items that make you feel more comfortable with the code?

Good function names, variable names, and comments.

  • Do you feel you can rate the experience level of the author by how the code looks, both in Perl and programming in general?

Generally and to some extent, yes. But there are lots of exceptions. There are some capable but entirely self-taught developers who have peculiar styles and I've seen some really lousy Perl code written by very good C programmers. At the extreme lower end of the scale, though, it's usually easy to judge experience, at least with a particular language.

  • Has your style changed as you have improved as a programmer, both in Perl and in general? If so, how?

Sure. How? That's a big question. I guess a concise way to put it is that my code has gotten more expressive. By which I mean that my intentions are, I think, more transparent to the reader. Another shorter way to put it is that my code makes more sense these days... ;-)

  • Do you think that the style of a piece of code can contribute to its maintainability?

Of course.

"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re^2: Commonly accepted style guide?
by Anonymous Monk on Sep 26, 2005 at 09:25 UTC

    If I see @n[$i] I get very worried.

    I don't. It's about time we got rid of that warning. It's going to be the right syntax in perl6, it's doing the right thing in perl5, and considering that:

    @n[$i,$j,$k,$l] @n[$i,$j,$k] @n[$i,$j]
    return 4, 3, and 2 element slices - the use of @n[$i] isn't unnatural at all. Its a one element slice. And what does a slice in scalar context return? It's last element. Which, obviously, is $n[$i].

    So, I think in this case that Perl should act perlish, and shut up and DWIM (which it is doing already). And not whine and pretent to be Java or Python.

      I don't.

      Perhaps you should. Here's one example (paraphrased from real life) of how it can get ugly...

      #!/usr/bin/perl $\=$/; @n[0] = localtime; $n[1] = localtime; print for @n;

      "My two cents aren't worth a dime.";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://494878]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2017-03-25 06:20 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (311 votes). Check out past polls.