Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Avoiding silly programming mistakes

by JavaFan (Canon)
on Aug 20, 2008 at 09:56 UTC ( [id://705463]=note: print w/replies, xml ) Need Help??


in reply to Avoiding silly programming mistakes

I've been coding for over 30 years, and I'm still making "doh" mistakes. I keep misspelling Fcntl. I keep putting a comma after the filehandle in a print statement. I keep forgetting to put Exporter in @ISA, and then I wonder why my subs aren't exported. Oh, and the number of times I left of '1;' (or another true value) at the end of a module.

And then I write some C, and I keep forgetting parenthesis around function arguments. Or forget that my variables need to be declared upon entering a scope. And that they don't need sigils, but may need casting. And when my job still required me to use Pascal, I tried using /* */ comments in Pascal, and (* *) comments in C. Worse is trying to use // comments in C, as some compilers accept it, and others don't.

And when (interactively) querying a database, the client has to remind me over and over again that 'cd' and 'ls' aren't valid commands.

Retirement or death, which ever comes first, will be the moment I stop making "doh" mistakes.

  • Comment on Re: Avoiding silly programming mistakes

Replies are listed 'Best First'.
Re^2: Avoiding silly programming mistakes
by rir (Vicar) on Aug 20, 2008 at 13:57 UTC
    Using a boilerplate to start a module will help with your problems with exportation and ultimate truth.

    The trick to using such templates is to make them congenial; make your own. Avoid building a template which is more comprehensive than you will be willing to alter.

    Here is what I'm currently using, minus pod.

    package XXX_name; use 5.008004; use strict; use warnings; require Exporter; our $VERSION = '0.01'; use Carp; use vars ( 'XXX_exported', '@EXPORT' ); ## no critic use base qw/ Exporter /; @EXPORT = qw/ XXX_exported /; XXX_code_here 1;
    Be well,
    rir
Re^2: Avoiding silly programming mistakes
by GrandFather (Saint) on Aug 20, 2008 at 10:11 UTC

    Golly! At least 2/3 of those errors are caught by using strictures or a decent syntax highlighting editor!


    Perl reduces RSI - it saves typing
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^2: Avoiding silly programming mistakes
by moritz (Cardinal) on Aug 20, 2008 at 10:12 UTC
    I keep forgetting to put Exporter in @ISA

    I don't really like to inherit from another module just to use one or two subs. Instead I write use Exporter qw(import);.

    And when (interactively) querying a database, the client has to remind me over and over again that 'cd' and 'ls' aren't valid commands.

    This happens to me all the time as well. When I use the mysql prompt and enter ls<return> I see my mistake, and then press Ctrl+C to abort the command. But of course Ctrl+C actually exists the client...

      When I use the mysql prompt and enter ls<return> I see my mistake, and then press Ctrl+C to abort the command. But of course Ctrl+C actually exists the client...

      I'd estimate I make the ctrl-c in mysql about twice a week. Of course, the only reason it's not once a day anymore is because I'm doing less database work.

      At this point, it's been years since I used Oracle, but I have problem overriding my old habits.

      Oh -- and as of mysql 5.1.10 -- ctrl-C aborts the running query, rather than dumping immediately. (still doesn't fix the problem when you're used to sqlplus and are just trying to clear the command, though).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-16 17:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found