Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Re: best practice

by George_Sherston (Vicar)
on Aug 27, 2001 at 18:38 UTC ( #108135=note: print w/replies, xml ) Need Help??

in reply to Re: best practice
in thread best practice

If you've got one handy I'd be very interested to see an example of a rough draft (perhaps versus a finished script) to get an idea of how much detail you get into at that stage.

George Sherston

Replies are listed 'Best First'.
Re: Re: Re: best practice
by dragonchild (Archbishop) on Aug 27, 2001 at 18:49 UTC
    A rough draft would contain a lot of the following type of lines:
    #GGG Add error-checking here. #GGG When in production, this line changes to $foo=2;
    'GGG' is just a character string that allows me to search for it and find all my to-do notes.

    Also, a rough draft doesn't have good comments. It doesn't have a lot of error-checking (though you should build it in as you go.) It probably also isn't factored very well.

    What a rough draft does have is good variable names. Changing variable names in mid-stream is a pain in the ass. Get your names right. If you can't name a variable neatly and succinctly, that's a clue that you don't understand what you're doing.

    (The above paragraph goes doubly for function names.)

    /me wants to be the brightest bulb in the chandelier!

    Vote paco for President!

      Well, if that was what I meant by a rough draft, I wouldn't be recommending it as an alternative to pseudocode, but rather as an addition.
      Snazzy tagline here
Re: Re: Re: best practice
by Aighearach on Aug 27, 2001 at 22:17 UTC
    When I said "throw one away," I really meant it. :) I don't have any because I invariably delete them. In fact, I don't even bother putting them into cvs.

    The idea isn't that I'm cutting corners on the rough draft. The idea is, rather, that in a language like Perl where there are many ways to approach a problem, you don't know what the best approach is until you've mucked about in the problem domain a bit. That's the problem with pseudocode; your pseudocode has to contain a high level algorithm, but you often don't know yet which algorithm to use. So my first draft might be procederal. My next draft might be OO. I might switch to a recursive algorithm, or decide to use Tie::RefHash to move all my filehandles into hash keys, storing related data or objects in the value. Usually, I don't know this until I've written some code.

    I can't imagine the pseudocode for procedural and OO approaches being the same; if it's that high level, it's mostly useless anyways.

    And if your first algorithm guess is always correct... well, only mortals would need pseudocode anyway.
    Snazzy tagline here

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://108135]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2017-02-26 17:43 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (376 votes). Check out past polls.