I posted a question and a couple of respondents asked for the source code. I could only post portions of the code.
If attachments were allowed I could have uploaded a .zip file with the whole application. Will this be a feature in SO?
Meta Stack Exchange is a question and answer site for meta-discussion of the Stack Exchange family of Q&A websites. It only takes a minute to sign up.
Sign up to join this communityThere are lots of free file hosts you can use -- it puts us in a difficult position to be hosting arbitrary files for user.
I'm strongly against such a feature. StackOverflow is meant to be a knowledge exchange platform, where we try to build, say, the Wikipedia of programming questions, not a place for troubleshooting "hey, dig through my source code. fix the problem for me" issues for free.
Currently, if you look at the answers in Stack Overflow, many of them are much longer than "change that line to something else" type of answer. Many good answers here really try to explain the reason that caused the problem and many alternative suggestions. They are more like blog entries than classic answers found in forums. This is what makes Stack Overflow a unique Web site. Those answers can be useful for a lot of people, not just the OP.
As a consequence, I believe any feature that encourages asking arbitrarily long questions and make the OPs think less before asking is completely against the spirit of Stack Overflow. It would no longer be a knowledge exchange platform but place to troubleshoot specific problems, which in my opinion, is no fun at all.
I think if you're posting a zip file of code for a question you're posting far too much.
Questions should be limited to specific problems or functions in your application so that the error can be readily seen and fixed by other members. I know I definitely wouldn't go digging through multiple files of code to try and solve an issue, but that's just me.
SO allows a substantial amount of code to be posted. In all honesty, if you're finding the limit to be too little, you're probably not getting close enough to your problem before posting your question.
Many people, not accusing you, ask questions like "What's wrong with this?" and then plaster 100 lines of code into their browser (many times un-tabbed). Try not to be that person. Instead, use your error-reporting to determine what problematic section should be copied. That, or ask a more general question about your issue and extract a solution from the answers.
I'm actually a bit surprised by the amount of negative emotions towards this in general... As Mehrdad pointed out, Stack Overflow is a great knowledge exchange platform. I completely agree. It is an excellent knowledge exchange platform. But why must we limit knowledge transfer to text?
The ability to upload supporting docs/code/images/etcetera to questions and answers is definitely a limitation of the overall SO experience. As Jonathan pointed out, questions that are along the lines of "hey whats wrong with these 200 lines of code" are going to be frowned upon. These questions will be met by down-votes and folks asking what the specific issue is. If someone were to post a project in a zip file and say "whats wrong with my project, it doesn't work"), it'll be met by huge resentment with downvotes, negative comments, etc.
So what do we lose by folks posting some zip files with project code in them? Do we stand to be negatively affected more by that or will our overall experience be improved? I certainly don't think it would be more negative and having this feature would only help some folks and make answers a bit more robust.
When questions exhibit more than a dozen lines of code, I switch to another one. Digging the code for finding bugs is my real life job, and I am good at it because I have spent time for learning the context. Getting into that kind of learning curve is not something I expect from Stackoverflow.
As a potential answerer, I expect from Stackoverflow that the OP has already isolated his bug and is able to present its essence to the community.
As a potential asker, I expect from Stackoverflow that the essence of the problem I am struggling against has already been exposed and solved. This will never be the case if every problem is flooded with specific context.
I'd like to approach this from another angle.
I spend a lot of time on the Electronics Stackexchange site, and many questions and/or answers there have links to component datasheets on external sites.
Now, I thought that the general policy was that questions and answers shouldn't rely on external sites if at all possible, so that if the external site went down / went through a restructuring, the question or answer was still complete and valid - hence the enforced use of imgur to host images.
Now, being able to attach the datasheet to the answer instead of referring to an external site must surely be a bonus to the longevity of the content in general.
I agree that uploading whole projects, or big code files is a no-no as this doesn't add any value to the content, but being able to attach files with information in to which the answer refers instead of relying on the data still being on an external site 6 months down the line has to be a big yes point.
Maybe it should only be allowed for answers, and not questions, and maybe for people with more than a certain threshold of reputation.
I understant there are 10's of good reasons against uploading code files, however: what if it's the answers that require some uploads?
I had the perfect code for a utility function that did exactelly what the OP was asking for. Code was 200+ lines, and would probably benefited a lot of people trying strugling with the same formatting problems.
Then you could just answer:
Well, this is the function that I use to format a DataSet into an XML-compliant Office Excel 2007 document: codegoeshere.cs
I would love to be able to upload small 10-15kb human-readable text files.
It is not likely that StackOverflow will implement file uploads into their service. They are trying to discourage people posting files with hundreds or thousands of lines of coding and expecting someone to spend all their time looking for the problem. Instead, S.O. wants people to only post the snippet of code which has problems so that people can easily detect the problem without breaking a sweat and to save server storage space.
However, you do have a good point for programming languages that do not exist in the form of plain text or have to interact with other elements to function, such as the old version of GameMaker (version 8.0 and below, not GameMaker: Studio). If you don't want to hear me brag about GameMaker: Studio, skip the next paragraph.
GameMaker: Studio appears to have a few removed object actions from my experience. Some actions were unknown when I opened up an object in a project file. I find it a bit slower and harder to use than V8.0.
Unlike GameMaker: Studio, where you can paste the code for certain parts of a project, GameMaker files cannot be simply viewed as readable plain text and normally problems are hidden in different parts of the file than what you think.
If you want to give people access to the files that have problems, which you should only do when you really need to, consider file sharing services like DropBox or Google Drive. While Google Drive gives you 15GB of free storage while Dropbox only gives you 2GB free, Dropbox does not care about executable files where as Google Drive will try to stop you in case of it being a virus.
Before I go, don't ask people to download the program you used to create the project file. I learned that the hard way.
EDIT: The words in italics is what I added.
I've read a couple of the responses falling on the side of the argument that uploading code might be a bad thing.
Configuring and building projects can be a difficult task, especially for beginners - and sharing a Visual Studio solution may be the only way readers can determine the cause of the problem.
In short, I think uploading would be a great feature.
Youtube can store and serve all that video, so what's a few source code files by comparison?! Isn't that what the Internet's all about?
I take onboard that there are free hosting sites that specialize in hosting files, but providing a git / SVN compatible interface to SO to allow users to upload files or projects would greatly add to the quality of Stack Overflow. IMHO.
You can use http://pastebin.com/ or GitHub Gist for long snippets and http://imgur.com/ for sharing images.
No one wants to dig through an entire project to find the problem but sometimes when i post a question i think the problem lies in one part of my code but it really is something else entirely. It would be nice to be able to say here's the relevant code but here is the full file just in case my problem is in a different part. If we narrow the scope to including one file not an entire project i think is a perfectly acceptable thing to do. it should not necessarily be hosted on stack overflow but i think posting a link to the file instead of dumping it all into the question is a much better approach.