Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Update code snippets?

by bronto (Priest)
on Mar 03, 2003 at 17:17 UTC ( #240079=monkdiscuss: print w/replies, xml ) Need Help??

Preface: I did a fast research with the words snippet update, and didn't find any useful title. If this has already been asked just point me to the right node, thanks.

Dear Monks
Days ago I posted a code snippet for which I received some advice by merlyn, Abigail-II and zentara (thanks guys).

I'd like to update it a little (a couple of lines or so) to make it work a bit better, but I fear that doing so I'd change the context under their comments, making them meaningless.

So, what's one supposed to do in this case? Updating the snippet anyway, putting in a warning? Write the corrected snippet in a reply to the first version? Write a brand new snippet?

Thanks for any advice
--bronto


The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
--John M. Dlugosz

Replies are listed 'Best First'.
Re: Update code snippets?
by larsen (Parson) on Mar 03, 2003 at 17:40 UTC
    I'd post new code as a reply. I'd leave the original node unchanged, to keep a meaningful context for the replies. Only an update at the top of the node, pointing to the new version of the script.
Re: Update code snippets?
by valdez (Monsignor) on Mar 03, 2003 at 18:53 UTC

    I've seen in the past nodes modified to reflect suggestions made in answers, so I don't see why you should not update your code snippet. The reason of a code snippet is to provide something useful, not asking a question like in SoPW.

    Btw, isn't it strange to see three italian monks talking in english? :))

    Ciao, Valerio

      Make it four ;)

      If possible and if the change is limited to a few lines I would comment out the old version with a little note explaining what changed and why. This way you would have the new code but keep track of the reason for previous comments. Anyway, I also second larsen's and valdez's hints.

      Cheers

      Antonio

      The stupider the astronaut, the easier it is to win the trip to Vega - A. Tucket

      un po' strano, davvero? And I'm not even Italian.

      It looks like the best way to do it is to add a little note at the bottom saying "Update: fixed code as suggested by ...". Then you can add comments to show what was there before.

      --
      Allolex

Re: Update code snippets?
by bronto (Priest) on Mar 04, 2003 at 15:34 UTC

    Thanks guys. Since I added two-lines-two of code, I preferred valdez's and abell's solution: the code is now updated with a couple of comment lines above the added code, saying that the code is changed and why.

    Thanks for your suggestions

    Ciao!
    --bronto


    The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
    --John M. Dlugosz
Re: Update code snippets?
by Aristotle (Chancellor) on Mar 09, 2003 at 04:30 UTC
    For extensive changes, I update the top of my node with something like
    Update: this version is <foo> because of <bar>, but left intact here for posterity. Please do see Re: baz if you intend to use it.

    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2020-01-23 19:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?