Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
XP is just a number
 
PerlMonks  

Re: Re: IYHO, what do you consider good code?

by helgi (Hermit)
on Jun 13, 2003 at 11:02 UTC ( #265641=note: print w/ replies, xml ) Need Help??


in reply to Re: IYHO, what do you consider good code?
in thread IYHO, what do you consider good code?

Yes, but with proper naming conventions, most of this comment is redundant.

If your subroutine were something like this:

sub get_build_from_server { my ($server_name,$password,$path_to_build) = @_; # do stuff here my $success = parse_build_name($path_to_build); if ($success) {return 0;} else { return 1; } }

--
Regards,
Helgi Briem
helgi DOT briem AT decode DOT is


Comment on Re: Re: IYHO, what do you consider good code?
Download Code
Re: Re: Re: IYHO, what do you consider good code?
by logan (Curate) on Jun 13, 2003 at 16:31 UTC
    Sure, for a simple sub like the one I used as an example. But that's like saying we wouldn't need a big table of contents if only people wouldn't write long books or if people wrote clearly we wouldn't need synopsis or abstracts. Sure, it probably isn't necessary to have a 6 line header for a 6 line sub, but if the sub runs to 20-30 lines, I'd rather have the header.

    The idea is that I'm trying to make it easy to follow program flow. Two years later I want to be able to look at it and instantly see what it does and how it should be called.

    -Logan
    "What do I want? I'm an American. I want more."

      if the sub runs to 20-30 lines, I'd rather have the header

      Obviously if it works for you...

      However, if it were me and the sub ran to 20-30 lines that I couldn't understand without half a dozen lines of comments I'd refactor it into a larger number of smaller subs - each of which I could understand without half a dozen lines of comments.

      I doing code maintenance I tend to ignore comments, since I find that they're out-of-sync with the code half of the time.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://265641]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2014-04-23 23:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (556 votes), past polls