9
\$\begingroup\$

Can I ask about open source code if I want to understand why a line of code is present when seemingly it does not affect the program behaviour, but there are good chances that it's there for a reason?

I read this meta question and answers. I'm not the author or maintainer but want to port the code in question to another language. Should I try to directly contact the author(s)? It seems a better choice to get hints from a community like this.

\$\endgroup\$
  • 5
    \$\begingroup\$ If you don't own or maintain the code, or if you're asking for explanation of someone else's code, your post is off-topic, as stated in our help center. Your own translated version would be fine to post for peer review though. \$\endgroup\$ – Mathieu Guindon Mar 20 '16 at 20:42
  • \$\begingroup\$ Thanks for the comment @Mat'sMug. Well, that seems quite weird. So I port the code and then I ask why did I put that line in there when it seems to be doing nothing? \$\endgroup\$ – marekful Mar 20 '16 at 20:46
  • \$\begingroup\$ You should contact the project owners to get an answer about that specific line of code. Reviewers here will likely not have the full context. I'd create an issue on their github repo. If the project is alive, you'll get an answer. \$\endgroup\$ – Mathieu Guindon Mar 20 '16 at 22:01
  • \$\begingroup\$ OK, that's fair enough, thanks. \$\endgroup\$ – marekful Mar 20 '16 at 22:10
21
\$\begingroup\$

In a code review, the person doing the code review is the one who should be asking the questions, like: "Why did you put that line of code in there? What does it do?"

It's back to front to ask: "Hey, I would like you to review my code, but I have no idea why I have this line of code, why did I put it in there?"

A code review reviews whether your code implements the specifications/goals well, and what can be improved. It is the person asking for the review who is responsible for describing the goals/specifications to the reviewer.

It is for this reason that one of the requirements here on Code Review is that you can only ask for code reviews on code you wrote, or actively maintain. If you can't tell us why you have done things in a certain way, then there's not much point in speculating about it.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .