Skip to main content
9 events
when toggle format what by license comment
Oct 23, 2023 at 14:56 comment added gnasher729 In C you could write #if SimpleButSlowCode <simple but slow code> #else <equivalent very complicated and fast code doing the exact same thing> #endif. If you #define SimpleButSlowCode 1 then your program should run identically, just slower.
Nov 3, 2012 at 17:28 comment added Donal Fellows Occasionally, a reference to a paper that explains the basic algorithm is nice (when it's otherwise utterly obscure). Sure, it might be obvious to someone who studied Analysis at PhD level, but that's miniscule proportion of the population of programmers!
Nov 2, 2012 at 10:38 comment added yannis @kevincline "WHY? WHY? WHY?" <- actual comment in a previous project ;)
Nov 1, 2012 at 17:03 comment added kevin cline When I see complicated code, I want to know WHY. Usually there's no reason except a lack of clarity from the original author. Occasionally it is complicated to work around bugs in underlying services, or for performance. In those cases a comment is invaluable.
Nov 1, 2012 at 14:20 comment added Izkata HOW is, on very rare occasions, necessary. Exactly once in the past year and a half, I had to do something rather obscure and ended up putting the url to a StackOverflow question in the comment, which explained HOW that code works (yay language edge cases) using several paragraphs with code examples...
Nov 1, 2012 at 12:19 comment added Superbest I agree mostly, except for "WHY is the only question worth answering outside of a few bizarre fringe scenarios". I don't think the bizarreness threshold is that high - sometimes a given block of code is just complicated and takes time to comprehend, and having a brief comment saying "this code basically does X" can help navigate code and mentally break it into components when you revisit it after forgetting everything (or when other people visit it the first time). Yes, you can refactor and make a nicely named method, but sometimes this ends up adding complexity to the code needlessly.
Nov 1, 2012 at 6:10 vote accept Assad Ebrahim
Oct 31, 2012 at 22:24 review First posts
Oct 31, 2012 at 22:36
Oct 31, 2012 at 22:07 history answered Michael CC BY-SA 3.0