5

I have seen Source code on GitHub (failed review) and I have a similar problem.

I have a data structure that I obtained from academia that is not completely tested. The data structure is a single short C source code file. I downloaded the data structure and ran it, now I am getting a segmentation fault.

I have a temporary fix for this segmentation fault and one that I believe is ugly. Is it on topic to present my fix for this GitHub source code and ask for improvement?

I can provide a minimum working example for this problem.

0

3 Answers 3

20

As long as you have a short (as a rule of thumb, something that doesn't cause the code box to scroll) example that you can post in the question itself that allows anyone to reproduce the problem, you are free to also link to GitHub for the extended version for anyone interested. But if you can post a shortened sample that suffices in itself, then there's no real need to link to an extended version elsewhere, so… meh?!

Secondly, you shouldn't ask for improvement of code here. If you have specific concerns that you need answered (e.g. "may this break if XYZ?"), that's fine. For code improvement question, please see http://codereview.stackexchange.com.

9
  • 3
    on the Code Review SE - they write that linking to external github site is illegal for SO
    – gansub
    Commented Oct 1, 2018 at 8:14
  • 2
    If your code is exclusively on GitHub, yes. Also, can you link to that specific citation?
    – deceze Mod
    Commented Oct 1, 2018 at 8:15
  • 1
    codereview.stackexchange.com/help/on-topic - "For licensing, moral, and procedural reasons, we cannot review code written by other programmers. We expect you, as the author, to understand why the code is written the way that it is."
    – gansub
    Commented Oct 1, 2018 at 8:16
  • 6
    That's… somewhat different than "illegal to link to GitHub on SO"!? What it's saying is that you should ask for reviews of your code, code you have written. In your case, you will need to supply a sample of the data structure for completeness, but your question is about your code and how your code may be improved. So that's fine IMO.
    – deceze Mod
    Commented Oct 1, 2018 at 8:18
  • Apologies. Maybe I came out wrong. There is a bug in that github code. I do not know how to fix it because the author is unwilling to help. So asking to fix that function is on topic here ?
    – gansub
    Commented Oct 1, 2018 at 8:20
  • 4
    Asking for a fix is on-topic here. Preferably you'd show the problem, demonstrate what you have achieved so far or perhaps just what you have tried and ruled out as a solution, so we can hone in on a fix quickly. In your case, since you have a solution that works, you don't really seem to have that kind of question though. Again, only if you have specific concerns about the fix you have already written would this really be on-topic here. Otherwise, for a general "I've written this, is this okay?" question, Code Review should be the appropriate site.
    – deceze Mod
    Commented Oct 1, 2018 at 8:24
  • 4
    Stack Overflow: specific answers to specific questions. Code Review: more open-ended tell-me-anything-that-sticks-out.
    – deceze Mod
    Commented Oct 1, 2018 at 8:25
  • 2
    @gansub CR has a rule that you should only ask about reviews regarding code you have written yourself. They also have a rule that you should only ask about working code. If you have found a bug in a specific function from some Github code, you should ask on SO. As long as the problem is narrowed-down and can be reproduced.
    – Lundin
    Commented Oct 1, 2018 at 13:39
  • @Lundin As I have repeatedly said: if OP has working code which is a fix for a piece of code they can't fix, then it should be fine to ask about a review of that fix (with a necessary sample of the original problematic code for context), should it not?
    – deceze Mod
    Commented Oct 1, 2018 at 13:41
6

More than one issue here:

  • Links to external resources (be them Git repositories or anything else) are only OK if they are supplemental to your question. Your question/post should stand on its own two legs without other users needing to follow the links. A post should be self-contained and complete. Links can die change, and any of these things would render your post obsolete.

  • Questions about "how to improve this code" are not on-topic in Stack Overflow. Stated like that the question is not properly scoped, and is liable to be closed as either too broad or primarily opinion based. Try to think over your question to provide a more stringent definition, so while multiple answers could exist, there isn't room for infinite answers, and it's easier to produce an answer that's unarguable correct or incorrect.

    Some other users are recommending you to head over to CodeReview. I'm nof familiar enough with that site or know enough of your question to tell you if that's a good idea. You should spend some time reading their rules before deciding to post there, nevertheless the advise you get here. And no matter what, they would want your posts to be complete as well, without any external dependencies.

2
  • Linking to external Git repository may have licensing issues as well ? Since I did not write the code there maybe issues posting it here ?
    – gansub
    Commented Oct 1, 2018 at 8:13
  • You should only post code you have the right to post, of course. But you should also provide a proper [mcve], so simply copyng and pasting would be most likely be wrong in any case. You'd need to work to produce a proper working example that demostrated the issue you want to ask about, and nothing else.
    – yivi
    Commented Oct 1, 2018 at 8:14
5

If you want to ask for review and improvement of working code in a broad sense, that's certainly not on-topic for Stack Overflow.

Such questions might fit on Code Review, but make sure you read their help section first before asking the question.

Stack Overflow requires a specific problem, and doesn't accept general improve this code questions.

2
  • 1
    If I present my question without showing any attempt for segmentation fault people always ask - what have you tried ? :)
    – gansub
    Commented Oct 1, 2018 at 8:05
  • The problem is you're asking for improvement on an answer. That's not on-topic. If you'd ask a self-answered question on the segfault it would be somewhat different, but you wouldn't get improvements on your approach.
    – Erik A
    Commented Oct 1, 2018 at 8:11

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