|
code:
|
# ¿ Mar 21, 2008 03:22 |
|
|
# ¿ Mar 29, 2024 12:04 |
|
Avenging Dentist posted:Also my favorite is still I've done that occasionally for writing test code (along with "#define class struct" ) but, yeah, finding it in something that's about to ship always amusing.
|
# ¿ Mar 21, 2008 20:22 |
|
Factor Mystic posted:I'm skeptical that goto has a valid place outside of perhaps some simple scripting. I challenge you to show me a valid example of goto use in modern object oriented code. Two that come immediately to mind are breaking out of nested loops in C/C++/C# and cleaning up/freeing resources upon failure in environments that do not provide exceptions. I've used them when I've written parsers too as there was no other clear way of providing similar functionality. Linus Torvalds addresses the use of "goto" in the Linux kernel with some good points here. Yes, they can turn code into an unreadable mess but, sometimes, they can also make code more readable and more intuitive. edit: I'm inclined to think that people who believe that "goto" has no place in modern programming languages have not been programming for long enough.
|
# ¿ Jun 15, 2008 01:43 |
|
In C# you can use System.Diagnostics.Debugger.Break(). C/C++ often have platform-specific ways of triggering a debug break point, and on PCs there's always interrupt 3. I'm not sure about other languages but they often have their own ways of breaking into the debugger
|
# ¿ Jul 8, 2008 21:52 |
|
Ryouga Inverse posted:Yeah, the SDET we hired is one of those. Really? Global variables? How heinous! What's next, is he going to say that "goto" actually makes sense in certain situations?
|
# ¿ Dec 5, 2008 19:45 |
|
I found a coding horror today:Zombywuf posted:Get a better compiler or write it in asm. If you're second guessing your compiler's interpretation of instruction cache usage, you have a problem. If you don't have a healthy paranoia of the code your compiler generates then you probably haven't been developing for very long. Not every platform has the luxury of being able to switch to a potentially better compiler either, not to mention that writing it in assembly because of it's C/C++ line count is just dumb.
|
# ¿ Dec 23, 2008 22:21 |
|
Zakalwe posted:That's not a horror, that's an extreme optimisation for an operation done a lot in many renderers. Low accuracy bitwise hack combined with one Newton-Raphson iteration. It's a coding horror for any x86 (post-1999) or PowerPC based computer.
|
# ¿ Jan 7, 2009 18:58 |
|
julyJones posted:I wrote some C# code last week that made me laugh later: There are some people that shouldn't write about programming. Jeff Atwood is one of them. Relying on the garbage collector to free resources other than memory (sockets, database connections, etc.) is pretty dumb because the behaviour of the GC is determined only by the state of the heap. If you run out of space in the active portion of the heap it will collect but if you depend on finalizers to clean up other resources you can easily run into problems where the resource is exhausted and the GC hasn't yet run. The GC doesn't care if you've hit your connection limit or whatever because it's just monitoring heap activity. If you're using unmanaged resources (sockets, files, database connections, etc.), dispose of them after use and don't let the GC clean up after you if you want consistent performance and behaviour.
|
# ¿ Jan 17, 2009 22:15 |
|
julyJones posted:That is my thinking as well, so I disagree with the article a bit. It was funny though to see code almost identical to mine appear on a WTF-type blog. Yeah, that's exactly what using does, it's pretty handy.
|
# ¿ Jan 17, 2009 22:49 |
|
Erasmus Darwin posted:
A coworker stumbled across this and forwarded it to me: code:
|
# ¿ Feb 12, 2009 06:25 |
|
Flobbster posted:The "not" operator is a redundant feature? No, but "unless" certainly is.
|
# ¿ Apr 12, 2009 16:51 |
|
pokeyman posted:What's the difference? Isn't "unless(statement)" identical to "if (!(statement))"? Sorry to break it to you but "unless" is redundant as it does the same thing as using if with a negated condition but saves no typing and some (like myself) might even say it does nothing to improve code clarity or comprehension.
|
# ¿ Apr 12, 2009 21:19 |
|
Ryouga Inverse posted:"If not (whatever) do this" is less clear to you than "unless (whatever) do this"? I mean, one of them is a common English construct. There are many common natural language constructs that have no business whatsoever belonging in a programming environment. In my case I find "unless" somewhat foreign (and less clear than if-not) because I'm largely steeped in C#/C++. If you can't figure out how to negate a boolean expression and require keywords like "unless" in your language then you probably aren't going to be a successful programmer. pokeyman posted:
It's simple - redundancy breeds inconsistency and inconsistency leads to incomprehensible code bases. Probably the worst example of this is Perl because there are so many ways to express the same functionality. Each programmer has their own idea of what they like, one may use "if (!condition) { blat }", another "blat if (!condition)", a third may use "unless (condition) { blat }", and a fourth "blat unless (condition)". When I'm working in an area of code that other people are working on and I come across something that isn't what I would think as idiomatic my mind is divorced from finding out what's going on in the code temporarily to figure out why the pattern was chosen. This is where coding standards come into play -- they help enforce consistent styles and practices so that people only really need to think about the problem at hand rather than why certain syntactic elements in the code were chosen. But if your coding standard dictates which of the conditional styles above are to be used then you've eliminated the need to have the alternate methods at all. If this is the case then redundancy has lead to these language extensions being worthless.
|
# ¿ Apr 13, 2009 00:18 |
|
ymgve posted:Is this actually enough for a computer to be Turing complete? Yes.
|
# ¿ Apr 13, 2009 00:44 |
|
Zombywuf posted:Nothing wrong with writing their own STL implementation for consoles, apart from STL implementations being a dime a dozen. Or with writing their own STL for performance reasons (the EASTL doc reeks of crazy though). Instead they decided to use their own array object for compatibility reasons? Paul is a genius, and you couldn't be more wrong on everything else. There isn't any "crazy" in EASTL beyond what has been required and requested by internal game development teams.
|
# ¿ Jul 1, 2009 01:23 |
|
I have no problem with #if 0 ... #endif but it's nearing horror status when it gets checked in.
|
# ¿ Sep 11, 2009 05:01 |
|
Flobbster posted:This is considered safer in languages (like C and Objective-C, assuming by your example), where any expression is allowed inside an if clause. It's meant to prevent errors caused by accidentally using = instead of ==: What compilers these days don't warn about assignment in a conditional?
|
# ¿ Feb 7, 2010 18:48 |
|
Encountered today:code:
ehnus fucked around with this message at 04:32 on Apr 14, 2010 |
# ¿ Apr 14, 2010 01:49 |
|
A A 2 3 5 8 K posted:Always make backward-incompatible changes after consulting a group of strangers on the internet but before consulting your team. That wasn't a question for this thread, I guess my original wording wasn't clear enough. I know who made this change but they are no longer with my company.
|
# ¿ Apr 14, 2010 04:36 |
|
|
# ¿ Mar 29, 2024 12:04 |
|
I found this method in a C++ mutex class the other day:code:
|
# ¿ Dec 19, 2013 06:55 |