26

My question here seems to be getting a lot of negative attention

Ruby on Rails - Invalid Date

This is an important question for me and I would like to hear some ways to improve this.

I take great pride in my posts, and want all of them to be top-quality. This was my first post to receive a negative feedback rating.

I tried creating a good post, but it looks like I came up short.

I am open to any suggestions or feedback. All insight is appreciated.

11
  • 15
    From the now-deleted post: you posted too much code; bring that back to a minimal sample that reproduces the problem. See How to create a Minimal, Complete, and Verifiable example.
    – Martijn Pieters Mod
    Aug 13, 2014 at 18:13
  • Thank you. Which code snippets should I delete? I thought all of them were important but maybe I don't need the User Controller or User.rb. I'll try deleting those first
    – Darkmouse
    Aug 13, 2014 at 18:15
  • 10
    The point is that those that help you should be able to reproduce your problem without needing to install a large number of moving parts. Try to see if you can simplify this in a new Rails environment with much less code.
    – Martijn Pieters Mod
    Aug 13, 2014 at 18:16
  • 8
    You were given a whole bunch of reasons why this is not a good post the last time you asked us what was wrong. You were also given advice on how to create a minimal reproduction of your problem.
    – Servy
    Aug 13, 2014 at 18:18
  • I always thought that more code was better, but I can see why some might be intimidated by the amount of code I had. Looks like I got carried away there. I tried to trim down the code to only the most important parts.
    – Darkmouse
    Aug 13, 2014 at 18:22
  • 13
    It wasn't so much about being intimidated by the amount of code, it was about having to parse the code to find the bits relevant to the problem. Aug 13, 2014 at 18:41
  • 2
    More code is better, a counterexample.
    – Jongware
    Aug 13, 2014 at 21:56
  • By "this question" do you mean this actual question? Okay, I'm being facetious, but only because the title of this question is too generic to be very useful. Aug 14, 2014 at 12:26
  • 2
    It seems worth pointing out that the original question, as phrased, is impossible to answer correctly. You did not say anywhere what the original format of your date was, which turned out to be the problem. If your function expects an input in an expected format, that's a possible point of failure that is at least as important as the code attempting to manipulate it later.
    – iabw
    Aug 14, 2014 at 12:32
  • @Jean-FrançoisCorbett Any suggestions for a better title? Everything more specific I can think of requires knowing what the problem is, e.g. "What can I do to improve a question with too much code in it?"
    – Michelle
    Aug 14, 2014 at 12:32
  • +1 for being interested in learning how to improve your questions.
    – Drew
    Aug 15, 2014 at 17:47

2 Answers 2

46

"More code is better" is not always true, unfortunately it is even rarely true. Why? Because:

  1. Even if the question looks interesting and well-formed, it still causes the TL DR problem (the same applies to text walls as well).
  2. And if it doesn't make the impression from the title and overall formatting, then it begins to look like a code dump.

That's why good questions should contain only valid and relevant code pieces—a minimal complete verifiable example. And it is not just "only the most important parts."

An MCVE is:

  1. Something that stops any speculations, clarifies your intent, methods and context (at least as much as code can do it).

  2. Something you can easily understand without any need to juggle the enormous amount of pieces in mind:

    Who wants to mentally debug some DI traversing through five classes or combine a class from ten pieces?—Very few and not every time.

  3. Something that can be easily set up on the answerer's machine and tested:

    Mental debugging is a very powerful tool, but it has its limits. Sometimes you just end up tweaking actual code to solve the issue. And even if our brains are capable of handling incomplete or disordered code, the compilers (or interpreters) aren't so forgiving—pasting multiple code pieces and setting up the entire project to debug an issue could be a frustrating and long process.

  4. Something that forces you to cut to the source of the problem:

    It is tempting to just dump the code (I do not say that it is exactly your case - you've obviously spent enough time pasting, formatting and explaining everything). But in the end, can you look into the mirror and say to yourself: "I have tried everything I can to fix it and failed, so I pinpointed the issue and asked the question"?

    For me it is usually difficult due to the pinpointed part—if multiple code pieces each of dozens line of code are needed, then I probably haven't removed everything unnecessary or irrelevant.

    Divide and Conquer—it is the main principle that allows us to deal with complex systems like programs. If you use it on your program you'll either find the issue or drop the deadweight. But in any case you will win, because creating a clean and short problem demo will improve your own understanding of both the issue and the whole program.


So, what can be done to improve it?

  1. MCVE is your best friend. When you know your enemy, you can face it. Otherwise it will just lurk in the depths of the program draining your resolve and energy.

    MVCE will demand a lot of efforts, will break the architecture, use a lot of hard-coded values and look very contrived. But it will deliver what it intended for—the gist of the issue.

  2. And that's probably all. Personally I do not see any other real issues with your post.

P.S.

Do not take downvotes so personally. As has been said your only problem was in the far too excessive code snippets. And someone, probably in frustration from overall amount of code dumps in new questions, decided to downvote it without giving you a chance to fix the problem.

That's their right, no one can force them to fix and babysit every question they encounter. Just the comment describing the problems(whether with or without the downvote) is usually more useful for OP than just the downvote. And it can prevent further repetitions of the same problems in future posts.

So, do not despair and remake it with an MVCE.

Asking questions is a useful skill, but asking right questions right is an even more highly sought one. Good luck.

4
  • 20
    When I follow this process of attempting to simplify a problem for posting on Stack Overflow, I usually end up solving the bug myself and find it unnecessary to actually post a question.
    – iabw
    Aug 14, 2014 at 13:24
  • 4
    Even if the question looks interesting and well-formed, it still causes the TL DR problem even if this answer doesn't provide a wall of code, it is a wall of text and produces TL DR :) Aug 14, 2014 at 17:40
  • 1
    @iabw shhh, we are hunting wabbits Aug 14, 2014 at 18:53
  • Perhaps you mean "Do not take downvotes so personally". I think that would read better than "close"
    – crthompson
    Aug 14, 2014 at 21:05
7

I looked at your question and, even in its current form, I got a strong TL;DR vibe. And I think I know why...

By placing useful prose between your code examples, I'm forced to scan through the whole question to read it all (see below). I see snippets of code, which while short, are not conducive to quick analysis. So my brain tells me "You're going to have to really concentrate here before you can understand what this question is all about". And I would move on.

Try summarising the whole problem at the beginning of your question and place the code snippets beneath, almost like appendices.

Prose placement

0

You must log in to answer this question.

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