-5
\$\begingroup\$

This has been an issue here since a long time and I see a lot of people just to get brownie points jump in and copy paste the answers which can be as generic as possible for example:

  1. Use linter
  2. Bad variable names
  3. Generic advice such as use services where possible etc.

In fact they are not answers too, they are list of generic advice.

To be clear I am not saying these advices are bad but as per my experience most of the programmers suffer in designing good programs, issues like lint and variable names are short term pain which can be cured easily.

I know its a free community but should there be rule asking people to write at least few pieces of code?

I see that a lot of people misunderstood my question and felt it as rude. So, just to clarify I wanted to say in short how to ask for comments or suggestions on design specifically? I know its always not possible but there must be a way to say ok I know there may be linter issues which I may have missed and you can comment on that but I am also interested in design issues too.

Examples:

Providing little or no value

https://codereview.stackexchange.com/a/175318/58341

https://codereview.stackexchange.com/a/179138/58341

https://codereview.stackexchange.com/a/151231/58341

Answers which can be revisited again and again and are great source for leaners:

https://codereview.stackexchange.com/a/104949/58341

https://codereview.stackexchange.com/a/102708/58341

https://codereview.stackexchange.com/a/127322/58341

and many more, I am fortunate enough that I found many people here to be very inspiring, they always write quality answers:

  1. https://codereview.stackexchange.com/users/12390/janos

  2. https://codereview.stackexchange.com/users/9357/200-success

\$\endgroup\$
  • 1
    \$\begingroup\$ Answer that triggered this question: codereview.stackexchange.com/a/179138/98493 \$\endgroup\$ – Graipher Oct 30 '17 at 14:48
  • 5
    \$\begingroup\$ I'm sorry what are you trying to argue for/against? Also 'bad variable names' is a valid reason to write an answer. Do you think I should delete such an answer? If not, where do you draw the line? \$\endgroup\$ – Peilonrayz Oct 30 '17 at 15:10
  • 4
    \$\begingroup\$ I think your question and demands are rude. People are reviewing your code for free so show a little gratitude. Not every answer deserves 10+ votes but I think every answer that makes a good point about the code deserves at least +1 for the effort. \$\endgroup\$ – t3chb0t Oct 31 '17 at 12:06
  • \$\begingroup\$ @t3chb0t don't see it as a one side effort, I also spend a considerable amount of time to post good questions, imagine a community without questions, car without fuel? anyways it time for reflection for all of us. \$\endgroup\$ – CodeYogi Oct 31 '17 at 21:46
10
\$\begingroup\$

First of all, two related meta-questions:


My experience is that Code Review answers are personalized to what the answerer feels is important for the asker at a specific point in time, for a specific piece of code. We do have a not-so-obvious-or-written rule on Code Review that even though the asker doesn't ask for some advice (such as variable naming and styling), answerers are free to comment on any aspect of the code.

While the above approach to "Any and all aspects are up to review" might be annoying to some who feel like they did not get as good as a review as they were expecting, it is unfortunately necessary. Imagine someone asks you "What do you think of this recursive method call?" and you have (extreme example here) no idea what their code is doing and barely can read their code because of messed up naming, formatting, indentation, everything, then you just can't answer them about the recursive method call.

Personally if I find styling and naming to be at least acceptable, I just don't comment on it.

If/when you get an answer that you are not happy with, remember that it's not guaranteed that that answer will be the only one you will ever get. And if you comment on the answer, I would suggest commenting with something like "Thanks, I will keep this in mind, but right now I am more concerned with the structure of how I should organize my classes, can you expand a bit more on that?". Also remember that they are free to reply with "No, sorry, I can't".

About some of your specific concerns:

In fact they are not answers too, they are list of generic advice.

A list of generic advice is also an answer. The answerer believes that you would have use for this generic advice.

To be clear I am not saying these advices are bad but as per my experience most of the programmers suffer in designing good programs, issues like lint and variable names are short term pain which can be cured easily.

Absolutely, which is also a reason why it's so easy for reviewers to comment about them.

I know its a free community but should there be rule asking people to write at least few pieces of code?

Absolutely not. I see no reason for such a rule. The only requirement for answers here is: They should be answers. More specifically, they should point out something in the OP's code. They should also not be pure "This is what I would do " without any explanation or reasoning why their approach is better than the code in the question. (Unfortunately this is way too common)

\$\endgroup\$
11
\$\begingroup\$

First, let me specifically answer your three points and why I think they are helpful answers on Code Review:

  1. Many programming languages have agreed-upon styles. Where this is the case you should use a linter if you expect somebody to read your code (future you included). Therefore not doing that before posting here shows that the asker is not aware enough of this and should be reminded of it. Just because it is almost always applicable, does not mean that it is bad advice. It just means that most people either don't follow it or have never been given this advice.

You can always note in the question that for some reason, maybe legacy code, you did not adhere to this or that particular part of the normal coding convention and that this should be ignored.

  1. Variable naming is one of the hardest things to get right. While I agree that a generic "Use better names!" answer is not very helpful, it can be if you did not even think this was a problem. And there is basically no way for the answerer to know the difference. If the answerer can give specific suggestions for variable names, this can actually be quite helpful.

  2. This depends on the question and which service specifically is recommended. It might or might not be part of a good answer. In this specific case I think the recommendations given were specific enough not to be a complete copy & paste answer.


We currently encourage short, possibly without any code, answers, in addition to fully-fledged comprehensive reviews.

This is included in the "How do I write a good answer?" page in the help-center:

What goes into an answer

Every answer must make at least one insightful observation about the code in the question. Answers that merely provide an alternate solution with no explanation or justification do not constitute valid Code Review answers and may be deleted. In addition to criticisms, pointing out good practices in the code is also a form of helpful feedback.

Answers need not cover every issue in every line of the code. Short answers are acceptable, as long as you explain your reasoning. Do not provide suggestions for improvements in a comment, even if your suggestion makes a very short answer.

And in "What can I ask about here?":

Reviewers may comment on any part of the code

Feel free to call attention to specific areas you are concerned about (performance, formatting, etc). However, any aspect of the code posted is fair game for feedback and criticism.


Historically (I think, this was before I properly joined) this has been done to encourage people to answer questions here, at all.

Giving a partial answer to some issues with the code posted is better for the Code Review site than no answer at all (by decreasing the number of unanswered questions). It is probably also better for the person asking the question, even though they sometimes will get some feedback they do not care about. But they might get more feedback. Long code review answers might also contain some recommendations they do not care about.

Code Review is less about finding the answer to your code, but about getting feedback on your code. There might be multiple short and incomplete answers that together give you this feedback.

I do agree, that copy & paste answers might not be very good answers. If that is the case, just don't up-vote them. If they actually recommend anything bad or are factually wrong, down-vote them.

\$\endgroup\$
  • \$\begingroup\$ What about the question? if you see my question I asked some very specific and good questions and the answers were very generic. Again I am not saying its a bad thing but things are not black and white always, I believe that I can copy and paste that answer to almost every question and believe its truth but in my heart I know what OP is asking. We are building a community here, something which can help others. \$\endgroup\$ – CodeYogi Oct 30 '17 at 15:44
  • \$\begingroup\$ Also from your point "Every answer must make at least one insightful observation about the code in the question." I can't find any sorry. \$\endgroup\$ – CodeYogi Oct 30 '17 at 15:47
  • 3
    \$\begingroup\$ Yes, you asked "It may be too broad, but what good programming practices I should follow". He answered that, in addition to catching some bugs. It's the sort of answer that I would appreciate. \$\endgroup\$ – 23fc9a62-56de-47fb-97b4-737890 Oct 30 '17 at 15:47
  • \$\begingroup\$ @Hosch250 you didn't mention what I wrote after that "...for example when and where to choose objects, enums etc? " \$\endgroup\$ – CodeYogi Oct 30 '17 at 15:50
  • 4
    \$\begingroup\$ Because those are "examples", not "restricted tos"... \$\endgroup\$ – 23fc9a62-56de-47fb-97b4-737890 Oct 30 '17 at 15:52
7
\$\begingroup\$

For want of a nail the shoe was lost.
For want of a shoe the horse was lost.
For want of a horse the rider was lost.
For want of a rider the message was lost.
For want of a message the battle was lost.
For want of a battle the kingdom was lost.
And all for the want of a horseshoe nail.

You can have the best-designed program, but if you don't use best practices when implementing it, it can be horrible. If you don't use best practices, we can't see the beauty of your design. If you don't use best practices, we can't even see what you are trying to accomplish 99% of the time. While I agree that copy/paste answering is bad and that the answer should be tailored to the question, I don't think we should do anything besides downvote if the answer is poor quality in other ways.

As for requiring the answerer to write code, that is definitely not going to happen. An answer does not need to have code to be good; in fact, the best answers I've received are those with a lot of tips and no code at all. As for your claim that best practices are trivial to clean up, I highly disagree. It's often like pulling teeth to get most people who write horrible code to follow best practices, usually because they have that same argument, or that it doesn't improve readability, etc. And it isn't trivial to clean up--it is only trivial if you know exactly what is happening, which is often very obscure if you aren't following best practices. In short, not allowing answers like that and requiring the answer to write code would kill this site.


Per the linked question in the comments, that is actually a reasonably good answer. It finds at least three bugs and recommends that the OP follows best practices that have been carefully designed to help prevent bugs and encourage people to write their programs with better design.

\$\endgroup\$

You must log in to answer this question.

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