Showing posts with label stack-overflow. Show all posts
Showing posts with label stack-overflow. Show all posts

Monday, November 12, 2012

Slashdot Descriptors Feature For Stack Overflow

You probably already know about Stack Overflow, a mostly nice Q&A site. There are still some problems with it, in my experience.

One problem is getting down-voted without explanation. Has happened to me lots of times, so you get used to it, you even expect it (without submitting knowingly bad questions, to be clear). But it's still confusing.

There is a solution, that would help at least some: down-vote buttons should be categorized. We know and love this feature on Slashdot: moderation descriptors. The complete list seems to be: normal, offtopic, flamebait, troll, redundant, insightful, interesting, informative, funny, overrated, or underrated (from http://en.wikipedia.org/wiki/Slashdot).


The negative ones are: offtopicflamebaittrollredundantoverrated. 

The positive ones are: insightfulinterestinginformativefunnyunderrated.

I haven't thought up good descriptors for Stack Overflow, but why not reuse the canned answers used when a question is considered so bad that it gets deleted? Maybe: 'unclear', 'shopping-list', 'clearly-homework', 'submitter-should-have-tried-harder', et cetera.





Wednesday, September 5, 2012

Stack Overflow


Some exercises. Exercise 1. What is wrong with this piece of code: 
try {    runSubs(objectFieldValue);
} catch (java.lang.StackOverflowError e) {
   System.out.println("[StackOverflowError] objectFieldValue: " + objectFieldValue);
   throw e;
}
Answer: the println() will of course overflow the stack too. (EDIT: seems it was the code I was debugging that caused this; i.e. the toString() contained some circularity. I wrote some simple code where a similar print statement seems to _not_ overflow. Although it should, the '+' gets compiled to a call to a string concatenation/append, doesn't it?)

What is wrong with instead doing just:
try {   runSubs(objectFieldValue);catch (java.lang.StackOverflowError e) {
   throw e;
}
...and setting a breakpoint at 'throw e'?

Answer: Well, nothing wrong per se; but you won't be able to see anything in the (Eclipse) debugger: it simply can't handle those stack depths. Maybe if you set a small stack allocation, but then you may get false positives.

So. If you didn't know it before, debugging StackOverflowError is a pain.

One might of course use some flags or counters or stuff, and handle the stack overflow further out. Cumbersome.

If you've got any good ideas or solutions, please don't hesitate to comment.