46

Code is not malicious (guns don't kill). It is the way that code is used that makes things a problem. I am certain that every piece of 'malicious' code has an 'angelic' corollary. If code can be 'malicious' then computers are 'malicious', and operating systems are 'malicious', and networks are 'malicious', etc. If I feel that the code in a particular ...


34

Yes, modern suggestions should be allowed on old questions. Initial authorship of code is only part of the software lifecycle. It is quite possible that code that was posted to Code Review years ago is still alive today, and the author might even be interested in maintaining it up to modern standards. Times change, and unmaintained code can "rot". For ...


26

There are times when it is obvious that people (new folk?) don't know how the markdown works on Stack Exchange. They take their block of code and paste it in to the edit box (and indent nothing): import java.util.Scanner; public class MyClass { public static void main(String[] args) { ///do something here } } Some of those people fix their ...


24

I wasn't one of the downvoters, so I can only speculate. However, it is site policy to include textual summaries of programming challenges. This policy was actually instated when Project Euler went offline for some time. So, the first thing you can do is include descriptions of the problem that you're trying to solve. The next thing you could do is take ...


23

"There are no wrong questions." Actually, I believe the phrase is that there are no bad questions, but the thing is, I have to disagree — at least in the context of a question and answer site. The phrase "There are no bad questions" is meant to encourage one who does not know to ask rather than to continue on in ignorance. But the phrase also doesn't mean ...


21

I have my 'pet theory' about Code Review. This is my personal theory, and it is about human psychology, so you will have to take it with some salt..... It goes like this: You post code for review, and... noone knows how good you are as a programmer they do one of two things: find the most glaring problems in your code, and identify what they think will ...


21

For the record, the linked question asks: Is there any better way to do this? I believe that is the question we all want the answer to when posting code here, more or less. Is a question that asks for a complete rewrite of a piece of code is acceptable in Code Review.SE? It depends on how it is asked. If you ask "Can someone please rewrite this code ...


20

In my opinion, programs that run out of memory with large inputs are in the spirit of Code Review (assuming that everything else about the question is OK). Performance and scalability are among the key concerns we frequently address. I don't see running out of memory as much different from time-limit-exceeded — they are related problems in the space-time ...


20

No. We shouldn't nuke it. Not only is it a piece of CR folklore at this point, but it's an on topic question. Just wondering if there was someone out there that could offer help in optimizing my script. The code may be obfuscated by OP's inane comments, but it is in fact, real working code and the question implies that OP is interested in improving the ...


19

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 ...


19

Stack Exchange in general has an English-Only policy. There are some exceptions for language-specific sites (like Stack Overflow in Portuguese). Code Review is not an 'exception' site. It is clear that there are benefits and drawbacks to having an English-only policy, but the Stack Exchange 'powers-that-be' have determined that, on balance, the English-only ...


19

No, we shouldn't encourage this. Broken code is broken code, and we're not Stack Overflow. I left this comment on the answer: Please note, questions involving code that's not working as intended, are off-topic on this site. If OP edits their post to address the problem and make their post on-topic, they make your answer moot. Protip: There are tons of on-...


18

OP doesn't seem to know their code is broken. Perhaps due to insufficient testing, but to the best of their knowledge, the code works and produces the expected output. The "spirit" of the "working code" rule isn't to forbid code with bugs - in fact part of the peer review exercise is to highlight unforeseen edge cases and other issues - it's very possible ...


17

According to What topics I can ask about here?: Simply ask yourself the following questions. To be on-topic the answer must be yes to all questions: Does my question contain code? (Please include the code in the question, not a link to it) Did I write that code? Is it actual code from a project rather than pseudo-code or example code? Do I ...


17

From the close queue I can see that three people voted to close and three voted to leave open, meaning that the question is gone from the close queue. Even though it has four close votes, I consider it on-topic. Here's why: Your question contains code You wrote that code It looks like actual code from a project rather than pseudo-code or example code You ...


17

What is code but instructions to a compiler? Would we allow an obscure language that no one here has a compiler to? I would hope the answer is yes. You might not be able to answer it but another person might. I can currently think of more than one example that we would accept but requires an extension/plugin. less-css is one that I personally use. It ...


17

I don't see anything wrong with posted answers with new technology on old posts. Times change and what would have been good advice 2 or 3 years ago might not be the best advice to give today. It is also reasonable to assume that OP just might still be maintaining the code and should be alerted to new alternatives. I think we should be careful about two ...


17

So questions must compile and work, in order to be considered on-topic questions. No. The code must compile and work in author's environment, so that OP isn't asking the CR community to fix their code, which would be Stack Overflow territory. But the code in the question itself doesn't need to compile straight out of the "ask question" box. Of course, if ...


17

The cited reason for the closure is not that it was someone else's code, but that the code looked hypothetical. Normally, function names like foo, bar, or functionA are indicators that the code is hypothetical. Also, comments like // Do something are stub code. Questions containing such vague code are generally unreviewable, since there is too much left ...


17

I personally believe security questions can be answered in such a way. That's because one of the main rules in security is "Don't roll your own". Examples: Generating XKCD passwords Password hashing and matching To answer your questions: How well received would suggestions be to use another language, in this case PowerShell? Don't. However, in this ...


17

The algorithm that makes a question hit the Hot Network Questions (HNQ) list isn't public AFAIK, but it definitely involves views, votes, answers, and a time factor is documented here. Your question is indeed a very well-formed CR question: it includes working code, a description of its purpose, a link to the GitHub repository, ...and a somewhat punny title....


16

I agree with @JamesKhoury. The GNU GPL defines "source code" as "the preferred form of the work for making modifications to it". For the author of the question, that means the version of the code with the meta-programming annotations. It does not make sense to review the post-processed form of the code, because we would then be critiquing auto-generated ...


16

Actually, it's not even asking for a review in my opinion. It seems to be directly asking for an alternative, which makes me think that it's SO territory. It is actually asking for "Is there any better way to do this?" which to my eyes is nowhere near "gimme-the-codez". Let's take a look at our ultimate questions: Does my question contain embedded code? ...


16

Your question, as originally written, was marginal for Code Review. As of Rev 6, it is now a fine question. The problems were: Your question had a generic title that did not meet the guidelines in How to Ask a good question. You also dumped a bunch of code in the question without explaining what the code is supposed to accomplish. As a result, the code ...


15

I was not a part of this, so this answer is based only on what the OP has shown us. I am afraid that I may catch a lot of flak for this post, but here is how I see things. Part 1: Embedding Code Let's go from the beginning: @RavenHursT broke our rules for not posting the code here. @rolfl posted a polite response clarifying our rules. @RavenHursT posted ...


15

The code that you want to have reviewed should be included. There are several questions on Code Review containing a whole lot of code, I myself tend to have very much code in my questions, and it's OK to have a lot of code in your question. The only limit is the limit built into the StackExchange system, 65k characters per post. (Be aware though that having ...


15

Fixing non-obvious bugs is part of code review. What this means is that if the OP ran their code and it seemed to work, then such question is on-topic and shouldn't be closed. If you find a bug in the code, post it in your answer along with other things you want to mention. (But don't forget that you don't have to review everything.) One problem with this ...


15

Code Reviews are all opinionated yes, even math is opinionated (occasionally, and for some values of math). Now, if you are seeking a code review, then your question is not opinionted as per the scope of Code Review. But, if your question basically starts with: Imagine you have a class with dozens of the follow lines of code and that you should localize ...


15

I've rejected the migration because the presented code appeared to be example code. Indications of this include: class SomeClass "I simplified some stuff so that I could make a short code example" If you see something like that, then it's very likely that the question is off-topic. It seems to be common for others to think that a question always belongs ...


15

No, there should not be. A question can only be put on hold by three means: Five users with 3,000 reputation or more (500 on beta sites) have cast a close vote. A user with a gold badge in one of the question's tags has marked the quesiton as a duplicate. A site moderator has put the question on hold. The evidence that the question should be on hold lies ...


Only top voted, non community-wiki answers of a minimum length are eligible