6 ms·
What is with all this contrarianism against basic software best practices in tech circles these days? First the thread about how great copy pasting was, and now
by HumanDrivenDev 8y ago
What is with all this contrarianism against basic software best practices in tech circles these days? First the thread about how great copy pasting was, and now people praising the use of global variables. What's next - goto advocacy? Segmentation faults as the preferred error handling technique?
- jimjimjim 8y agogotos are fine. people are tired of guidance being turned into rules and then into dogma.
- notacoward 8y agoI wouldn't say gotos are fine, but they're sometimes better than alternatives. I'll take a "goto" to an error-cleanup cascade at the end of a function over ten nested three-line functions, a mini state machine, or lots of little state variables (the most common alternatives) any day. If the language has destructors or deferreds or anything else that automatically triggers when leaving scope that's probably even better, but some older languages - notably C - don't, so dogma often leads to worse alternatives.
- emerged 8y agoI've wondered about the parallels between globals in code and open door immigration policies, etc. The left/right political axis may conceptually span across more than just politics and the current tech climate is more left.
- notacoward 8y agoBoth global variables and gotos are bad. On the other hand, the contortions some people go through to get the same effect without using the actual construct are often worse. That's the real point. Design and implementation decisions should be judged based on what they do, not their superficial appearance. If code is littered with singletons and often-thrown exceptions, it's worse than if the programmer had been honest about using globals and gotos.
- a1369209993 8y ago> goto advocacy? If you actually encounter a situation where more self-documenting constructs don't work, sure, but usually that only happens due to deficiencies in your programming language. > Segmentation faults as the preferred error handling technique? Actually you should use SIGABRT, not SIGSEGV; see self-documenting. Considered harmful assertions considered harmful.