What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 134 Stack Exchange communities.

I would like to see an ehhancement to an answer i.e. in how a solution is applied on Stack Overflow to someones existing code example/s. Maybe right next to the users suggestion where you increase their score there is a button that says, "Apply This Solution" to the original question. When clicked the solution would show the chosen users code's solution with the suggestion. On the popup it then allows you to click "With Solution" and "Without Solution" so you can see the difference and maybe also see different resulting output as a secondary feature.

The reason this would be useful is because there are a lot of new programmers out there and this would attact a larger user base to see what the results looked like before and after. In addition, this type of solution would allow seasoned developers to explain complex behavior allowing more detailed explanations to be utilized in a with/without scenario which would greatly include a larger community of users and differentiate the answers willing to go in greater detail. This would also differentiate stack overflow more from other types of q/a sites with better code examples.

share|improve this question
8  
We don't need that. A correctly written question already contains the original code. I can't see a reason for duplicating this information in the answer and probably cluttering the correct solution. –  Darin Dimitrov Sep 12 '12 at 14:40
    
Well then we are in different camps of thought, but I think my camp would benefit from it. –  RetroCoder Sep 12 '12 at 15:12
    
This is my pwned moment! Thanks everybody, I cherish your conservative action. –  RetroCoder Sep 12 '12 at 15:26
5  
Since you asked about your downvotes in chat: I'm downvoting this both because it's difficult to understand your writing and because I do not agree that the proposed feature would make the site better. –  Pops Sep 12 '12 at 15:30
    
Ok how would I rewrite it so I can get your up vote? –  RetroCoder Sep 12 '12 at 17:51

2 Answers 2

So if I understand you correctly, given this question:

I want this function to return the larger of two values, but it always returns the smaller one. How can I fix that?

function larger(a, b) {
    if (a < b)
        return a;
    else
        return b;
}

and given this answer:

You have to replace the if statement by

if (a > b)

then it will work.

what you want is a button that applies this change to the actual code in the question, so you can see automatically what the corrected version looks like. Let me know if I misunderstood you.

So assuming that's what you want: apart from the question of whether this is something that's necessary or desirable (I don't think it's either), there are plain technical issues that prevent this.

Very few answers will be of the kind "replace X by Y in the code and it will work", and even fewer will have this in a way that can be understood by a computer (which is obviously a prerequisite for doing something automatically).

The single sentence "Replace the less than by a greater than" means exactly the same thing, and there's no way (at least these days) the computer could understand and automatically apply this plain-language description. And what if you get into territory like "Just move the first variable declaration to the outer scope and make sure that you're importing the quux library before you foo the bar"?

And of course the arguably best answer to the above example question – don't build your own; use Math.max – doesn't fit into the schema at all.

share|improve this answer
    
But your looking at it through the cold eyes of a veteran developer. Not through the young eyes of a new beginner. –  RetroCoder Sep 12 '12 at 17:44
    
Also this should apply to the code section... the <pre>Hey dude I'm code - over here!</pre> –  RetroCoder Sep 12 '12 at 17:48
    
Is there a way I can get your upvote. What would I change? –  RetroCoder Sep 12 '12 at 17:51
    
@RetroCoder Even a beginning programmer should be capable of reading and understanding "replace the if statement by if (a > b)" –  David Z Sep 12 '12 at 20:37
    
You know and I know in this complex world we live in your case is not always valid. Each pre code can easily be iterated through and displayed or add your own solution. If I have time I'll create an example in a simple mvc4 layout. –  RetroCoder Sep 12 '12 at 21:35

I don't think such a requirement would come up often enough to warrant such a impractical non-trivial solution.

If you consider the types of questions that are preferred on StackOverflow, not many would actually benefit from such a feature. And for those that do, users can already use sites like ideone, jsfiddle and the likes to great effect to show the results of running the code they suggest.

share|improve this answer
    
Anyway I can make a change your ideas to get an upvote? –  RetroCoder Sep 12 '12 at 17:52
1  
A quick demo showing that it can be done reasonable well for a typical Stack Overflow post may convince me. –  Shawn Chin Sep 12 '12 at 19:41

You must log in to answer this question.

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