20

Do I have to explain why I need some code related advice? Do I need to explain why I don't want or can't use some technology or part of framework when in my question I specifically seek advice on correct way of coding my solution of my problem?

Let's say I try to write copy of STL and I need advice on some twisted generics voodoo. Do I need to explain why I just don't use STL and why am I reinventing a wheel? Do I need to explicitly say that it is just a learning experience or what are reasons behind my question? Because without it my question instead of valuable answers will be polluted with "you should use STL, reinventing a wheel is stupid" remarks.

What if I can't explain my reasons due to fact that I can't talk about my work in details? What if my STL is not in fact STL but something under non disclosure agreement but to make my problem more clear I use STL which is familiar to most of developers?

EDITED

NDA is one of reasons why somebody may not be able to explain details but I understand critics about that point in my question.

That said if somebody asks about specific code and give you this code as example and visualization of his question do you really need to know why does he want to write this code? Maybe his boss is crazy and this is one of his crazy requirement? :)

1
  • 21
    I understand that it can be very annoying when people treat you like you don't know what you're talking about, but there are hundreds of questions on SO every day where the fundamental concept is flawed, and needs correcting (rather than answering the actual question that was asked). Because those cases are the majority, it is often necessary for the asker to indeed provide some background (or simply get across that they know what they are doing) to be taken seriously. See also What is the XY problem?
    – Pekka
    Jul 1, 2011 at 19:22

5 Answers 5

26

Do I have to explain why I am asking a question on SO?

No. However, if you want good, precise answers that directly address your specific reasons for needing this solution, you save a lot of time and needless commenting by providing as much information as necessary so others don't become distracted by things that aren't relevant.

Programmers are often good at optimization - if there are easy obvious solutions that you don't discuss in your question, they will bring them up.

Make sure you provide enough information to cut off useless optimizations, but don't make the question long. A simple, "For a variety of reasons which I can't/won't go into here, I cannot use the STL." should be sufficient without giving away your NDA.

20

Do you typically give advice without understanding the context?

To the question "Do I have to explain why I am asking?" I would say the answer is sometimes yes, sometimes no, and sometimes you shouldn't have to but you won't get a good answer unless you do.

Remember that answers are solving your problems. So do you have to explain that you are asking because you are building a top secret spy satellite with x-ray vision? No, but you need to explain that A and B are not acceptable options because of conflicts with system C, which you are committed to using.

Most questions aren't simple syntax problems, so answerers need to know the context of what you are trying to accomplish. To be effective at giving context, you need to abstract your problem, which has the following benefits:

  1. You keep the noise down and the question concise.
  2. You won't mislead users with information that isn't significant
  3. You don't tell the world what you are working on

This does take a little skill, but it will help you get that much better answers.

Sometimes, the question is fine, but odd enough that without an explanation, users can't help themselves by telling you that you shouldn't care. This happened on a question yesterday where a user was asking about why the DOM element style properties turn out the way they do, but got a bunch of suggestions to use classes instead. If the user had initially explained that they weren't interested in classes and why, then they may have had more focused responses from the beginning.

4
  • 3
    +1. I often change my package names to com.mycompany.example and play Mad Libs with my variable and method names before I post to SO, or come up with a completely independent example that illustrates the problem but is not the actual code I'm working on.
    – Pops
    Jul 1, 2011 at 18:10
  • ok, I understand what you are saying but if you asked me "why you don't use X" and I will answer "because I can't" or "because I don't want to" will you answer my code related question or will you press me on my reasons? I don't mind asking for clarification but I do mind writing elaborate explanations on why I do not go usual way if it is really not related to a question
    – grapkulec
    Jul 1, 2011 at 18:23
  • @PopularDemand I generally just put my code up, because I already use generic names for things. I mean, if someone can sort through my related code samples and can build even 40% of my backend from that, kudos to them. I doubt anyone is a) that interested in my questions or line of work, or b) that masochistic. That being said, I'm not one of those to have SO build my projects for me ;) ~ All that to mean: why bother? Unless you have massive swaths of code on SO, just leave the names alone.
    – jcolebrand
    Jul 1, 2011 at 19:22
  • 4
    @grap - you don't have to, but understanding why you're not using X is still helpful because those constraints may also rule out other options people might suggest
    – Brad Mace
    Jul 1, 2011 at 19:46
11

I was with you on this for a while. I usually advocate answering the question that was asked and not making any assumptions about what the OP "really meant" or "would want if he only knew better." (I believe this puts me in the minority of SO users.)

Also, if you state that a certain library is not an option for you, and someone gives you pushback about it, I would downvote that person for not answering the question. The reasons why are your business; they are not programming-related.

That said, I can't get on board with your last paragraph. Although I'm not a lawyer, I can't imagine a situation in which an NDA would force you to obfuscate your true intention to the degree you're describing. More practically, if you're changing your code to make it more accessible to a wider audience, you could of course be removing the actual bug you're facing and/or introducing new ones.

2
  • +1 except fro "I would downvote that person", since you would be downvoting because his/her opinion is not yours. Jul 1, 2011 at 18:03
  • 11
    Hypothetically, if an asker says "I cannot use jQuery, only plain old JavaScript" and an answer is given in jQuery, I think that answer is no more on-topic than an answer in, say, FORTRAN. Nothing opinion-based about it. I probably wouldn't literally downvote unless there was a certain degree of obnoxiousness involved, though. Future visitors to the question might have the same problem but not the no-jQuery restriction.
    – Pops
    Jul 1, 2011 at 18:07
6

I would say yes, if you are not in a position to use the generally accepted best practice, then a brief explanation of that is warranted. You do not need to reveal trade secrets, violate any NDAs, but you should give the briefest of explanations and if that is not good enough for the masses, then so be it.

For example, if someone in C# was using ArrayList all over the place, you'd expect him or her to be asked "why don't you use List<T>?" The answer could simply be "I'm maintaining a .NET 1.1 application." That's all that needs to be said.

In your case, maybe there's more to be said, maybe not. At any rate, if you're demonstrating something outside of best practices, expect to be told to adhere to best practices. If you can't, say so and briefly why. That should be good enough for most people.

1
  • my question was about design of my class hierarchy, does it make sense, is there anything that should be coded differently, nothing mind twisting really, just need opinion of some more experienced developers on my design. and I got comment that I should derive from WinForms or WPF base classes just because in my question I wrote that my classes are somewhat similar to WinForms
    – grapkulec
    Jul 1, 2011 at 18:11
5

Yes, sometimes.

Someone who asks

I want to use .NET without using mscorlib.dll

Is clearly talking nonsense. Your question was

I want to make a Windows GUI in .NET without using WinForms/WPF

and that comes very close. WinForms and WPF are always readily installed.

I know there could be a good reason, but it should be possible to provide this in general terms w/o breaking a NDA. As it is , your question looked a lot like trolling.

It shouldn't have been moved though, IMHO.

0

You must log in to answer this question.

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