I came across a question where a comprehensive example would be very useful. So I wrote an example program showing one way to solve their problem.
My problem is that when I was done creating it, and testing to make sure it worked, it was over 400 lines in 18 files. My example included source code, header files, and scripts for building the example in a variety of circumstances.
It's a working and tested, so it's of huge value to illustrate the tricky solution, but because it's all there, my response was huge! Is there a better way of posting my code dump?
I guess there isn't a current "best way" to include a large chunk of code, so I made this a feature request and tried to add some ideas.
Perhaps code entries that are longer then a certain number of lines, or ones that have been specifically marked could initially be displayed as "collapsed", and someone could expand them if they want to see them?
Or maybe, like attaching images, users with enough reputation could attach an archive of files. They could be displayed as "attached code" (initially collapsed also).
Some problems have simple answers that unfortunately touch disproportionately large parts of the program, or can be solved in slightly different ways depending on the environment. I feel that stackoverflow needs a way of capturing these large solutions. Sometimes, they're large chunks of code. In my case, the code was small, but there were many files.
Using github or a similar code repository is great, but we risk linkrot (even for big guys like github) and loose the community editing, commenting, and voting abilities.
I understand the problems that could come from with people dumping whole "I can't get this to work" packages, but surely we already have a solution for that in moderation.
I'm starting to see that this may have been already addressed in posts like
- Ability to upload code samples (ie: entire zipped project)?
- Please add a system to allow file uploads attached to questions and answers, and
- Uploading code for small projects
If you feel this a dupe, I'm open to having it "closed as already addressed"