11
\$\begingroup\$

A question was just posted: Set desktop background. One of the lines in the posted code looks like this:

string json = webClient.DownloadString("super secret website url");

Clearly, in the actual source code, this is a URL and not an example string.

Does this count as example/filler/stub code?

On the one hand, I couldn't copy & paste this code into my IDE and run it and in this particular case, I might not be capable of finding a URL that would serve up the correct data format that the application is expecting.

On the other hand, I can find good reason why a user might not want to be giving away a link to his website for various reasons. It's not necessarily drastically different from not wanting to post your email address (which we'd edit out anyway). Moreover, the content at the URL could very easily be NSFW stuff that we'd want to remove from Code Review anyway.

Should we expect the user to provide some sort of URL that will allow the code to work, or is it fine is URLs to personal websites are redacted from the code wishing to be reviewed?

\$\endgroup\$
  • \$\begingroup\$ Example code?? Really? At best it's broken, but even that is a stretch. I'd say it's pretty common and fair to "dummy" this kind of thing. \$\endgroup\$ – RubberDuck Aug 21 '14 at 23:45
  • 3
    \$\begingroup\$ It's normally to substitute a URL, but general you can provide a URL other than your own private URL and it will still work for the code. In this case, the URL was to download some sort of JSON. But the reason I say "example code" is because to me, this is about the same as having // do stuff in place of actual code in a method. \$\endgroup\$ – nhgrif Aug 22 '14 at 0:52
  • \$\begingroup\$ I don't understand the downvote on this question. I think it's a discussion worth having. The question itself expresses no favor for one side or the other. The question I linked to has no downvotes or close votes (so clearly, despite my bringing this question, I took no action on the question I linked to). Why the downvote? \$\endgroup\$ – nhgrif Aug 22 '14 at 0:54
  • \$\begingroup\$ @nhgrif: On Meta.SO at least, votes work differently; they're often used to express agreement or disagreement rather than "this question sucks" or the like. I assume it's a similar story on the other meta sites. \$\endgroup\$ – cHao Sep 3 '14 at 12:55
  • \$\begingroup\$ @cHao How can you agree or disagree with a question that doesn't take a side? I don't know what side the down voter disagrees with. \$\endgroup\$ – nhgrif Sep 3 '14 at 14:15
  • \$\begingroup\$ @nhgrif: I'd assume it's a "no" to the question in the title. Or maybe the OP just isn't happy about having their super secret URL posted for all the world to see. :) Who really cares, though. It's Meta; votes aren't exactly srs bzns anyway. \$\endgroup\$ – cHao Sep 3 '14 at 18:27
19
\$\begingroup\$

Censoring private URLs, usernames, and passwords is completely reasonable, and in no way makes this question example code. The exact URL has no bearing on correctness, readability, efficiency, or the many other issues we would want to address in an answer.

You might want to suggest that the URL should be defined in a string constant, or maybe stored in a configuration file, but even that wouldn't require you to know the exact URL.

If necessary for clarification, you could ask for a sample of the JSON that would be returned from that URL. Other than that small withheld information, the rest of the code in the question is claimed to be in working order, and therefore the question is on-topic.

\$\endgroup\$
6
\$\begingroup\$

I can see both of your concerns. In a way I feel by doing this the asker robs himself of good aspects of CR that could only be tested by compiling/executing the code, such as performance issues.

I think it is one thing to remove potentially private data like passwords, server IP and such that could compromise security, and definitely NSFW stuff should not be present. I would hesitate to VTC as example code though, personally.

I commented on the question, since it was just posted, and the asked provided updated code.

\$\endgroup\$
4
\$\begingroup\$

I agree with others that censoring the domain name of the server or things like that are okay.

But I also think this doesn't mean it's okay to always censor the whole URL, since URLs can contain reviewable stuff too. (For example, if it's some publicly known API, you could point out the use of a deprecated parameter, or more efficient way to get the same information.)

So, my guidance it this: if it's some private API, that we couldn't review anyway, feel free to censor the whole URL. But if it's a publicly known API (even if the site itself is private), you can censor the domain name (e.g. by using example.com), but you should leave the rest of the URL be.

\$\endgroup\$

You must log in to answer this question.

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