7

My question Define one object's method as another object's method then use it programmatically has been closed.

I don't understand why this question has been closed. The reason given is "Lack of focus". In the original post, I'm asking one specific question which is why the line cursor.insertText(text).matchArray[i].setFunc(); produces the error. That line is clearly marked with a comment in the code snippet.

I provided further information as to where I was headed with the code once I got past this particular problem in the belief that this would aid the formulation of any answers (perhaps I'm headed down completely the wrong path for what I ultimately want to do).

I've edited the original post (clearly noted) to show what else I've tried to solve the problem (before the question was closed).

The answer to the question lies, I assume, in how I've defined setFunc() in the matchArray's objects and that's where I need help. I've been quite focused on that regardless of comments that the code has "several syntax errors" (it doesn't and runs perfectly well with the problematic line commented out).

Also, the title is as focused on the problem as I can make it with the knowledge I have.

What else can I do to get the question reopened?

9
  • 13
    You don't need to "clearly note" where you've edited your post. When interested parties look at your post, they can see a history of the edits done and see whether they agree if the question has been focused enough to reopen. Indeed, it is preferred if the question reads as if it was never edited; the purpose of Stack Overflow is to create a library of high quality questions and answers for future people to find and get answers from, so the question should be clear and focused for those future people when they find it. Commented Mar 4, 2021 at 12:55
  • 5
    The whole issue here seems to be of wrong assumptions, or potentially even an X/Y problem. Most of your question discusses and presents things that are completely irrelevant to the error, because your error is caused by a rather simple logic/syntax error. The issue is... that error was caused by something you tried to do, but your question doesn't really explain why you were trying to do it. It's easy to say "Your code is invalid", but without knowing why you used the invalid syntax... it's anyone's guess as to what should be done instead.
    – Kevin B
    Commented Mar 4, 2021 at 16:21
  • 3
    . . . and yet, in the past when I've tried to strip down the code to only where the problem lies, I've been told to present it within the context of a working function with all details on what I expect the code to do. This I have done (even explaining what setIndex() is – and still I'm asked to explain what it is). I know I have done something wrong – what is that 'rather simple logic/syntax error' and how to correct it so that, as the title of my question states, I can 'Define one object's method as another object's method then use it programmatically'? Commented Mar 4, 2021 at 17:00
  • 2
    i'm not sure what that means: "Define one object's method as another object's method then use it programmatically" you can certainly define properties on existing objects, you can extend something so all instances of it have a given property, but i don't know what you intend to gain from that. Method chaning is a lot more than just adding properties from x to y.
    – Kevin B
    Commented Mar 4, 2021 at 17:06
  • 1
    For example, cursor.insertText(text).matchArray[i].setFunc() Why does matchArray[i] in this case need to be called on the return of cursor.insertText(text)? Why is doing this on two lines unacceptable? What was the goal there?
    – Kevin B
    Commented Mar 4, 2021 at 17:12
  • 1
    My typo mistake @KevinB: that comment should read: cursor.insertText(text).matchArray[i].setFunc(); should end up being treated as: cursor.insertText(text).setItalic(textStart, textEnd, true); I've tried setting var blah = matchArray[i].setFunc(); and then cursor.insertText(text).blah(); but I get 'ReferenceError: setItalic is not defined' Commented Mar 4, 2021 at 18:26
  • 2
    @MarkGrimshaw-Aagaard - You shouldn't use commentary to clarify a typo. The code you are actually asking about isn't even in this question. Commented Mar 4, 2021 at 18:58
  • 3
    @MarkGrimshaw-Aagaard There is a middle ground between posting all the code you have and posting the line you believe is the problem, and that is creating a [mre]
    – klutt
    Commented Mar 4, 2021 at 19:21
  • 6
    My 2cts @OP, but stg ("else") that might (also) be "playing a role" is that for the 16 months since you joined the Forum/Site, from the 15 Qt's you've asked that are (still) visible (all in [0-1] Votes, so I guess a few got automatically deleted by yourself or the over-zealous Cleaning-Bot (-1 is enough...)), you never accepted one single Answer while several Answerers have already referred you to the "What should I do when someone answers my question?" Page...
    – chivracq
    Commented Mar 4, 2021 at 23:42

3 Answers 3

16

In the past, we had a close reason called "too broad", but it have been replaced by "focus". The description is a bit different as you may have noticed, since "focused" has to do with asking multiple questions at once. Unfortunately, many people are using this close reason in situations where "too broad" would have been suitable. The correct close reason in this case would have been "unclear", because the question is simply unclear.

This is a decent template to achieve a clear question:

I want to create a program that <description>

So far, I have tried this minimal reproducible example: <code>

When I run it with input <input> I get this output <actual output>, but what I am expecting is this output <expected output>

In other words, explain what problem you're trying to solve, create a minimal, reproducible example and show your attempt, show it's output and explain what you expect instead.

10
  • 8
    One nitpick on your question template: "So far, I have tried this: <code>" seems to imply that the poster should post the code they were trying to run when they ran into a problem. This is not the case, though. They should post an MRE, like you suggest at the end of your post. I suggest changing the template to be "The issue I am having can be demonstrated succinctly in this minimal, reproducible example: <code>" Commented Mar 4, 2021 at 20:59
  • 3
    Another nitpick: the question must also include a clear explanation of what specifically the author needs help with. Questions of the form "I wrote this code, here's what it does, here's what I want instead", but which don't show what the author did so far to try to figure out how to fix the code, nor what part of that effort wound up blocking them, are still not useful and not clear enough for a good answer. Commented Mar 4, 2021 at 21:56
  • @PeterDuniho Yeah fair point, but I'm not aiming to make this post the ultimate guide to how to ask a question :)
    – klutt
    Commented Mar 5, 2021 at 10:20
  • 2
    @PeterDuniho Furthermore, I'm a bit ambivalent. Sure, I don't like people treating SO as their personal coding service. But on the other hand, those questions that I have had the most help from when I'm googling my own problems are those with a VERY to the point perspective. The problem is not primarily that people don't give a lengthy explanation of their effort, but more that they have not narrowed the problem down to the actual problem.
    – klutt
    Commented Mar 5, 2021 at 10:23
  • "The problem is not primarily that people don't give a lengthy explanation of their effort, but more that they have not narrowed the problem down to the actual problem" -- it's both. Ignoring the word "lengthy", which doesn't belong there. Word count is not the issue. The issue is when the question amounts to "I wrote some code, now I need to add a new feature; write it for me." Commented Mar 5, 2021 at 17:41
  • @PeterDuniho If we skip the factor that we don't like help vampires. Let's just say that you want to know how to calculate the length of an array in C. You fire up google and type "c array length" and then you get this one stackoverflow.com/q/37538/6699433 Does it matter to you in that situation that the question is just a question with zero effort?
    – klutt
    Commented Mar 6, 2021 at 10:13
  • 1
    "Does it matter to you in that situation that the question is just a question with zero effort?" -- if the _only thing that mattered was whether future readers can find the answer useful, obviously no. But that's not the only thing that matters. Stack Overflow is awash in a deluge of crap questions, far more questions than there are people to answer. In 2008, maybe it made sense to tolerate such a poor question; indeed, that particular question obviously exists only so that the person who wrote it could post an answer...something that in the early days of Stack Overflow was probably ... Commented Mar 6, 2021 at 18:27
  • ... encouraged more, or at least tolerated more. But if someone asked a question like that today, even just to self-answer? No...we should not tolerate that, because every question like that makes it that much harder to find the real questions, the ones that there wouldn't be an answer to on the Internet if Stack Overflow didn't exist. And frankly, with thirty-four answers, that question is of questionable value even today; sure, most people will get their answer from the accepted post, but that answer is trivial to find without Stack Overflow. If you're looking for anything more ... Commented Mar 6, 2021 at 18:27
  • ... in-depth, you've got to read through a huge mess of poorly-organized information, just hoping that maybe the little detail you want is in there somewhere. Those kinds of details belong in a much more focused question, one that's easy to find when you want it, not one that requires you read thirty-three other irrelevant answer just to find. Your example is actually quite good at illustrating why we shouldn't tolerate crap questions like that. Commented Mar 6, 2021 at 18:30
  • @PeterDuniho is right: a self-answered question can afford to be minimal, as basically a placeholder for you to write the answer you want to share. When you want someone else to write that answer for you, it's fundamentally different from a perspective of social dynamics. To be fair, there are plenty of examples of old low-effort questions from the early days of SO that are common and general enough to be worth answering well, you just happened to pick a self-answered Q&A instead. And yeah, too much detail about attempt and effort make it more about that beginner, not a good canonical. Commented Mar 7, 2021 at 3:18
13

The question is unclear.

You have a bunch of code and clearly something isn't working as it should, but I can't tell what it's supposed to be doing. As a result, I can't tell what'd be wrong.

Try to explain what your code is supposed to do, and what is going wrong.

3
  • It looks like that setFunc is assigned by setFunc = function() {setItalic(textStart, textEnd, true)}; but we miss setItalic. I assume a stacktrace would also help to verify the right line is indicated where/when the error pops up.
    – rene
    Commented Mar 4, 2021 at 12:38
  • Thanks for the quick responses. I spent some time explaining before I posted the snippet what the code was supposed to do and, after the snippet, what I was aiming for (to provide context). The code snippet itself points out where the error is and what the error is. As noted, I assume the error is in the setFunc method assignment of matchArray's object and that's where I need help – I've done something wrong there and I don't know what. Commented Mar 4, 2021 at 13:28
  • 2
    setItalic – again, in my attempt to be clear, I did note what it was and where it came from (it's a google script method that is the only means to convert text to italic as it is inserted in the document). If I comment out that line where I try to actually use it, the script runs fine. I wouldn't know how to do a stacktrace within the google scripts environment. I will go back and make all these things even clearer. Commented Mar 4, 2021 at 13:32
7

The question should have been closed as "needs details or clarity", not "needs focus". At the end of the day though, the close reason doesn't really matter; the fact that your question was closed should be enough of a hint to you that there's something wrong with it.

As for the question's content, I've read through it three times and I'm still not sure what you're trying to accomplish, what the code you've presented has to do with it, or what the actual problem with said code is.

I can make some good guesses, but if I have to guess at a question's meaning and intent, I'm generally going to discard that question and move on. The simple reason is that I've been burned in the past by answering a similarly vague question and being told my answer wasn't what the asker wanted, and that pisses me off because that's a waste of my time. Other long-serving members of this site have similar experiences and similar responses to such questions.

The onus is always on you, as the one asking a question, to ensure that your question can be answered by people like us who have zero knowledge of the context from which you're asking it.

4
  • 12
    I agree with this answer except for "... the close reason doesn't really matter". The fact that the wrong close reason was chosen made the OP try to fix a problem that didn't really exist, and didn't point them to where they should have looked instead, thereby wasting the OP's time. There are other benefits to picking a correct reason, which I won't get in to, but on the whole, I think appropriate close reasons do matter.
    – cigien
    Commented Mar 4, 2021 at 21:47
  • @cigien but reopening a closed question just to close it again doesn't seem good.
    – 10 Rep
    Commented Mar 5, 2021 at 19:09
  • 3
    @10Rep Absolutely, and I'm not suggesting we do that at all. I'm just saying that it does matter that we use correct close reasons, and so we should try to do that in the first place. If a wrong reason is chosen, a comment could be left for the OP indicating what they should improve; reopening the question just to close it with a right reason certainly isn't worth the effort.
    – cigien
    Commented Mar 5, 2021 at 19:12
  • Closing a Qt for a "wrong Reason" feels ironically like a Demonstration/Application of the "X/Y Problem", oops...!
    – chivracq
    Commented Mar 5, 2021 at 19:57

You must log in to answer this question.

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