I have found a mistake on someone's code published online: what is the protocol?

Now that I have found the problem what is the protocol for highlighting this, is emailing the author necessary?

It isn't necessary, but it is the right thing to do, if you don't, you're responsible for causing others set backs that will waste them a considerable amount of time.


An important point of etiquette that has been skipped in the other answers:

Treat it as a suspected bug, and do not assume "I'm right, you're wrong" while presenting your fix.

  • No matter how confident you are on the matter, there is always room for having misinterpreted or overlooked something important.

Consider the case of finding an 'error' in code of:

(A + B)

And you decide that all of your use cases need this to be:

ABS(A + B)

Your use cases may not include a need for that possible negative to exist, or even be able to handle it when it does, but that does not mean cases outside of your consideration may not require them.

  • Start off with the assumption that the original coders know more about the code than you do. [They might not actually, but opinions of others can always be re-evaluated...]
  • Approach it as having a goal of mutually gaining a better understanding of what the code is doing, and what it should be doing, and how it is actually being used.
  • Consider phrasing any suggestions for changes/improvements as questions rather than commands. ["Do you see any flaws in my attempt at fixing my problem?" vs "You should use my code instead."]

You have 3 possibilities:

  1. Contact the author as per the other answer. Best option based on the subsequent comments revealing that the source was a personal website.

If the code was published in an article or paper then the following may be applicable:

  1. Contact the editor.

  2. Publish a paper showing your work to improve the usefulness of the code.

The third depends on the type of error and how it was corrected - if it meant changing a 3 to 5 then that is trivial, but if it meant re-coding a significant portion with an extra process then it may well be a suitable option.

You have to tell somehow though.

Tags:

Code

Etiquette