|
dwazegek posted:I have a colleague who also does stuff like this. For whatever reason, he refuses to use return anywhere, except the last line of a method. This frequently results in methods with absurd amounts of indentation, or stuff like this: It's an application of the Single Function Exit Point philosophy, with which I don't agree. I think it's good for some issues, especially resource management, but largely you want to use RAII for that anyway, and code can get very messy if you can't bail out early (goto, anyone?).
|
# ¿ Mar 21, 2008 18:50 |
|
|
# ¿ Apr 29, 2024 19:08 |
|
rotor posted:When I used to work in the build department, I inherited some real doozies. The build scripts were giant shell scripts running under MKSTools. Probably half of the code we compiled was generated by a process I won't pretend I even came close to understanding. There was a lot of necessary complexity because we built for a shitload of different platforms, but one thing really stuck out. It blows my mind that anybody that would know how to do that would actually do it.
|
# ¿ Mar 27, 2008 21:22 |
|
such a nice boy posted:Dude, whitespace changes can be incredibly annoying, and sometimes autocorrect functions don't work well. The horror... the horror. - Col. Kurtz, ~1970
|
# ¿ Apr 4, 2008 09:00 |
|
chocojosh posted:In all seriousness then, how would you encode N different options that can be on simultaneously? I always assumed the bitmask would work (and I would go so far to say that it is a simple and clear solution that should be efficient enough for small cases, n <= 8 or n <= 32). std::vector<bool> AFAIK is almost always implemented as a bitfield that uses proxy objects to modify its 'bool references'. I doubt that the 31 bits you save per bool really add up to anything significant, but it's a simple solution at least.
|
# ¿ Apr 24, 2008 21:04 |
|
chocojosh posted:Alright, so then you also second the bitmask suggestion (which means I'm not totally crazy). No, that's just a viable alternative if you're retarded and don't want to go with the prime factorization solution. Why would you use dynamic memory at runtime when you can quickly run through a sieve of eratosthenes and get some valid, unique flags?
|
# ¿ Apr 24, 2008 22:35 |
|
Flobbster posted:I'm surprised nobody has mentioned this advantage yet. If I remember my Win32 API correctly, there's a window style called WS_EX_THICKFRAME. But it doesn't let me control the degree of thickness. WS_EX_GIRTHYFRAME will do that too.
|
# ¿ Apr 25, 2008 16:16 |
|
GCH is leaking!
|
# ¿ Apr 26, 2008 01:56 |
|
yaoi prophet posted:Haha, I love the 1/2 being 0%. Some of the int-float-int-float conversion that I see sometimes is sickening. The compiler really should be stricter when you're going to 'promote' and lose data .
|
# ¿ Apr 28, 2008 02:06 |
|
ShoulderDaemon posted:Why? If you're about to dereference a pointer in a dynamically-allocated structure, then there's a very good chance you've lost memory locality and are about to stall on memory access anyway, so the check is essentially free. It inflates code size slightly, so I wouldn't do it inside a tight loop, but I'd be trying not to traverse large structures in a tight loop anyway. Because as expensive as LHSes are, mispredicted branches can still hurt quite a bit on modern architecture. Remember, the fastest and least buggy code is the code that's not run, or ideally never written.
|
# ¿ May 14, 2008 09:57 |
|
TSDK posted:Hungarian notation is an old technique that has no place in modern C++ programming, but there are one or two odd exceptions which are either genuinely useful, or are a strange hang-over. Well, not really. It was originally intended to give context to the variable's usage, not type. So you might prefix something with 'idx' or some such to indicate that it's an index, but you wouldn't put the type in the variable name since that's just stupid.
|
# ¿ Oct 4, 2008 07:35 |
|
tripwire posted:God I hate hungarian notation. How in the hell did anyone ever think it was a smart idea Its original intent - to document the purpose and usage of the variable - was a great idea. Somehow it got perverted into being only the type, which is obviously useless.
|
# ¿ Dec 29, 2008 04:45 |
|
tripwire posted:At the risk of opening a can of worms, its retarded in either form. You are only adding more headaches for yourself later on. I'm not some hungarian evangelist - I'm just saying its current usage is unambiguously worthless, but its original intent had potential to make more readable, self-documenting code. Not that it matters since most of us don't get to decide on the coding style for our particular codebase anyway.
|
# ¿ Dec 29, 2008 06:30 |
|
geetee posted:There is no way &1 even compiles (right?) so I don't understand what this entire fiasco is about. The logical operator "AND" requires two ampersands, not one. I'm surprised none of your IDEs warned you about this. It's just a segfault waiting to happen. Just use modulus and move on. There's more than one kind of 'AND'...
|
# ¿ Jan 7, 2009 16:09 |
|
No Safe Word posted:*whoooosh* I guess I would have been more suspicious of a fakepost if it was funnier? I.D.K.
|
# ¿ Jan 8, 2009 05:36 |
|
|
# ¿ Apr 29, 2024 19:08 |
|
code:
Just saw this at work, someone should tell this chucklefuck that there's only one sequence point here.
|
# ¿ Jan 8, 2009 16:11 |