Questions tagged [code]
Questions relating to code that appears in a question or answer, such as answers which are entirely code. Do not use this tag for questions about code formatting; use [code-formatting] instead - and NEVER EVER USE THIS TAG TO ASK A PROGRAMMING QUESTION ON META!.
133
questions
2
votes
0
answers
51
views
Proportional font instead of monospaced on mobile in inline code blocks [duplicate]
On the mobile version of Stack Overflow, inline code blocks are still proportional instead of monospaced.
Example:
Illogical1011111illllll
1
vote
0
answers
478
views
Pasting multi-line code block sometimes fragments the code
I was trying to answer a SO question that involved some VBA. The question had a code block, which I copied to my VBA editor (which resulted in some non-indented lines, made some fixes, then put it ...
16
votes
2
answers
497
views
Brackets/curly brackets highlighting in code samples
I wonder if in code samples we can highlight the closing bracket when the opening bracket is clicked (and vice versa).
This can sound like a silly feature but it does help a lot visually to quickly ...
2
votes
1
answer
116
views
Code Diff in answers
I'm not sure whether this is the best place for feature suggestions, but I think having a diff viewer for code that compares source code snippets to answer's code snippets would be a very helpful ...
52
votes
3
answers
876
views
Are imports useful when posting code on answers?
Today I've seen this user editing multiple posts and he's being doing it for a couple of days. His edits only remove imports on the code (Example) and sometimes he improves something else, that, IMO ...
8
votes
1
answer
771
views
Best practice for using code snippets from Stack Overflow
Is there a best practice for reusing code snippets from Stack Overflow in production code?
Personally I always do something like this:
// Handling input that is not parseable as an integer.
// ...
1
vote
0
answers
158
views
When a user's question amounts to "write this code for me," what is the best course of action? [duplicate]
When processing review queues, I often come across questions that amount to, "I need this function to do x, please re-write for me" or "I need code that does this, please provide this code." Those ...
-1
votes
1
answer
79
views
Is it considered more useful to answer with pseudo-code or code? [closed]
I'm not a big fan of spoon-feeding but I'm aware sometimes you just have to provide code in order to clarify a point.
But is it more useful in the long run to provide pseudo-code and then comment on ...
157
votes
7
answers
4k
views
Is it bad practice to post a short answer first and then add details afterwards?
I have the habit of posting quick code-only answers to "simple" questions, and then add details / context later... for example on a question that I stumble upon in a review queue, that can ...
-10
votes
3
answers
151
views
Cannot post code due to post size
I was trying to ask a question and include a code source.
The problem I faced was running into the maximum size of a post. Even when using the stack snippet, I could not post my code. So I tried to ...
-5
votes
2
answers
109
views
Integrate a real time code syntax tester
I wonder what your opinion is on the idea of integrating some kind of code syntax tester.
This would greatly help in preventing syntax errors when we write code for a specific question.
1
vote
2
answers
62
views
Should I insert some code when asking for idea?
I'm having a problem with the following thing:
Today I've asked a question about getting all cases of a word in Perl, and, to my mind, wrote the question exactly the same way as here. However, if ...
-5
votes
2
answers
248
views
How are you supposed to post code in answer comments?
Answer comments are obviously not the right place to paste code. However in discussion it may be useful to refer to some code, for example a candidate implementation of something. Where are you ...
-3
votes
1
answer
193
views
Save Answers to Your Own Snippet Library
This comes from the meta topic Can we favorite an answer instead of a question?
Where the accepted answer was that we could not "favorite an answer" but you can find it by looking for your upvote.
...
-1
votes
2
answers
157
views
Minor edit of code rejected [duplicate]
I asked a question about how to implement a specific functionality in Rust and got a very good answer that solved my problem, but I wanted to improve the code in minor ways. The edit was approved by ...
3
votes
0
answers
79
views
While Reviewing, What to do when someone gives an algorithm in Pseudocode and asks it to be writing in given language? [duplicate]
What do the guidelines say about asking to translate pseudo-code into a given language? Is it against the guide lines? If it is or if it isn't, should it be, or should it not be? (I can think of good ...
17
votes
0
answers
299
views
Add a means for tab stacking code snippets
The vast majority of questions on Stack Overflow come with a specific language tag and no post in the tag will contain any language other than that specified language.
However, for some questions are ...
-15
votes
1
answer
67
views
Possible Github integration such as code imports?
Github Integration
Idea
I thought of a new feature that might be helpful. Github integration for questions and answers.
Examples & Usage
Code imports in Q&As
Automatic pull requests from ...
3
votes
4
answers
85
views
Question review
The following is a question I asked on SO: Boolean short-circuit not short-circuiting.
When I posted I omitted to specify one of the frameworks that are in use in the code. It turns out that the ...
48
votes
2
answers
2k
views
Is there really a universal code requirement?
On a question asking for an approach to solving a programming problem such as this one the user is not asking it as a "gimme teh codez" (as far as I interpret it). So I don't interpret it as being ...
10
votes
5
answers
734
views
Should I demonstrate best practices in example code or be concise?
A commenter to an answer I recently posted said:
Please don't ignore errors in "example" code... You know some fool will blindly cut-n-paste it and... later make some other SO answerer's life ...
2
votes
0
answers
168
views
Clarification on Stack Overflow code license [duplicate]
I have seen tons of posts on the license on the code used here on stackoverflow.com. A simple search brings tons of results but I still don't fully understand the license the code on this site is ...
191
votes
12
answers
9k
views
Can we get some explicit clarification on the *intended* legal usage of code from SO answers?
I was recently told by someone that due to the fact that Stack Overflow uses the CC BY-SA 3.0 license any code examples cannot be used in a commercially available closed source application. This ...
133
votes
6
answers
3k
views
Reduce "try this" answers by giving a helpful message
An answer that consists solely of a code block or "Try this" (and variations) followed by a code block and nothing else is usually not useful if not very low quality. So let's encourage people to fix ...
-13
votes
2
answers
333
views
How to convince people to write code instead of gibberish long paragraphs?
As hackers our common language are the programming languages. Since most of us spend more time writing code than blogs I think it is only normal for us to express ourselves better with code.
But a ...
22
votes
0
answers
365
views
Should we automatically detect pastebin (and other related) sites?
New users can only post a limited amount of links. However, they might reserve this link for paste sites such as pastebin, bpaste and so on. In my opinion, these kinds of websites are useless as the ...
25
votes
2
answers
727
views
Remind people that included files are part of an MCVE
This question concerns C or C++, but it may be relevant to other languages.
When constructing a minimal, complete, and verifiable example (MCVE), occasionally the question asker does not include the ...
2
votes
1
answer
83
views
Should an answer link to live code?
If I'm answering a question and I find myself writing code that lends itself to a live demonstration, as in the case of HTML and JavaScript, should I link to a page where readers can see it in action? ...
-29
votes
3
answers
223
views
Re: Requests for Code Outsourcing
I agree that Stack Overflow is not a code outsourcing site. But, is it permissible to ask for code in exchange for bounty? The respondent would receive compensation in the form of rewarded reputation ...
5
votes
1
answer
278
views
How to deal with post containing only code
How should I deal with stuff that contains only code (both question, "here code, fix it" and answer that has just a bunch of lines and not comment at all)?
Is:
for answer: flagging it as "This is ...
35
votes
11
answers
1k
views
Should provided code in an answer work?
I'm wondering whether answers that involve some guidance on how to use an API or sketch an algorithm should be fully functional. I often consider the answers to be pseudo-code that guides the OP in ...
3
votes
2
answers
162
views
Edit code to reduce the used space
I usually read the sql tag here on Stack Overflow and sometimes in the questions there are long queries with very little code on every single line, for example this question.
The particular point is ...
232
votes
1
answer
65k
views
How do I format my code blocks?
How do I post text so that it is formatted as code?
What do I need to do so that my code shows up properly—not escaped or removed—when posted? And how do I get the correct syntax ...