Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: RFC: Perl Second-Best Practices

by markjugg (Curate)
on Dec 18, 2005 at 20:24 UTC ( [id://517615]=note: print w/replies, xml ) Need Help??


in reply to RFC: Perl Second-Best Practices

I will hardcode a magic number in the code and mark it with an comment next to it like "# XXX should be in config file".

I do it because I want to stay in the flow of programming and feel it will be easy to return later for the brain dead task of moving the number out to a config file instead.

If I knew the number would need to appear multiple times throughout a code base, I'd probably go ahead and add it to a config file immediately.

As part of my refinement process, I'll grep the code for XXX comments to see if anything has been flagged for later attention.

Replies are listed 'Best First'.
Re^2: RFC: Perl Second-Best Practices
by merlyn (Sage) on Dec 18, 2005 at 20:39 UTC
    Ohh, that brings back (bad) memories.

    In $CPAN/src/unsupported/4.036/perl-4.036.tar.gz, you'll find a file named lib/chat2.pl, which contains:

    unless (socket(S, 2, 1, 6)) { # XXX hardwired $AF_SOCKET, $SOCK_STREAM, 'tcp' # but who the heck would change these anyway? (:-)
    Yes, these were the correct constants on BSD, but they were wrong for SysV, which meant that every SysV user sent me bug reports about why chat2 didn't work for them. {sigh}

    Thankfully, that file was "retired" as of Perl5, being replaced by the Expect module.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Finally easily accessible as... http://chat2.pl! Yes, I bought the domain just for the joke!

      -- Randal L. Schwartz, Perl hacker

      The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

        I’m proud of you. I owned or own at least six joke name domains. :P

Re: RFC: Perl Second-Best Practices
by jonadab (Parson) on Dec 19, 2005 at 14:37 UTC

    Yeah, I do that. I use TODO instead of XXX as the comment flag, but it amounts to the same thing. I've also been known on many occasions, despite whatever shred of sanity I may possess, to hardcode filepaths (although, I usually at least put them in a lexical variable at the top of the file). The thing is, I know better. I know that most of my Perl code eventually ends up running on at least both *nix and Win32, but I continually leave myself this cleanup to do the first time I have to run any given program on the other system.

    At least I've finally just about got myself trained to use File::Spec::Functions::catfile instead of hardcoding the directory separator.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-29 09:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found