5

The topic of code quality comes up often enough that there is a wiki Q&A devoted to it:

How would you know if you've written readable and easily maintainable code?

There are currently 103 questions linked to or marked as a duplicate of that question.

The question is very broad, and a poll asking for ideas. There are no constraints on the problem, and there is no single correct answer.

How would one know if the code he has created is easily maintainable and readable? Of course in your point of view (the one who actually wrote the code) your code is readable and maintainable, but we should be true to ourselves here.

How would we know if we've written pretty messy and unmaintainable code? Are there any constructs or guidelines to know if we have developed a messy piece of software?

The answers are equally as broad to the point of being useless.

  • Your peer tells you after reviewing the code.

  • Sometimes, the best way to know, is to come back to code you wrote six months ago and try and understand what it was written to do.

  • It is: maintainable if you can maintain it.

  • If your code follows the principles of SOLID and DRY and has a good set of unit tests around it, it is probably maintainable.

  • If you can understand it after 6 months, it's not bad.

Yes, these are all correct answers. None of them point the question's author in the wrong direction. But there is no success criteria. There is no real problem to be solved. Why ask the question? Does your team have a specific quality issue to solve? No, this is a poll, and the answers are vague, abstract, and plain old common sense to anyone in the industry.

This is compounded by the fact that there are over a hundred questions marked as a duplicate of this one. A question is a duplicate when the duplicate target's answers can also answer the new question. With the quality of the answers being so poor they cannot answer the duplicate target question, how could they answer the question being marked as a duplicate? They cannot.

What should we do to this question? Is it worth improving its quality, or should it be locked or deleted? What should be done with the linked questions marked as a duplicate of this question?

2
  • see also: Can we please cleanup this popular question? "...answers that are strong candidates for deletion: - belong to low rep or anon users with no real commitment to the community - are provably duplicate, that is, were added well after (30+ mins later) other answers that contained the same exact information - are short in length - do not explain much of anything"
    – gnat
    Commented Jul 20, 2015 at 20:59
  • I checked the question in logged out mode, to see how it may look like for outsiders / low rep users. Only about half of 19 answers appears to be worthy. Why am I not surprised
    – gnat
    Commented Jul 21, 2015 at 6:24

1 Answer 1

3

While the question and its answers are poor, this is a topic that is inescapable. Users will continue to ask similar questions, so it makes sense to try to have a canonical Q&A that addresses their concerns even if the question is primarily opinion-based or off-topic. Clearly, this question fails to be that canonical resource in its current state.

I propose we take the following three actions:

  1. Fix the question. It needs to specify some type of success criteria. How do I quantify good code? This is inherently an open-ended and subjective issue, but we can try to reign it in a little bit.

  2. Fix the answers. If an answer can be improved to explain why what it proposes will improve quality, then great. If it is redundant (a quick scan of the eyeball shows two answers both saying "if you can understand it six months later..") or useless, delete the answer.

  3. Delete the other questions that are marked as a duplicate of it. They serve only to decrease the signal to noise ratio.

I do not believe we should add a historical lock to that question for the simple reason that it may be worthwhile to be able to edit or add answers at a later date if new ideas relating to code quality come up, new concerns by users who wonder why their question is a duplicate, etc. We may want to add a header to the question similar to the historical lock stating "this is here for historical reasons, do not ask questions like it."

8
  • What about a wikilock? meta.stackexchange.com/a/230278/200235
    – durron597
    Commented Jul 20, 2015 at 20:56
  • 2
    @durron597 for a successful wikilock, it really needs to be distilled down to one canonical answer - not one people are going to have opinions on (and thus edit wars and dissertations and justifications). To an extent, this is part of the symptoms of the problems with the question - there is an answer that starts out "Some of these answers are terrible. I can't understand why they are being up-voted. Answers like 'If your peers can read it', 'if you go back to it and it makes sense', seriously?" This type of material cannot be reasonably wikilocked.
    – user40980
    Commented Jul 20, 2015 at 21:27
  • 2
    "it makes sense to try to have a canonical Q&A that addresses their concerns even if the question is primarily opinion-based or off-topic" I disagree. It makes sense to close every question that is off-topic as off-topic rather than as a duplicate of an off-topic question.
    – zzzzBov
    Commented Jul 21, 2015 at 17:10
  • 1
    @zzzzBov in the past I was thinking like you, until I saw a reasoning here that made me change my mind. '...There are two goals to closing a question: keeping the question from getting further attention, and educating the asker so they'll be a better contributor. Pointing out the duplicate is a nicer way of saying, "Next time, look to see if similar questions have been closed."'
    – gnat
    Commented Jul 21, 2015 at 23:51
  • 1
    @gnat, off topic is still off-topic. Closing questions as off-topic serves to clearly show that the intention of this site is not to ask and answer those sorts of questions. If it's garbage, take out the trash, and don't leave it lying around for the next guy. I have seen many questions along the lines of "do my work for me" but it should be obvious that it's not a good idea to keep a single "do my work for me" question lying around just to close the others as a duplicate of it.
    – zzzzBov
    Commented Jul 22, 2015 at 0:07
  • 2
    @zzzzBov I understand what you're saying, I've been doing this way myself in the past. Heck I even often do so currently, when duplicate is hard to find (even when I know there is a duplicate). I merely point that other point of view also has merits. As for leaving it laying around, the best way to get rid of trash is to vote down and abstain of answering - system automatically deletes negative score unanswered questions, no matter if these are dupes or not
    – gnat
    Commented Jul 22, 2015 at 0:10
  • 1
    @zzzzBov I agree the trash should be taken out, but there is a rare question that should be handled this way: they are signposts. That is part of the reason for having historical locks, and the reason why I specifically stated in my answer that there should be a notice in the question stating something similar to the historical lock message.
    – user22815
    Commented Jul 22, 2015 at 0:27
  • 1
    It has been over a week since I posted the original Q&A here with several upvotes to both and no new answers. I went ahead and edited the question to improve it.
    – user22815
    Commented Aug 1, 2015 at 3:03

You must log in to answer this question.