|
ymgve posted:Also bad code: Using floating point numbers for representing money. I seem to recall the MONEY type being specially designed to avoid that sort of stuff, but I'm not 100% certain
|
# ? Dec 4, 2009 11:52 |
|
|
# ? Jun 5, 2024 04:07 |
|
yaoi prophet posted:I seem to recall the MONEY type being specially designed to avoid that sort of stuff, but I'm not 100% certain That only works if your calculations are using the MONEY type and that your code contains lots of comments about rounding. Zombywuf fucked around with this message at 15:05 on Dec 4, 2009 |
# ? Dec 4, 2009 11:55 |
|
yaoi prophet posted:I seem to recall the MONEY type being specially designed to avoid that sort of stuff, but I'm not 100% certain
|
# ? Dec 4, 2009 13:07 |
|
Mill Town posted:DB DB DB... Th-th-th-that's all folks! I chuckled. I think us PHP users have to find humor where we can
|
# ? Dec 4, 2009 16:38 |
|
xarph posted:This one is tame, except it does it for EVERY. SINGLE. PROMPT. in a 100+ step installation checklist. Our install script* broke again on the latest build from Japan. Yes, I know it's the leading space that somehow got in there but the error message amused me. *text file full of carriage returns** with the occasional "no" **does still using this term mean I'm old?
|
# ? Dec 5, 2009 00:16 |
|
What's that, gramps? Some sort of newline?
|
# ? Dec 5, 2009 00:20 |
|
xarph posted:Our install script* broke again on the latest build from Japan. images is 404ing for me, gently caress waffleimages
|
# ? Dec 5, 2009 12:10 |
|
A consultant sent his source code to me recently, and I had the pleasure of rewriting it. I don't think this guy knows about the standard library.code:
code:
code:
code:
I'd caution you against using any of this code in your own programs, as it's under copyright.
|
# ? Dec 7, 2009 07:47 |
|
sund posted:
Even ignoring what's in the standard library (I don't know poo poo about C++ either) he managed to make the function name by itself more characters than doing it the "hard" way instead of just calling it "toRads" or something.
|
# ? Dec 7, 2009 08:58 |
|
Blue Footed Booby posted:Even ignoring what's in the standard library (I don't know poo poo about C++ either) he managed to make the function name by itself more characters than doing it the "hard" way instead of just calling it "toRads" or something. What? That's not a coding horror at all, he was just being descriptive. The benefits of functions and abstraction are far greater than saving keystrokes.
|
# ? Dec 7, 2009 09:02 |
|
sund posted:
Blue Footed Booby posted:Even ignoring what's in the standard library (I don't know poo poo about C++ either) he managed to make the function name by itself more characters than doing it the "hard" way instead of just calling it "toRads" or something. I love it when people try to post coding "horrors" and it backfires. I think embedding *180/PI or /180*PI (or /PI/180 or *PI/180) everywhere is more of a coding horror than the cited code, which isn't a horror at all.
|
# ? Dec 7, 2009 12:59 |
|
I've come to believe that the majority of programmers in business think that the standard libraries stop with printf() and cout.
|
# ? Dec 7, 2009 12:59 |
|
Mustach posted:I've come to believe that the majority of programmers in business think that the standard libraries stop with printf() and cout. You just don't know where those other libraries have been, man.
|
# ? Dec 7, 2009 16:55 |
|
That Turkey Story posted:What? That's not a coding horror at all, he was just being descriptive. The benefits of functions and abstraction are far greater than saving keystrokes. Yea I agree. I think long but descriptive function/variable names are very good for readability, even if they loose some stupid "elite" factor. With modern IDEs especially this is not a big problem as most have nice auto-complete features, so you don't even need to type more, but spend less time trying to figure out what random abbreviation meant.
|
# ? Dec 7, 2009 17:23 |
|
Ledneh posted:Out of curiosity, Broken Knees Club, did you ever find out what makes GCC die without this define in your codebase? We just removed it one day, and it worked. Still don't know what the gently caress
|
# ? Dec 7, 2009 19:17 |
|
That Turkey Story posted:What? That's not a coding horror at all, he was just being descriptive. The benefits of functions and abstraction are far greater than saving keystrokes. And if they change the definition of a radian then it only needs to be changed in two places!
|
# ? Dec 7, 2009 23:34 |
|
CanSpice posted:And if they change the definition of a radian then it only needs to be changed in two places! no one argued that this was a good reason for doing it but if you can't see why rads = degreesToRadians(degrees); is better in every way than rads = degrees/180*PI; then the coding horror, it's you
|
# ? Dec 7, 2009 23:47 |
|
CanSpice posted:And if they change the definition of a radian then it only needs to be changed in two places! This can actually happen if you're working with a library that defines Pi with multiple levels of accuracy! (Both .NET and XNA have their own Pi)
|
# ? Dec 8, 2009 01:15 |
|
Broken Knees Club posted:We just removed it one day, and it worked. Still don't know what the gently caress My totally unbased guess, it had to do with the addresses reserved in the memory for the variable. What happened when you changed the value of the define? It also just didn`t work at all? If leaving that didn`t had any side effects, I would just leave it, if not for the phrase itself.
|
# ? Dec 8, 2009 01:23 |
|
HardDisk posted:My totally unbased guess, it had to do with the addresses reserved in the memory for the variable. If the flag was not present in one specific file in that exact form, GCC segfaulted. We were trying to remove it because it was literally the only file left over from an obsolete and long-gone library.
|
# ? Dec 8, 2009 01:37 |
|
Ryouga Inverse posted:no one argued that this was a good reason for doing it but if you can't see why rads = degreesToRadians(degrees); is better in every way than rads = degrees/180*PI; then the coding horror, it's you From a readability point of view it makes complete sense, yes. All you need is to slip once and suddenly your radians are off by 5% because you've hit 170 instead of 180. I do the degreesToRadians() everywhere, except usually I use a constant D2R or something like that.
|
# ? Dec 8, 2009 02:40 |
|
Guys you should be using ruby so you can just monkeypatch a to_radians and to_degrees functions onto int.
|
# ? Dec 8, 2009 02:43 |
|
king_kilr posted:Guys you should be using ruby so you can just monkeypatch a to_radians and to_degrees functions onto int. I see your clever ruse.
|
# ? Dec 8, 2009 03:25 |
|
Broken Knees Club posted:I see your clever ruse. No clever ruse intended . I seem to recall rubies integer class isn't actually named that though, is that the alleged ruse?
|
# ? Dec 8, 2009 04:28 |
|
king_kilr posted:No clever ruse intended . I seem to recall rubies integer class isn't actually named that though, is that the alleged ruse? No one sane uses an integer for radians.
|
# ? Dec 8, 2009 04:31 |
|
king_kilr posted:Guys you should be using ruby so you can just monkeypatch a to_radians and to_degrees functions onto int. C# has extension methods that can do that.
|
# ? Dec 8, 2009 04:34 |
|
dis astranagant posted:No one sane uses an integer for radians. Doh. I'm going to go somewhere and pay penance for my insanity.
|
# ? Dec 8, 2009 04:47 |
|
dis astranagant posted:No one sane uses an integer for radians. #define 2PI 6
|
# ? Dec 8, 2009 05:03 |
|
dis astranagant posted:No one sane uses an integer for radians. Just monkey-patch Integer to be fractional, problem solved
|
# ? Dec 8, 2009 05:05 |
|
Dijkstracula posted:sure, if you care enough about accuracy to get within 25 degrees of the correct answer, then go right ahead and use those extravagant floating point operations π should have been defined as twice what it is. You see 2π way more often.
|
# ? Dec 8, 2009 05:06 |
|
Pardot posted:π should have been defined as twice what it is. You see 2π way more often. Maybe my brain is just not working tonight, but where exactly do you see it regularly? Everything that uses Pi that I can think of (area, circumference, radian conversion) uses Pi, not 2*Pi.
|
# ? Dec 8, 2009 05:13 |
|
c = 2*pi*r reduced h = h/2pi omega = f*2pi A shitton of other physics stuff, commonly anything where you're thinking in terms of a full revolution
|
# ? Dec 8, 2009 05:17 |
|
The integers are dense modulo 2pi so you can achieve arbitrary trigonometric precision.
|
# ? Dec 8, 2009 08:25 |
|
I interviewed a guy a while back who claimed in his resume that he'd written 500,000 lines of code. The interview went well enough so we asked for a code sample. This was the first function that I looked at: code:
|
# ? Dec 8, 2009 20:16 |
|
floWenoL posted:I love it when people try to post coding "horrors" and it backfires. Glad I could provide some amusement! I can't imagine anyone having to think about what toRads does, but I freely admit to being an awful scrub. Blue Footed Booby fucked around with this message at 22:35 on Dec 8, 2009 |
# ? Dec 8, 2009 22:31 |
|
Clearly degrees and radians ought to be given in separate types so that trigonometric functions can be overloaded on them.
|
# ? Dec 8, 2009 23:32 |
|
Vanadium posted:Clearly degrees and radians ought to be given in separate types so that trigonometric functions can be overloaded on them. Or use boost.units
|
# ? Dec 8, 2009 23:45 |
|
Grazing Occultation posted:He's returning a const reference to a dynamically allocated std::string object. Guaranteed memory leak with memory that didn't need to be allocated in the first place! code:
|
# ? Dec 9, 2009 02:02 |
|
No, because that would be deleting the stack-allocated const reference which has the same value as the leaked pointer.
|
# ? Dec 9, 2009 13:01 |
|
|
# ? Jun 5, 2024 04:07 |
|
No, it would not, it would be perfectly fine, except nobody expects to have to do that when given a const reference, or any reference at all.
|
# ? Dec 9, 2009 13:10 |