Is it OK to ask on SO for help in explaining someone else's working piece of code, from Open Source projects or library examples etc.? Or does this belong somewhere else?

  • There are question of this kind (it was even a whole program) that even got many upvotes. – Johannes Kuhn May 14 '13 at 16:50
  • 1
    @JohannesKuhn: That question has the virtue of being interesting to many C programmers. Most "how does this code work" questions are too localized. – user102937 May 14 '13 at 18:46
  • I know, I was just throwing a counter-example in. :) – Johannes Kuhn May 15 '13 at 16:53

I think it is OK as long as you are very specific. But if you throw up a hundred lines of code and say "what does this do" people aren't going to be happy. That's lazy and a surefire way to get downvotes.

Always give plenty of context - what is the project, what is this particular piece of code supposed to do. And describe what in particular you don't understand about the code. For example, if something is happening differently than you expect, explain why you are expecting something different. If they are using a strange syntax when you think something more common would be better, ask why someone would choose to do it that way.

If possible, narrow down the part you have a question about to a single code snippet that doesn't necessarily have anything to do with the library/project you're asking about.

The goal here is for you and others to learn how to be a better programmer, not to document the implementation details of an open source project. In many cases, when doing the above to formulate an interesting question, you will end up answering the question yourself.

Edit: You may also want to try out codereview.stackexchange.com, but I'm not active there and I don't if this is acceptable there or not.


Not sure why the downvote, but I've seen plenty of examples on SO where someone is asking what a piece of code is doing and, although I'm not hugely active on SO, have answered a couple myself. I don't see that there is any problem with it.

It would probably help if you make it clear that you've made a whole-hearted attempt at understanding it. Explain some of the research you've done, give an idea of what YOU think it might be doing, etc. Otherwise it'll look like "please splain to me teh codez", which is just spoonfeeding.

  • 2
    Also make sure that you have the right to repost the code to SO. – Adam Lear Apr 14 '11 at 18:33

You must log in to answer this question.

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