-3

This is the question:

Java - Check if a string only contains symbols

What's a good method for checking if a string only contains symbols. i.e. if one of my properties only contains a "%" or "---" or "$%^&". I'm trying to pick out properties which aren't words.

It's not a very good one but can be easily answered with one line of code, I think that you should either do that (and 3 people did that) or not answer it at all.

The answer I'm asking about is:

Regular Expressions is a way to go. Since Pattern is going to be static, keeping a static copy of compiled Pattern will get you Best time complexity. Check out class named Pattern and it's compile and match method

This technically answers the question but it's not a good answer, I downvoted and commented:

This is too general to be a useful answer

The answerer responded with:

@Oleg Pattern.compile has been mentioned in my answer which is very specific

From looking at Answering and searching meta I don't see anything that will contradict his point and his answer is valid.

Is his answer a valid and/or good answer for Stack Overflow? (I'm kind of asking if it's good enough to be valid)


Update

For questions there is What topics can I ask about here? which sets a very low bar for a question that can be asked here and How do I ask a good question? which sets a much higher bar for what constitutes a good question.

For answers there is only How do I write a good answer? and it sets an extremely low bar. I was looking for some consensus on what constitutes a good answer. To me it's very clear that in this case it's not, that question should be answered with code or not answered at all.

The responses I got so far are:

  • This answer is better than an answer with code
  • It's a bad answer
  • Not good but it's appropriate to the quality of the question so there is no problem with it
  • A philosophical point about what is "good"

So it looks like there is no consensus and/or desire to create a higher bar for answers. It's possible to tell someone 'your question is on topic but not really what we are looking for, please try to do better next time' for some reason people are not interested to have the same thing for answers.

Also whether the question is good or not is not relevant I'm talking about a situation where it was asked and answered take it as a given.

Update 2

@Makoto is the only one who actually answered my question so I accepted his answer. I mostly got what I wanted but some more votes will be better, please upvote his answer if you think the answer I asked about is "fine" or downvote if you think it's not.

If you don't know what "fine" means or still don't understand what I'm asking, this question is not for you, I don't know how to explain myself better.

24
  • 3
    regex is getting like jQuery;( Sep 15, 2017 at 17:20
  • 1
    @MartinJames: You should be less worried about what has already happened and use regex.
    – Makoto
    Sep 15, 2017 at 17:21
  • 8
    The real problem is that it's a bad question, and cannot really be given a good answer.
    – Servy
    Sep 15, 2017 at 17:24
  • 1
    @Servy That's a separate issue, my question is about the answer. Is it as good as the others? (not in terms of quality but in terms of code vs advice)
    – Oleg
    Sep 15, 2017 at 17:25
  • 2
    That answer seems more like a comment as it doesn't even give basic information on how to use the suggested class and boils down to be a suggestion to use regex.
    – Joe W
    Sep 15, 2017 at 17:42
  • 1
    I agree with Servy, bad questions create an opportunity for bad answers. The answer is somewhat appropriate for the question. Since the OP didn't provide any code, answering with a code-only or code-heavy answer may be worse (since then the OP probably learned very little, and it might invite him to use code he doesn't understand, which you should avoid). OP needs to do his research and form an own attempt, and the intention behind this answer is to help him with that.
    – Erik A
    Sep 15, 2017 at 18:01
  • 2
    It is a fairly stoopid unresearched question, entirely too unspecific what "symbol" is supposed to mean. Answerers tend to balance the amount of effort put into it. Not entirely impossible to turn into a Q+A with lasting value, the ball is the OP's court now to uplift it. Might happen. Sep 15, 2017 at 18:07
  • 1
    @Oleg I'm saying it's a bad answer, but an appropriate one. For me, this is a good reason to quickly close these kind of questions, to avoid users from posting answers like this. If you see questions like these, please just flag them or vote to close if your rep is high enough
    – Erik A
    Sep 15, 2017 at 18:07
  • 1
    @ErikvonAsmuth I'm asking only about the answer, when you see somebody post an answer like that, are you leaning towards upvoting it because it's appropriate or downvoting it because it's bad?
    – Oleg
    Sep 15, 2017 at 18:11
  • 1
    Whether or not you find the answer useful, or "good" (whatever that means) is irrelevant. that's simply grounds for you to cast either an upvote or a downvote, not a matter of whether or not it is an answer. You can vote for pretty much whatever reason you want as long as you aren't committing voting fraud.
    – Kevin B
    Sep 15, 2017 at 18:11
  • 2
    It certainly appears to be an answer to me. for example, "How could i also do y?" wouldn't be an answer, because it is instead a new question. just because an answer could be expressed as a comment doesn't mean it isn't an answer.
    – Kevin B
    Sep 15, 2017 at 18:20
  • 1
    "objectively" i think not. this is all subjective, even if there were guidelines.
    – Kevin B
    Sep 15, 2017 at 21:32
  • 2
    What would the official guideline say? All answers must contain a code sample? even ones where it makes no sense for a code sample to be included? It simply isn't possible to create objective rules for a Q/A site of this scale. There has to be some subjectivity, that's what voting is here to solve.
    – Kevin B
    Sep 15, 2017 at 21:38
  • 1
    @KevinB This is something that requires some thinking first there needs to be a desire to create one and at least some consensus about what answers should be here, if there are people who think that the answer I brought up is better than a one line of code that solves the problem it's going to be difficult to create a guideline.
    – Oleg
    Sep 15, 2017 at 21:42
  • 1
    So it looks like there is no consensus Yes, correct. and/or desire to create a higher bar for answers No, other users just disagree on what constitutes a good answer. No one is saying that they like bad answers, they just disagree that an answer without code is always bad.
    – BSMP
    Sep 16, 2017 at 4:31

3 Answers 3

1

Seems fine to me. It's not a detailed answer, but it provides:

  • Something for the OP to experiment with
  • Two (or three, depending on your view) things for the OP to look into - regex, Pattern, and Matcher
  • Enough context into an answer without just giving them the answer, which is an acceptable style of answering

It's not a stellar answer, but it's definitely an answer. Not all answers need to be spoon-fed to askers.

4
  • 2
    "Enough context into an answer without just giving them the answer" I thought this is a Q&A site not a Q&R site. (the R is for riddle)
    – Oleg
    Sep 15, 2017 at 17:38
  • 1
    @Oleg: One can choose to answer a question how they like, so long as they're actually answering it. Regex is a viable answer. The answer just doesn't go into details like what regex is, or what regex to use, which I think is fine.
    – Makoto
    Sep 15, 2017 at 17:43
  • 3
    You're bothered enough to comment Want to explain what your code does?, but not enough to criticize an answer that says Use regex. Reminds me of this. That's a garbage answer where >50% of the text is irrelevant. Sep 15, 2017 at 17:59
  • 3
    @SotiriosDelimanolis: You seem bothered enough to criticize it then. Feel encouraged to.
    – Makoto
    Sep 15, 2017 at 19:12
9

If you're asking if it qualifies as "Not an answer", no, it doesn't. The definition of "not an answer" has already been discussed quite a bit on Meta, though. (Here's a good reference: When to flag an answer as "not an answer"?)

If you're asking whether or not you should downvote it, sure, why not? If you think it's not useful, then click the down arrow. That's what it's there for.

In general, you could have avoided the argument (if two comments can be considered an argument) by just not commenting when you downvoted. Unless you have a really detailed criticism, the -1 speaks for itself.

3
  • No, I know it qualifies as an answer, what I was trying to ask is if this is the kind of answers the community wants to see when the question can be easily answered with code. And the discouragement of explaining downvotes is also something I have a problem with but it's not related.
    – Oleg
    Sep 15, 2017 at 18:33
  • 1
    As far as the community, I don't know if there's really a consensus. I think opinions vary, and I think probably quite a few people (like me) evaluate the specificity required to address the question on a case-by-case basis. Sep 15, 2017 at 18:39
  • 3
    That being said, personally, I'd downvote the example you provided here if I came across it while browsing the site. (I haven't done so in this case because I don't like to participate in the meta effect.) Sep 15, 2017 at 18:41
5

Presence of technically correct information in the post does not necessary make answer useful, complete or even related to the question.

You are free to vote any way you want, preferably based on usefulness and correctness on content of a post. You are also free to pick whether you consider post value as standalone entity or relative to other existing answers to the same/similar question.

In this particular case I disagree with assessment of "post technically correct". The answer makes very strange assertion: "keeping a static copy of compiled Pattern will get you Best time complexity" (compiling or making regex static has no impact on time complexity) - which I consider solid reason to downvote post (whether one should vote on post due to meta effect is personal choice).

Note that question deserves separate voting for using http://www.disney.com to search for answers to programing questions where more generic search like http://google.com, http://yandex.ru or https://www.bing.com/search?q=java+check+if+a+string+only+contains+symbols would be way more suitable.

6
  • I didn't say anything about the correctness of the information in the post the advice to use regex is technically correct. This might be a language thing though it's the same word and can be used in the same way in Russian or maybe it's not clear because it's in writing but I used 'technically' as a way to say 'this kind of answers the question but not really'.
    – Oleg
    Sep 16, 2017 at 2:22
  • For example I can say that you are technically correct that compiled Pattern will have no impact on time complexity but it will improve performance and probably that's what OP meant. And what I actually mean by the previous sentence is that you made a correct point but I don't find it an important or useful point. The issue is that his answer is not useful and something should be done about it but others disagree.
    – Oleg
    Sep 16, 2017 at 2:36
  • 2
    @Oleg Sure. I don't see other answers disagreeing with your decision to downvote... Both other answers just point out that it is answer, but it is up to you to decide if post is up to your quality standards. I view answer you've linked as not useful, low quality, but somewhat answering question so: potential downvote, no need to delete, no need to flag as VLQ or NAA. Sep 16, 2017 at 3:19
  • Yes, you view it as 'not useful, low quality' and it's clear to me that that's what it is, I wanted to see what the community thinks about it and if there is a consensus. @makoto thinks that it is useful, he even upvoted it. 6 other people agreed with him so it's clear that there is no consensus.
    – Oleg
    Sep 16, 2017 at 4:42
  • 1
    @Oleg: "Fine" and "useful" are two disparately different things. The answer is definitely not worth writing home about, but it's also not worth pontification, either.
    – Makoto
    Sep 16, 2017 at 6:41
  • @Makoto Sorry, I assumed you upvote useful answers, this is what this site tells you should do when you hover over the upvote button. Your upvotes are of course your own and you can upvote "fine" answers.
    – Oleg
    Sep 16, 2017 at 12:50

You must log in to answer this question.

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