55

I have written some plugins for jQuery that are very often searched on Google. One of them is used for long-click event handler, presented in a "beautiful" way, for example:

$("a").longclick( function() { /* code */ }, 500 );

I want to share my work with everybody (for free). Is it OK to post a question on Stack Overflow and answer it myself? Or should I post somewhere else on the Stack Exchange Network?

17
  • 18
    You could create a tag and follow it. Then when you release it and people start using it, you can answer their questions for them.
    – Albzi
    Commented May 20, 2014 at 10:29
  • 70
    You can write a question and answer pair, but beware - though this is technically and officially OK, many people in the community take a dim view of such self promotion, whether for profit or not.
    – Oded StaffMod
    Commented May 20, 2014 at 10:34
  • 4
    I am mostly worried about not being downvoted for something like this!
    – Victor
    Commented May 20, 2014 at 10:37
  • 1
    "I want to share my work with everybody (for free)". Are you not sharing your work already (if it's often searched on Google)? I'm just not sure whether you're talking about using SO as a code-snippet repository here, or whether you're talking about using SO to point to your work hosted elsewhere (e.g. GitHub).
    – Bruno
    Commented May 20, 2014 at 11:49
  • 5
    Also see How can Stack Overflow users be encouraged to use jQuery only when appropriate?. Questions and answers about a special plugin of a special library might not be very interesting and might result in only few views. Why not starting your own blog? Commented May 20, 2014 at 12:02
  • 1
    written some plugins for jQuery you should really add a tag as mentioned by BeatAlex.
    – Mr_Green
    Commented May 20, 2014 at 12:23
  • 13
    You should totally drop that and try... oh wait. Commented May 20, 2014 at 13:15
  • 4
    I think it's okay to have a few "How I do make longclick (or X plugin) work with a custom function. Worst case scenario there's one of these for each plugin, but that's what would happen eventually anyway, this is just beating them to the punch Commented May 21, 2014 at 12:43
  • 1
    Alternatively (or worst case scenario), you can always post a link in your profile description to your github profile, or even line-by-line links to individual repositories you wish to advertise. Commented May 21, 2014 at 13:46
  • @Gracchus, will you upvote my code "for free"? :))
    – Victor
    Commented May 21, 2014 at 17:11
  • Victor, quite simply .. search on SO and you will surely find someone asking about the issue at hand. Go right ahead and answer, or better, put it in as a comment, and include a link to your web page or whatever. By the way, what the hell is query??
    – Fattie
    Commented May 22, 2014 at 10:08
  • Show HN (on Hacker News) should be a better option although I never read these posts..
    – cr0
    Commented May 22, 2014 at 10:09
  • SO does have a way to advertise open source projects. You could use that if it turns out your current idea isn't going to work out.
    – Tyler
    Commented May 25, 2014 at 13:10
  • @JoeBlow, and there are quite a bit of those questions already
    – Basilevs
    Commented May 27, 2014 at 2:31
  • 3
    Sounds like you need a blog.
    – Ed B
    Commented May 28, 2014 at 19:33

10 Answers 10

207

Stack Overflow is not GitHub. I recommend that you not start turning it into a code-sharing service.

21
  • 11
    Then why are we encouraged to answer our own questions? I am just trying to understand what the founders said by that :-?
    – Victor
    Commented May 20, 2014 at 11:41
  • 194
    Your code is not an answer. Lack of your code is not a question. Commented May 20, 2014 at 11:42
  • 10
    @Victor: Suppose that you discover that JavaScript behaves weirdly with the absence of semi-colons at the end of a line (return\n"Hello, World"; and return "Hello World"; having different behavior), then asking the question and explaining what's going on to other people will help them. Commented May 20, 2014 at 11:46
  • 3
    If you make a fair question SO encourages you to keep searching for the answer, not just waiting for others to find the solution. If finally you found a valid answer out of SO, you should add it to your question instead saying "Nevemind, I solved it by my own" and removing it Commented May 20, 2014 at 11:46
  • 1
    One of the other problems with publishing code on SO instead of GitHub (or other) is the licence. The CC licences aren't always the most appropriate for software. (If you do publish code on GitHub and have never done this before, please do remember to put a licence, otherwise we won't be able to use it.)
    – Bruno
    Commented May 20, 2014 at 11:58
  • @PabloLozano Closing it as a duplicate is a lot better. Commented May 20, 2014 at 12:25
  • 1
    @JohnSaunders is spot on. Thanks for the thought, though, OP. Commented May 20, 2014 at 12:33
  • @R.MartinhoFernandes I'm talking about keep investigating and trying to solve an issue without SO, not looking for a similar question in SO Commented May 20, 2014 at 13:01
  • @Pablo then you should not remove anything but instead post the correct answer. Withholding knowledge doesn't help. Commented May 20, 2014 at 13:02
  • @JohnSaunders, I have just seen your comment! My code in this question is not meant for being the answer. The answer would be the complete code of the plugin with some explanation on it.
    – Victor
    Commented May 20, 2014 at 14:10
  • 11
    John dude .. "why all the anger?" "Stack Overflow is not GitHub." OK - who says that? You? The founders of this business? Is it a "general opinion" or what, buddy? What's with the “Answer your own question – share your knowledge, Q&A-style”. I see everywhere? (is that "different"?) The only thing we know for certain about SO is: SO is a business like Pfizer or Google started by some guys to make cash money so that they can pay for diapers and bread. When you "recommend" that he doesn't use it as code sharing .. that's a harsh way to phrase "it would be a shame if...". You know?
    – Fattie
    Commented May 22, 2014 at 10:12
  • 20
    @JoeBlow Try not to confuse brevity with snark - I'm sure John didn't intend it.
    – user50049
    Commented May 22, 2014 at 11:55
  • 4
    @JoeBlow: when I express anger, it's usually pretty clear. That's not anger, just conciseness. Besides, it doesn't even look like GitHub :-). And I meant "I recommend you not start using it for code sharing, but I can't actually stop you" Commented May 22, 2014 at 13:49
  • 4
    "IMO, the founders of SE wanted to hijack the brain of all programmers and other field experts around the world and make a super clean encyclopaedia out of it". That's not even close. The founders of SE wanted to make money to eat - not complicated. it would be like saying "the founders of amazon wanted to help move books around the world!!" of course, the founders of amazon and stackoverflow wanted to: make money. To feed their children, buy diapers etc.
    – Fattie
    Commented May 27, 2014 at 6:47
  • 1
    @JoeBlow, will I get any diapers for answering questions? Anyway, what was the question?
    – Jodrell
    Commented May 29, 2014 at 16:14
49

We support answering your own questions, it's built right into the user interface. It's designed for those moments when you have this sort of epiphany, pull something together and want to make sure the next person finding themselves in that particular variety of quicksand is able to make use of your sage advice.

When you get into wanting to share a plugin, or entire library, it's better to just get it exposure using any of the code forges, and you can offer your plugin as a solution to questions where it would be appropriate. Just give thorough answers:

  • This is mine, I wrote it
  • Here is a code sample that encapsulates the example you provided
  • Here's further directions you could go with it, if you wanted
  • Here's (any applicable) shortcomings

I'm sure you'll find a few opportunities to do this, but make sure you answer other questions too - or folks might think you're being a bit spammy, even if it's open source (you do stand to gain contributors, but that's digressing).

I wouldn't out and out use the site as a platform to announce it, though - while I'm certain that many would appreciate it, an equal number wouldn't appreciate how you went about it, and would probably react negatively.

Folks have relaxed a bit when it comes to the use of the feature, but I fear this might be pushing it a tad bit far.

1
  • Nicely put. You've explained the general vibe of what is likely to happen and so on, and how that may or may not be changing over time.
    – Fattie
    Commented May 22, 2014 at 10:14
29

Answering questions to promote your own libraries (unless done in moderation and with the answer being useful without reference to an external resource) is likely to cause people to consider you a spammer. Creating questions that you can answer with such a promotion, more so.

1
  • 1
    Few times the same person who write answers has a 2nd account to write questions. You can easily see that by looking if answers are always to questions of the same person. Unluckily I saw that few times, and is likely that the answer from someone else will not be accepted. Commented May 23, 2014 at 12:38
25

I want to share my work with everybody (for free).

Thank you!

Is it OK to post a question on Stack Overflow and answer it myself?

Yes, definitely.

However, you need to care about asking the correct type of question for it:

  • [BAD] - What plugin should I use for …?

    SO is not a recommendation service. $("a").longclick( function() { /* code */ }, 500 ); would not be an acceptable answer.

  • [BAD] - What does a plugin to … look like?

    As @JohnSaunders has very nicely put it, SO is not a code hoster. Don't paste the source of your plugin in an answer.

  • [GOOD] - How do I …?

    You want to share your knowledge, not your plugin. Make an answer in which you outline the important techniques for …, and how to implement them. It's fine to cite relevant parts from your plugin's code for explanation purpose.

    In the end of the answer (or even in the first comment on it), you then can put Oh and btw, I've coded this into an easy-to-use jQuery plugin here with a link to your project's homepage.

1
  • 1
    I like this answer, it doesn't oversimplify the question. If a difficult problem is what led you to create a plugin, no reason not to share the journey with others who may run into the same thing.
    – aw04
    Commented Oct 23, 2014 at 17:43
15

For what it's worth... my #3 most upvoted answer was a question-answer pair I wrote myself.

Ref: On Windows 7, how does Java JVM set "user.home" System property?

I spent far too long on this problem. When I found the solution after very tough Googling, I wanted to share with others. StackOverflow did not have the answer. Admittedly, I felt awkward the first time. After I got votes on both sides (Q & A), I've done a few more.

I do this when an answer requires me to synthesize multiple, diverse sources: Google, official docs, source code, blogs, and StackOverflow.

12

I think if you can formulate a good question, then give a good answer that includes your code, that is quite acceptable. However, if the question you give is "how do I do X beautifully", that is not acceptable. Make sure the question is something people actually ask, and represents a real problem.

Also, make sure the answer includes the code, don't link to your own website or blog. As long as the question is useful, and as long ad your answer is well written and includes your code, you should have no problems.

2
  • 2
    Once framed as a question, it may turn out that it's been already asked. Checking for that should also be part of the process. Commented May 21, 2014 at 15:00
  • 2
    Make sure the question is something people actually ask, and represents a real problem. Wow, is that hair splitting. People will up- and down- vote for a variety of reasons -- but self-promotion is one of those things that can get you down-voted into oblivion if it's too obvious.
    – McGarnagle
    Commented May 24, 2014 at 17:51
11

You could create a question at Software Recommendations SE (tagged with jquery) and answer it yourself, either including the full code (if it’s short) or linking to it. Make sure to disclose that it’s your software.

(You could also post a question with your code (or several questions about specific parts of your code, if it’s too long) at Code Review SE, asking for improvements.)

Note that any code you post on the SE network will be licensed under CC BY-SA 3.0. But you can, of course, license it under other licenses in addition, e.g., you could say that your code is also licensed under GPLv3 or that it’s in the public domain.

-10

As a newbie to this site I'd have to say I wouldn't care if the answer was self-answer/promotion as long as it solved a problem or gave me insight to a problem.

1
  • 8
    It's ok if you don't care. There are those of us who will care on your behalf, so you don't have to. Commented Jan 28, 2015 at 20:21
-16

Yes it is now possible. StackExchange has added a new CheckBox to indicate that the Question contains an Answer.

You can find more information on this page:

https://stackoverflow.blog/2011/07/01/its-ok-to-ask-and-answer-your-own-questions

Thanks to all guys that have contributed to push this new enhancement.

4
  • 3
    That blog post is from 6 years ago, so it's not a "new enhancement". You were always able to self-answer. This isn't what the question is asking.
    – ChrisF Mod
    Commented Mar 13, 2018 at 20:34
  • this seems to merely repeat point made (and much better explained) in at least two prior answers that were posted several years ago, here and especially here
    – gnat
    Commented Mar 13, 2018 at 21:24
  • Ok, the link is old but this link is not referenced in this post and it explain clearly what to do.
    – schlebe
    Commented Mar 14, 2018 at 8:08
  • And what about the CheckBox "Answer your own question" just below "Post your question" button. It is new or not ?
    – schlebe
    Commented Mar 14, 2018 at 8:10
-19

I think that posting an article that exposes a problem and explains directly the solution is a good thing.

Posting a question and posting immediately the response is only a workaround.

Suppose that you search to resolve a problem and that you find yourself a solution. You can post a question and then answer to it in another post... with the risk that after a long time your response's post is separate from your question.

What is missing is StackExchange is the possibility to post an article without question.

Somebody has alreay posted a question about that but the post is locked Where can I post a complete solution I found, as an “article

I don't know the author of this post, but I find interesting to reopen it because this post is distinct from this.

There exists a difference between asking to post directly an article and asking to answer to proper question.

The second question is a bad workaround of the first !

I don't understand why StackExchange doesn't encourage writing articles (not posting code, only writing article).

I thought that the purpose of StackExchange is to encourage users to share their knowledge !

Is "writing directly an article" not sharing knowledge ?

9
  • 11
    The SE network of sites tries to be good at being a Question and Answer site. That means we explicitly stay away from blogs/articles/forum like threads. There are plenty of other sites that cater for that. On SE contributions simply has to follow the Q/A pattern. Nothing is missing, it doesn't exist by design.
    – rene
    Commented Feb 9, 2018 at 13:41
  • The right question is . "What is the purpose/goal of StackExchange". Is there to promote sharing of knowledge as written in his About page OR Question and Answer as already written in his About page. I'm analyst and "Question&Answer" is not a goal, it is a concept. I have no problem with that and I will write all my articles on CodeProject even if this can be interesting to share with your users because you don't accept my point of view.
    – schlebe
    Commented Feb 9, 2018 at 14:46
  • 5
    @schlebe we have our way of doing things (Q&A style) and other sites have their own ways of doing things. We are not obliged to host every bit of content that you think might be useful. If you don't want to make the content fit within the construct provided for you, that's your choice, but we are not going to change the construct to fit your content. Our construct works for us, and we are very heavily invested in the continuation of said construct at this point.
    – user4639281
    Commented Feb 9, 2018 at 20:30
  • @Tiny: I don't want to change the construct to fit my content because posting a message that is an article and not a question is already possible ! I can create a post and write in the title that this post is an article and other persons can react to my article as it is a question. What I want is that the first post can be categorized not as a question but as an article and that this practice (already possible) is accepted as a correct practice.
    – schlebe
    Commented Feb 11, 2018 at 8:56
  • 2
    @schlebe that would be changing the construct.
    – user4639281
    Commented Feb 11, 2018 at 17:12
  • @TinyGiant: the following link math.meta.stackexchange.com/questions/5020/… is an article posted by StackOverflow as a question ... but this is an article ! I want to do as StackOverflow, posting an article without question and let others users post "response". StackOverflow make that ! Why not us ?
    – schlebe
    Commented Mar 2, 2018 at 11:51
  • @schlebe meta site are different than the main sites. They are much more relaxed in many ways.
    – user4639281
    Commented Mar 2, 2018 at 15:29
  • @all - thanks to StackExchange that has finally added the possiblity to flag question as a question/answer like described in my post. See stackoverflow.blog/2011/07/01/… It is very disturbing to have a lot of negative points when my request is finally implemented :-)
    – schlebe
    Commented Mar 13, 2018 at 20:22
  • 2
    @schlebe that is not a new feature, has been around since 2011. That checkbox does not exempt your question from the requirement of being in the form of Q&A, and historically such Q&A sets are subject to a much greater level of scrutiny than normal Q&A sets.
    – user4639281
    Commented Mar 14, 2018 at 4:44

You must log in to answer this question.

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