5

@ThomasOrozco recently posted asking for more feedback about Code and Stack Snippets:

If you have more general feedback regarding Stack Snippets, or suggestions, please consider making it a separate question and linking to it in a comment here.

So here it is: I would love to have the ability to quickly copy 2+ classes from a question I'm trying to answer into files without having to select the entire code block, figure out where a class begins and ends, and so forth.

  1. Primary request - figure out a way to have the interface encourage users to separate multiple classes / files clearly
  2. Secondary request - include a non-visually-invasive select all / copy button (or even a download file button) for each section of code.

Anything that would speed up the process of extracting MCVEs from a question into my IDE would be great!

6
  • Hm. Why would you want to put different classes in separate files for an MCVE? Now if it involves subtleties of properly including headers / having files in different languages, then it might just possibly start making some sense. Jul 13, 2015 at 22:07
  • @Deduplicator I'm talking about copying and pasting someone else's code. I agree I try to keep my own MCVE's to one class / file, but not everyone does.
    – durron597
    Jul 13, 2015 at 22:08
  • 3
    @durron597 If I understood deduplicator right, his point is that you can put different classes in the same file (at least for some programming languages) without needing to put them in separate files. Therefore, why bother putting them in separate files just for someone's question? If you've got so much code that you need to organize things into different files, then it's probably not satisfying the M in MCVE.
    – mason
    Jul 14, 2015 at 2:21
  • @mason It's annoying to have to add the word static to every one of somebody's classes, that's the whole point. Maybe in some languages it doesn't matter, but Java it does.
    – durron597
    Jul 14, 2015 at 3:24
  • While the goal is good (export to IDE) I don't think this is a good way of going about it. If you had a download button, you'd need to determine the correct file type to provide. In a question tagged HTML and JS, should you provide the file with a .js or a .html extension? What's stopping you already from copying and pasting? I think something like GitHub's Gist (example) would make much more sense.
    – mason
    Jul 14, 2015 at 3:36
  • @mason Feel free to suggest that as an answer
    – durron597
    Jul 14, 2015 at 3:38

2 Answers 2

2

I'm leery of this idea.

So let me describe my standard flow with Java classes. If I see a question that has an MCVE, I usually am capable of copying and pasting it (with slight modifications to the visibility of the classes) to a special Formatting class that I have specifically for Stack Overflow. This means that in general, no matter what they've created, I'm usually capable of running their code in short order.

My flow differs depending on whether or not there's a framework I have to use (Rails, Flask, Spring, etc), but by and large I'm able to get by with a simple base file.

There have been very few occasions in which there has been a question that's not too broad and has a ton of code in it which I want to give an answer to. If there is a ton of code, it's really not that minimal, and there could be a lot of places where there's a problem, so it's not ideal to fire up my IDE to debug one problem and run into six.

1

An alternative way of implementing an export-to-IDE feature would be to implement functionality similar to GitHub Gists. Here's GitHub's description of gists:

Gists are a great way to share your work. You can share single files, parts of files, or full applications. Every gist is a Git repository, which means that it can be forked, cloned, and manipulated in every way.

Basically, a gist is a set of 1 or more files that you can share with others, usually used for short snippets of code that don't warrant a full blown Git repository. Gists can be interacted with via a Git client, or you can download the files as a .zip file. Here's an example of a Gist (not mine).

What's more, other people can fork your Gist, allowing for an easy way to provide solutions. How far we take this idea is up for debate. I really like GitHub, and I think it'd be cool to see some partnership between Stack Exchange and them. If that's not possible, then I think it'd be nice to have the functionality re-implemented here. Basically, a person asking a question is asked to create a Gist. Code in answers can be forked from the original Gist. Suggested edits could even be incorporated from pull requests.

You must log in to answer this question.

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