7
\$\begingroup\$

A struct within a class, and this is the edit history: https://codereview.stackexchange.com/posts/60534/revisions

The original code include this method:

public bool AddStudent(string name, int age, string grade)
{
    // To do something
}

None of the code in the snippet provided uses this method. The plain-English part of the code makes no mention of this method.

Moreover, per the help center, comments in the place where executable code belongs makes questions off-topic.

As far as I can tell, including this method makes the question off-topic. With its removal, the question is a little closer to being on-topic (though it lacks some context making it unclear).

In this specific case, removing isn't enough to make the question on-topic. However, in other cases, potentially removing a method like this could make the difference in a question being on or off topic. As such, is it okay to remove methods like this from questions?

This question presumes that the code being removed makes the question off-topic (per the example/pseudo code rule--not the broken code rule), and that the method being removed is not referenced either by the included code snippets or the asker's plain-English part of the question.

\$\endgroup\$

2 Answers 2

6
\$\begingroup\$

The problem with that question isn't that it's unclear.

class StudentMangement
{
    private struct Student
    {
        public string Name { get; set; }
        public int Age { get; set; }
        public string Grade { get; set; }
    }
}

That edit removes a piece of noise, that could have also been edited like this:

private List<Student> _students = new List<Student>();

public bool AddStudent(string name, int age, string grade)
{
    _students.Add(new Student { Name = name, Age = age, Grade = grade });
}

But whether we add or remove code, doing that changes OP's intent, and as such, is an edit that, if I'd have seen in the review queue, I would have rejected as "incorrect, or an attempt to comment".


That said, I don't think closing as "unclear what you're asking" was the right call here. OP's intent is very clear IMO:

What is the best practice for a C# struct?

The Help Center is also pretty clear about this:

Best practices in general (that is, it's okay to ask "Does this code follow common best practices?", but not "What is the best practice regarding X?") [...] then your question is off-topic for this site.

The question is simply not asking for a peer review within the site's scope.

\$\endgroup\$
4
  • \$\begingroup\$ This doesn't answer the actual question asked all that well. I think everyone probably agrees the question belongs closed in its current state. \$\endgroup\$
    – nhgrif
    Commented Aug 20, 2014 at 11:22
  • 2
    \$\begingroup\$ Closed, yes. Unclear what's being asked, not at all. As for the edit in question, I think this answer is pretty clear,I don't think it's a very good edit, I would have rejected it. \$\endgroup\$ Commented Aug 20, 2014 at 11:31
  • \$\begingroup\$ Your answer isn't clear though. That's why I commented. You say "this edit removes a piece of a noise" which seems to be a good thing, then you offer an alternative edit, which ADDS code (and adding code is drastically different) and say that your example is something you would have rejected, but you don't directly comment on my edit to remove the chunk I removed. \$\endgroup\$
    – nhgrif
    Commented Aug 20, 2014 at 11:36
  • \$\begingroup\$ Oh I see what you mean now, right. I'll edit later, thanks! \$\endgroup\$ Commented Aug 20, 2014 at 11:43
6
\$\begingroup\$

You will not alter the OP's code, unless it is clear that their presented code does not match the code they have.

That stuff is subject for review. The objects used. The design. The algorithm. The whitespace. The blank lines between the code statements. The length of each line, the words used for variable naming, the style of the comments, the format of the comments, the language of all the naming and just about anything else that you can attribute to that piece of text sitting in the code box.

Exceptions include:

  • They can't paste in their code due to some wacky error
  • They've put up a pastebin containing a small code sample
  • There's a comment along the lines of "I used tabs and it's not displaying properly".

That's when you edit the code to be indented by 4 spaces. But guess what? By doing so, you don't alter the code. You only alter it as such that the code in the code box matches the code that the OP has. You know, the code that the OP wants to get reviewed.

\$\endgroup\$

You must log in to answer this question.

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