Hot answers tagged

175

What distinguishes Code Review from Stack Overflow? Different communities have different rules to address different needs. A quick summary: $$ \begin{array}{l|l} \textrm{Code Review} & \textrm{Stack Overflow} \\ \hline \text{Open-ended questions} & \text{Questions with a specific goal} \\ \text{Answers can suggest any improvement} & \text{Must ...


140

You have several options for follow-ups: Accepting an answer If one of the answers gives you good advice with clear directions for improving your code, just accept the best answer and upvote any other answers you feel were helpful. The checkmark that you confer is the best way to show appreciation on this site, as it gives 15 reputation points and raises ...


62

Perhaps something like this could help situate CR in StackLand:


55

When you ask your question Your question is (should be) presented in 4 basic parts. The Title, Tags, Text, and Code. I suggest that you build your question up in that order too. Title Use a title that is catchy, and describes the problem your code solves. A question with the title "New programmer looking for advice" is both 'obvious' and meaningless. How ...


48

No. We require the code to be contained within the question, for the following reasons: To avoid dependency on third-party hosting services. These links tend to go away after a while. To prevent review requests of huge projects. To make it easier to see the code and so it can interest more reviewers and get more reviews. To avoid confusion when the OP ...


48

How to NOT write a zombie. A zombie is a question that remains unanswered. As a question asker, your goal is to avoid writing one. Beyond meeting the on-topic requirements, I think "good CR questions" can be broken down into several question types. This answer is longer than I would have liked, but there are pictures. The Minimalist These questions show ...


45

I think that such question should clearly state that it is a follow-up question to a previously asked question. A good follow-up question should include, in my opinion: Which question it is a follow-up to What changes has been made in the code since last question Why a new review is being asked for If a question does not include (at least some of) these ...


43

Before you ask your question... Understand the community Code Review is a collection of users with different experience levels in different technologies. These users each have different time commitments and availability. Understand that you are requesting a review, and you cannot demand one. Code Review is not just a 'service' to be used for free. It is a ...


38

No Personally, I think that they should usually NOT be allowed for questions. This site is about code reviews. Readability is an important issue in code reviews, as are syntax errors. Editing the post is not constructive. It is much more helpful to leave a comment or answer that points out the shortcomings. If the code in the question is edited, other ...


37

Note Accumulating multiple discussions about why the 'own code only' restriction is in place on Code Review There are multiple reasons why Code Review has the restriction that the code has to be your own code. Moral / Polite The purpose of a code review is to provide constructive criticism. Criticism can only be constructive if given to the person who is ...


36

After you ask your question So you have asked a question, how do you ensure it succeeds? Note: there are two sets of rules for editing your question - one set applies before there are answers to your question, and the other set applies when it has already been answered. Feel free to edit all parts of your question before answers are given, but read up on ...


34

Simon's Guide for posting a good question There are a lot of questions that appear on Code Review, and all questions are fighting for reviewer attention. This is a non-exhaustive list of items that I am looking for in a Code Review question when determining whether or not I should review it and how I should vote on it. If your question is lacking a lot of ...


31

When things go awry What happens when you don't get answers, or get answers that are helpful, but don't address your main concerns? First, be patient. Code Review normally has a few hours at least before you can expect your question to be 'cold'. If your question is still on the 'front page' then you should probably avoid complaining or pestering people. ...


30

I agree with seand, but I'd also point another facet. Why doesn't the poster edit their question to put the code in? They don't want their code in that question, (seand's case) in that case we shouldn't override their wishes. They never came back to look at the question, and so don't see the comments telling them to edit their code into the question. In ...


29

What items appear in this queue? Overview: What are the Review Queues? History: New Review Queue: First Posts Help: Review privilege The first question a user asks, and the first answer a user provides, will be automatically added to this queue. First posts may also be added to the 'late answer' queue (if the question was asked a long time ago). What is ...


29

If your question contains broken code… If your question contains something like: ... runs ...but it gives the wrong answer... ...I tried ... but sometimes... ...works great when I do ..., but when I do ... ...it works fine, but I also need it to do ... ...it fails a test case... (**unless that test case is a performance test) then your code does not work ...


27

Proof by [extreme] example. (based on a true story) Not too long ago, someone posted one of their employees' code and asked for it to be reviewed by the community. The OP wrote that based on the feedback we would give him, that he would decide whether to keep or to fire that employee. Would you write the same review if you knew that what you write can ...


27

Hypothetical code makes poor Code Review questions, which produce poor answers. For example, here is a code excerpt that made a poor Code Review question: bool f(const string& key, const string& value) { // some codes for input check exec_cmd("cmd %s %s", key.c_str(), value.c_str()); // some codes for making return value } bool f(const ...


27

If your question is not real code… Unlike other Stack Exchange sites, which encourage general reference questions and offer broadly applicable answers, Code Review aims to offer customized advice specific to your code. To make that work, we need to see real code. If your question was asking for a review of pseudocode, then we need you to post an ...


26

No. Because there's a reason we require your code to be embedded in the question:


25

There are all kinds of problems that can be pointed out in a code review. Good answers point out Genuine bugs Security holes Misconceptions Inefficiencies in the algorithm Inefficiencies in expression Poor use of data structures Violations of accepted programming practices Advice to understand the challenge to be solved Ways to enhance the clarity of the ...


24

Checklist for migration to Code Review Is the question off-topic on the originating site? Are you sure? Do not migrate if there is doubt. Is the question on-topic for Code Review? The question must contain working code. Code Review is not a debugging service. Reviewers may discover bugs in the course of answering, but the code should be generally ...


23

After editing many posts over time, I've come up with my own checklist for formatting posts: (I'll edit this as more things come to mind) Code Any code must be indented (manually, CTRL+K, or the {} button in the editor), not formatted with <code>/<pre>. These tags often leave extra whitespace, and if used incorrectly, hides syntax-...


23

Although it may seem daunting to start talking in an unfamiliar room or site, The 2nd Monitor is a great room, and the friendly regulars will help you to feel right at home. Some questions you may have: How do I ask questions or get help with a post on the site using chat? What topics are appropriate for chat? In The 2nd Monitor, site business always ...


22

If your question does not include the code to be reviewed… Please embed the code to be reviewed directly in the question, for multiple reasons, including quality and licensing. You may optionally also link to a third-party site where your programming project is hosted, but the question must contain enough code to stand on its own. There is a length limit ...


22

If your question contains someone else's code… For moral, practical, and legal reasons, we are only able to review code that you wrote or code that you maintain. Code Review is not the place to ask about someone else's code. We also expect you to understand how your code works. If you are seeking an explanation of how your code works, then we will treat ...


20

Good code doesn't mean nothing can come out of a peer review. Reviewing code doesn't always mean shred the OP's code to pieces, and propose better ways to do the same thing. It could just as well point out why every right decision was the right decision to make. I don't have an example at hand, but if Eric Lippert were to post some piece of the C# compiler ...


20

Stack Exchange chat rooms are an informal discussion area that have few rules in general, and some 'rooms' have room-specific requirements as well. In general (from the FAQ): This site is an extension of The Stack Exchange Network, so discussion should more or less revolve around the same topics you'd find at The Stack Exchange Network — but in an ...


20

If your question is asking for advice about code not yet written… If you have not yet written your program, or if you are wondering how to add functionality to your code, then Code Review is unfortunately not the place to ask for help. We would be glad to have you ask another Code Review question later, after you complete your program. Now you might be ...


19

I think that there is also a legal reason for this: whenever you post something to a Stack Exchange site, you release it under the CC-BY-SA license. If the author doesn't post the code here, but to some other site, then they most likely didn't release it under that license. And you as someone who didn't write that code have no right to do that.


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