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

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

by DrHyde (Prior)
on Jun 20, 2003 at 09:00 UTC ( #267491=note: print w/ replies, xml ) Need Help??


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

There are only three numbers in Computer Science. Zero, One and N

Someone suggested on the london.pm mailing list some time ago that if you ever use a constant other than 0 or 1 you should comment why. I can see his point, although I make exceptions for well-known scaling factors like 7, 24, 60, 3600 and 86400 when mangling times and so on. I also don't bother documenting the constants when I do something like:

$foo = ($foo & 112) >> 4;
although that gets wrapped up in a little subroutine whose function is documented, including a pointer to the relevant standard. But just about every other constant I do inded comment. eg, from my current project ...
$price /= 100; # convert from pence to pounds ... $time += 23 * 3600 # because we're changing timezone


Comment on Re: Re: Re: IYHO, what do you consider good code?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2015-07-06 19:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (81 votes), past polls