in reply to IYHO, what do you consider good code?
Frequently, I have to revisit code I wrote a year or more ago, and figure out what it does and why it isn't doing it anymore. Ergo, I'm comment guy. Each subroutine I write has a profile at the top something like this:
#--- # sub get_build_from_server # Takes: server_name, password, path_to_build # Returns: 0 for pass, 1 for fail # Called by: main # Calls: &parse_build_name #---
The essential concept is to insure that I won't have to spend a lot of time figuring out what a sub does. If I do something "clever", I put in comments explaining why. A few times, I've gone so far as to include the chapter in The Camel Book/Perl Cookbook where the concept was discussed. Also, if the main chunk of code is a loop, it helps to list the exit condition at the top.
You might also find the Perl Programming guidelines/rules thread instructive.
-Logan
"What do I want? I'm an American. I want more."
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: IYHO, what do you consider good code?
by helgi (Hermit) on Jun 13, 2003 at 11:02 UTC | |
by logan (Curate) on Jun 13, 2003 at 16:31 UTC | |
by adrianh (Chancellor) on Jun 15, 2003 at 00:08 UTC | |
Re: Re: IYHO, what do you consider good code?
by DrHyde (Prior) on Jun 13, 2003 at 11:13 UTC | |
Re: Re: IYHO, what do you consider good code?
by dopey (Sexton) on Jun 13, 2003 at 15:16 UTC |