4

Some questions have the following shape :

I have data :
[datum, datum, datum]
I need it in other format :
[other datum, other datum, other datum]
How do I do that?

No code to actually make the conversion is provided.
If some code was provided then it would be a debug question ("I tried it with conversion code but I ended up with data in broken format instead, what went wrong?").

Is such a question off-topic?
What if the question can be answered with short (< 10 lines or so) and fairly simple code?
What if it can be answered with a language built-in?

5
  • 3
    It has to be useful to somebody else. That's the usual problem with questions like this, they don't name a formal data standard or a specific version and name of a common app that generated it. Nobody will ever google that Q+A. Commented Oct 10, 2015 at 18:00
  • 1
    @Kyll: why do you use too-broad tag here? If the question has an answer "use time.mktime()"; it is not too broad. "off-topic" and "too-broad" are not synonyms: there are off-topic questions that are not too broad.
    – jfs
    Commented Oct 11, 2015 at 4:48
  • 3
    Is anyone else tempted to VTC this question as "Unclear what you're asking"? ;)
    – Dan Field
    Commented Oct 11, 2015 at 4:58
  • @J.F.Sebastian I guess you know this, but: if a question has an answer, it may still be too broad... on account of having many other answers besides.
    – Frank
    Commented Oct 11, 2015 at 5:00
  • @Frank: "too broad" means that a useful answer may require to write a book. Having more than one valid answer doesn't make a question too broad. Almost all programming questions have more than one answer.
    – jfs
    Commented Oct 11, 2015 at 5:35

3 Answers 3

7

I say that depends entirely on the two sets of data and how much detail is given.
If the relation between input and output is unambiguous, I'd say it's on-topic.
Otherwise it might be "too broad" or "unclear".


I would consider such a question on-topic:

I have a unix timestamp (like 1444495607) and want to convert it to a date string, like 10.10.2015 18:46:47. How can I do that in [language]?

However, I would vote to close as "too broad" if it were less detailed, like:

How can I convert timestamp to date string in [language]?

Because "date string" is rather ambiguous, and not every representation is suitable for every use case. For example, you probably wouldn't want a JS-like string of Sat Oct 10 2015 18:50:18 GMT+0200 (CEST) to be displayed to an end user.

The amount of detail required also depends on the complexity of the data. For example, converting an integer to a string is a pretty unambiguous request, but if there was a question like

I have the following string:

"d4f56g4d156"

How can I convert it to a JSON string like

"{year:\"2015\",data:{herp:\"Derp\"}}"

?

Then I'd vote to close as "unclear what you're asking", because I cannot see any relation between the two data sets.

Similarly, I would consider a request to convert an array to a String in Java "too broad", and a request to convert a HashMap into an array "unclear".


Also, if they do not specify a language, the question is likely going to be too broad, but there are a few cases where this doesn't have to be the case, namely if all of the following apply:

  • The task they want to do is not part of a bigger program
  • The task they want to do does not depend on the programming language
  • You have enough information about their environment to chose a language you know they have available

For example, I consider the following perfectly answerable:

I have a folder structure that is up to five folders deep, and I want to rename the folders, to prefix them with _pdf if they contain any pdf files. I'm on Ubuntu, how can I do that?

This could be answered by a bash script, for example.

But the following request would be pretty much unanswerable:

How can I turn the following JSON object into an array?

["herp", "a", "derp"]

Java? JavaScript? PHP? ...?


TL;DR: It depends.

5
  • Good examples, but: I have a unix timestamp (like 1444495607) and want to convert it to a date string, like 10.10.2015 18:46:47. How can I do that in [language]? that almost certainly has good answers on Google already, probably even a couple of duplicates on Stack Overflow.
    – Pekka
    Commented Oct 10, 2015 at 17:24
  • 1
    @Pekka웃 Yes, most likely. But the type of question is ok, and there's a first time for every question :P
    – Siguza
    Commented Oct 10, 2015 at 19:04
  • @Pekka웃: if you have found a duplicate then close it as a duplicate. Being a duplicate does not make an answer off-topic, it is the opposite. Moreover it indicates that the question is useful if a it is asked multiple times.
    – jfs
    Commented Oct 11, 2015 at 10:02
  • @J.F.Sebastian if entering the question title into Google yields a perfect answer to the question, it is not useful to post the thousandth duplicate of it on SO. In that case, at the very least downvoting is warranted.
    – Pekka
    Commented Oct 11, 2015 at 10:18
  • 1
    @Pekka웃: if the question does not show the research effort; you can downvote it. If you know it is a diplicate; close it as a duplicate. It has nothing to do with the question being off-topic or not. Ponder, why lmgtfy links are forbidden on SO.
    – jfs
    Commented Oct 11, 2015 at 10:23
7

No, they're not inherently off-topic. Including broken code in a question is not mandatory.

1
  • 5
    They're often enough downvote-worthy though - for example when the answer can be found through a simple Google search
    – Pekka
    Commented Oct 10, 2015 at 17:04
1

It could be off topic:

I want to convert all the .PDFs to .DOC on my server - a consulting company told me it'd cost more than I want to spend, but we all know programmers can do this in their sleep so just tell me how.

It could be unclear:

I have data 1234, I want it to be <xml><date>today</date><variable>asdf</variable></xml>

It could be overly broad, or opinion based, or asking for an off-site resource

What are all the ways/the best ways to convert PDF to XML programatically? Tutorials pls?

Or it could be perfectly fine...

How can I convert this string to title case in C#? I've tried TextInfo.ToTitleCase but it's not working as expected.

...but have a high likelyhood of being a duplicate. We shouldn't say this perfectly fine question is out of bounds simply because it's "easily googable" - chances are, that Google search points to an on-topic question on this site (and if it doesn't already, it would be a good idea to create a question/answer for it here). We wouldn't want to remove that resource as if it were off-topic - even if we'd close the new one for being a duplicate.

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