This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Ranch Office and the fly likes how much code to put in a question? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » This Site » Ranch Office
Bookmark "how much code to put in a question?" Watch "how much code to put in a question?" New topic
Author

how much code to put in a question?

Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

I have often been bitten by this issue (and i see many other people are), if I try to put in everything that is usefull, i got complaints nobody could read all of that, if I only put in a couple of snippets of what i thought was the relevant code, I was informed I was missing all the usefull bits.

So How does everybody else decide?
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Ideally, you should provide an SSCCE that has just enough code to demonstrate your problem, so that others can simply copy, paste, compile, run, and get the same results as what you're seeing (or just compile and get the same error, if that's the problem you're having), but no more. Often this will mean that rather than providing a snippet from the project you're working on, you will create a new program, just for the purposes of demonstrating your problem with no extra clutter.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

May way of doing: Firstly I would try to isolate the problem by trying to implement/reproduce in a simple program that way I can remove all the noise. May be after doing this I would be able to solve the issue myself, if not then post the simple program on the forum for help.
There might be times when I dont have patience and end up posting lot more code. But if at all you fail to post the correct code then you always get inputs from other members- whether to post more code or remove excess code. Because a third eye would be able to spot the issue much quickly then the two eyes which have been seeing the issue for long time and yet unable to find the issue.


Mohamed Sanaulla | My Blog
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Mohamed Sanaulla wrote:May way of doing: Firstly I would try to isolate the problem by trying to implement/reproduce in a simple program that way I can remove all the noise.


Indeed. And this is important: If you're doing your investigation and debugging right, you should already have an SSCCE even before you decide to post to a forum. When something is not behaving as you expect, and you can't figure out why, one of your first steps should be to isolate the misbehaving piece (or a smaller, simpler equivalent) and try to understand how it behaves in isolation. As Mohamed points out, this will often lead to you solving your own problem, but if not, it means you're ready to provide the forum with something that is more likely to be useful for the people there to understand the problem and suggest a solution.

Looking at things in small, isolated pieces is a High Holy Writ of software development (and many other types of research and experimentation as well).
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38467
    
  23
We have posting guidelines already, which include things like “Isolate the Problem”. The “Post Real Code” page there, for example, has links to sites about SSCCEs.

We usually discuss questions about questions on a different forum, so I shall move this discussion. It will remain “visible” in this forum, however (I think, for one week), and may remind new posters about those guidlelines.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how much code to put in a question?