Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Hot answers tagged

176

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


30

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


29

This seems to be about the right place to post a response to what happened in the chat room today, and in the past 6 weeks or so. Since various names have come up, and people have posted here too, I won't make it all anonymous, but will use concrete examples instead. I also want to stress that this is my perception of things, mine, personally, so if you ...


29

If the code produces wrong answers for some test cases, then the author is aware that the code is not working correctly as intended, and the question is thus prima facie off-topic for Code Review. There may be room for certain exceptions, though: If it's failing due to time limits rather than correctness, then that is an issue of scalability, which is OK. ...


28

I had the impression that the line is if the code works or not code does not work (i.e. has bugs or does not compile) -> SO code does not exist (i.e. not sure where to begin) -> Programmers code does work (but may not be the best) -> CR now there may be a grey line between "working code" and "semi-working buggy code", but I think that's a different line ...


28

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


28

Based on the guidelines in the Help Center, questions asking to review license text would be off-topic, as it's not code. If you have a specific question about a legal principle related to licensing, you could ask on Open Source (assuming that it's related to open-source software) or Law. Note, however, that no Stack Exchange site will give you ...


23

No. Our focus is to improve working code. By definition, pseudo-code is not working code. The restriction is (partially) to make sure you've put effort in your code before showing it to us. Pseudocode doesn't demonstrate that. The only thing that we could possibly review about pseudo-code is the algorithm. But that would be Algorithm Review, not Code ...


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


23

The line between real and hypothetical code is sometimes blurry, but I would consider this code sample to be on the wrong side of the line for Code Review. Code that contains Foo or Bar identifiers is generally an indicator that you are withholding something from us. We would have to speculate as to what you really mean, which makes reviewing this code ...


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


22

No. Code Review is for the review of "code" in the sense of interpreted or compiled programming languages. Not for any other sort of "code" such as "legal code".


21

Ideal situation - asker Code Review is where you go to get feedback on your code that teaches you at least one new way to do things (better). Premise: you bring your code - and you have it in a state where it represents the best you can do. Expectation: someone helps you see things differently, that you would not otherwise have seen. Ideal situation - ...


21

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


20

There is one school of thought that says "the code is the design". The reason is that the completed system often bears little or no resemblance to the "design". So I would say that if the question contains code, and the asker wants the design of that code reviewed, there's absolutely nothing wrong with that, but if the asker wants something that is not code ...


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


20

If you have code that implements real functionality, and it's your code, and it works, then the code is on-topic for review, regardless of what the purpose of the code is, with some exceptions: the code you want reviewed has to be included in the question itself (links to supporting code on off-site systems like github are OK for background use only - code ...


20

Is it on-topic to review a challenge's requirements? To the extent that the requirements force bad code, Yes. The core of every question at Code Review is "How can I make this code better?" It is not "How can I solve this challenge?" If the asker has not gotten at least that far already, their question is off-topic here. Therefore every question at Code ...


19

The mission of Code Review is to help programmers improve working code. Although A-B comparison questions tend to elicit a different kind of answer and therefore make us feel uncomfortable, they are just another way for programmers to seek help to improve their working code. We should therefore welcome them as Code Review questions, even though they don't ...


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

I see no reason why it wouldn't be. Provided it is otherwise on topic. Which, your question is. The code works, you're honestly looking for a review, etc. What stops us from reviewing Fim++ is that we can't tell if fim++ code works, because there is no compiler implemented for the language. No compiler = hypothetical code. So, Fim++ remains off topic until ...


19

I found working on this jigsaw puzzle a personally rewarding experience. It really helped me appreciate what you do here. Obviously the longer your site has been around, the more problems you find that need addressing. I'm sure you've tried cramming more unrelated close reasons into each slot, but that becomes unwieldy fast. I've been developing a better ...


19

Are reviews that ask us to DRY their code within the spirit of CR? Yes. If you know that your code is not DRY and you want it to be, isn't that almost like having broken code? Not the same at all. Just because you have a feeling that your code doesn't adhere to DRY, doesn't mean that others will agree with you. Others can still say "It's not as bad as ...


19

Strictly speaking, Code Review requires you to post real code from a project that you are working on. In practical terms, though, any plausible realistic code is acceptable too. If your real project is a shopping cart for a porn site, and you decide to post the question as a shopping cart for a clothing site, that's fine. Just make sure that the code ...


19

Short answer: Will you be posting your actual existing, working code? If yes, then I believe Code Review is better. Our help center does state: However, if your question is not about a particular piece of code and instead is a generally applicable question about (...) Higher-level architecture and design of software systems then your question is off-...


18

As a counterpoint, here are a list of highly ranked, small-code questions that have high quality answers, and are generally successful: Each element is the sum of itself with the next element of a List: now do this point-free in Haskell https://codereview.stackexchange.com/questions/25905 Implementing a Singleton pattern in C# https://codereview....


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 understand your concern, but Code Review is unfortunately not the place that you are looking for. I would recommend asking among your friends, on Twitter/Facebook, or on Reddit. Or you could propose a new Stack Exchange site for "Software Reviews". Or take a look at the existing related proposals: Design Review Website Review Software Quality Assurance ...


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