|
Multiplication is a slow operation:code:
code:
|
# ¿ Feb 6, 2009 10:26 |
|
|
# ¿ Apr 25, 2024 12:07 |
|
UberJumper posted:One more before i go to bed. Holy poo poo that code owns. The horrors I run into are mostly nested #ifdefs. Boring poo poo compared to that. e: Although at one of my earlier coding jobs I had a colleague who loved to use single- and double letter variable names. So stuff like int a = 1; int b = 1; int aa = a + b; Wheany fucked around with this message at 10:43 on Feb 24, 2009 |
# ¿ Feb 24, 2009 10:34 |
|
Richard Noggin posted:
Short loop variables can be descriptive, though. For example using y and x instead of, say, the traditional i and j: code:
Confession: I just made a program last week where I used variables int Δx and int Δy. Because I could. I copy-pasted the delta-character every time.
|
# ¿ Feb 24, 2009 21:47 |
|
code:
But also: The flag is defined and manipulated, but never tested, in device.c. It is declared extern and tested, but never manipulated, in driver.c.
|
# ¿ Apr 8, 2009 11:03 |
|
TSDK posted:Why would you think this is a coding horror? Sure, it's a bit of an old-school way to get a status from a module, but then you are working in C. Well, it doesn't really show from those lines, but there is no need for the flag to even exist in device.c. It pretty much goes like this: code:
|
# ¿ Apr 8, 2009 11:41 |
|
How about "Coding annoyances: post the code that bothers you" I see numbers needlessly defined in hex all the time. E.g. int numberOfApples = 0x05; What's wrong with a simple int numberOfApples = 5;
|
# ¿ Apr 29, 2009 12:27 |
|
quote:There's a bit of controversy going on as to why the passwords were stored in plain text in the first place, with some arguing that it was because of the very large user base. Password hashing was apparently on the TODO list for the future, but that has become a priority now. Now that's premature optimization.
|
# ¿ Aug 4, 2009 07:07 |
|
In a Qt project: A colleague had added two text edit widgets to our UI, but they were hidden before the UI was made visible. They were used for getting the row number from a table view. The table view's activated-signal was connected to a QDataWidgetMapper that set the text edit's value to the row number. Then the text edit's textChanged signal was connected to a custom slot on the UI's parent object. The slot then saved the row number in a private variable. Then when the user presses a button, the button's event handler uses the private variable to recognize what row in the table view is currently selected. The other text edit was used in a similar way, except for another table. Okay, so maybe you don't have a lot of experience with Qt, but I'm pretty sure every framework has a better solution to the problem than "// TODO: ugly hack, needs to be removed"
|
# ¿ Aug 24, 2009 13:35 |
|
Lexical Unit posted:I'll just assume your company routinely hires kindergartners then. I read somewhere that often those coding tests aren't really meant to show how clever you are, just to prove that you can program at all.
|
# ¿ Sep 3, 2009 11:56 |
|
code:
|
# ¿ Oct 2, 2009 10:37 |
|
MrBishop posted:I'd punch someone in the face if I had to maintain that. It's the code equivalent of, "Everything's ok...... NOT!!". If everything is ok on opposite day, do this:
|
# ¿ Oct 2, 2009 15:21 |
|
Fenderbender posted:
That's adorable
|
# ¿ Oct 2, 2009 21:09 |
|
Inverse Icarus posted:http://www.ibm.com/developerworks/java/library/j-jtp09275.html Today I learned the concept of defensive copying. In hindsight it's totally obvious, and I've even thought that doing stuff like Point getPoint(){ return this.point; } is kind of dangerous, but it never occurred to me that I could do a return new Point(this.Point);. Also, I never thought that I should also make a copy of the object passed to my constructor for the same reason. I'm a coding horror
|
# ¿ Oct 6, 2009 08:09 |
|
JOrbisPlayer:code:
And I just realized that it's not an Applet, but a JApplet, so it's at minimum Java 1.2, which definitely has lastIndexOf().
|
# ¿ Oct 19, 2009 13:54 |
|
Broken Knees Club posted:So what exactly did those 500 lines do? I don't think I could write 500 lines for something that simple even if I tried. if(x<=10) tilex=0; else if(x<=20) tilex=1; And so on. It's not that hard.
|
# ¿ Nov 7, 2009 15:58 |
|
And anyway, isn't the point of a flowchart to describe the logic flow of the program, not to format the actual code in a weird way? 'Ah yes, array_aaa(array_pos)="y"+left(aa,tt-1)+"y"'
|
# ¿ Jan 2, 2010 15:30 |
|
Zhentar posted:Edit: (1/(Speed/Fastest Speed)) More = better than.
|
# ¿ Jan 29, 2010 07:50 |
|
JasonV posted:
http://betterthangrep.com/ (okay so it doesn't provide any improvements in this particular use-case, but...)
|
# ¿ Feb 4, 2010 09:17 |
|
Parantumaton posted:Swing apps do, ours start at 24 megs (that's a lot too, agreed) and never pass 300 megs. Then again, our Java apps don't plain suck as apparently a lot of others' do... 24 megs is nothing, 300 megs could be a problem on a low-end machine.
|
# ¿ Feb 9, 2010 07:52 |
|
Zombywuf posted:Depends if all the programs on your system think 24MB is nothing. Well, if every background process and service running on this machine would take 24MB, I would be at about 1,5 GB. It would not be pleasant, since this machine only has a gig of RAM. Then again, computers with 2 GB RAM is not exactly rare these days.
|
# ¿ Feb 9, 2010 14:27 |
|
markerstore posted:If only there were some way to temporarily store the contents of RAM on your hard drive while they weren't being used! Like I said: "It would not be pleasant, since this machine only has a gig of RAM." And besides, I was the one arguing that 24MB is nothing.
|
# ¿ Feb 9, 2010 17:29 |
|
Parantumaton posted:Our software supports millions of users per day and are generally run on clustered servers (mostly because clients demand it) so 300 megs is nothing to us. I just took a look at a price watch site and listed their computers by price. The cheapest computers were nettops that had 1 GB of memory. There was one thin client that had 512MB, and a bunch of "media" computers that also had 1 GB. Pretty much any "real" desktops these days come with 2GB, often 3 or 4 gigs. I'd say memory usage on software designed for a desktop computer (or higher) is not that big of a worry these days. Memory leaks are of course a different matter. e: (I'm not disagreeing with you.)
|
# ¿ Feb 9, 2010 20:37 |
|
which is worse:code:
code:
|
# ¿ Feb 27, 2010 22:54 |
|
Mista _T posted:If the test fails after function1() in Wheazy's first example, you are still testing "status" an unnecessary number of times. That said, my third idea was having an array of function pointers, with the last array entry being NULL, then doing a code:
|
# ¿ Feb 28, 2010 09:35 |
|
markerstore posted:Good lord, just use a real language with exception handling. I would if I could.
|
# ¿ Feb 28, 2010 19:59 |
|
His lovely attitude has nothing to do with PHP, or any other language. He's just a bad programmer.
|
# ¿ Mar 19, 2010 08:16 |
|
Maybe they didn't know that in Java you can do a Course [] returnCourses = new Course [numberOfCourses];
|
# ¿ Mar 28, 2010 09:44 |
|
markerstore posted:What if the next element in the array is FALSE? Then the function throws a EverytingIsFine exception, which evaluates to FALSE.
|
# ¿ Apr 8, 2010 20:56 |
|
Flobbster posted:Oh, I don't actually believe that, I just don't care enough to change it right now. I've got bigger fish to fry, and this is a hobby project anyway. Just bookmark Janin's post for when you need to change it.
|
# ¿ May 11, 2010 08:31 |
|
Mustach posted:Baby-sized horror that popped up today: I don't get it.
|
# ¿ May 27, 2010 13:24 |
|
Spazmo posted:Comparison functions shouldn't return on first difference to avoid timing attacks on password comparison. You shoudn't store plaintext passwords anyway?
|
# ¿ Aug 3, 2010 05:12 |
|
HFX posted:You shouldn't store passwords in plaintext or non salted non block level password schemes. Anyway who cares. Well I care in the sense that if your password system would be vulnerable to strcmp timing attacks, you are already doing it wrong. I just wasn't sure if I missed a joke
|
# ¿ Aug 3, 2010 11:02 |
|
Zombywuf posted:Yeah, maybe you'd learn to regex. They are not some deep mystery only comprehensible by the gods, they're the most trivial way of expressing a string pattern. Yeah, this. You really should learn them, and they're really not that hard. They have applications other than programming too.
|
# ¿ Sep 1, 2010 15:59 |
|
TRex EaterofCars posted:Hey baby, s/your pants//g Well, I couldn't actually think of that many examples, and even those are close to programming. Anyway: learn regular expressions, they're really loving useful and not hard at all. (try http://www.weitz.de/regex-coach/ )
|
# ¿ Sep 2, 2010 11:07 |
|
Lurchington posted:Not so much a coding horror, but after seeing it on the official (although internal) system visualization documentation/presentations, I'm shaking my head. I had nothing to do with it. I would love to work in such a zany place
|
# ¿ Oct 8, 2010 15:54 |
|
qntm posted:Except this doesn't work, because outside of a pair of square brackets, the ^ metacharacter isn't "negation", it matches the end of the string. So /^\s+/ will match nothing. I think what's needed is either /[^\s]+/ or /\S+/. ^ is the start, $ is the end e: so it's "the start of the string, followed by 1 or more whitespace"
|
# ¿ Oct 14, 2010 13:03 |
|
$get = sqlInjectionProtect($_GET);
|
# ¿ Nov 9, 2010 20:49 |
|
ymgve posted:Might not be a horror (except for the fact that they're probably not used parameterized queries) - I assume the function does something like "Check if gpc_magic_quotes is enabled, if not, do manual escape of all variables." Something like that, yeah. Then on the next row after calling that function: $thing = getAThingById($get["id"]);
|
# ¿ Nov 9, 2010 22:14 |
|
code:
if(hasRights(5)){...} What does '5' mean? Who knows! Well, actually there is an explanation about the bits in the rights-field in a comment near 'hasRights', but it's off-by-one. And for some reason it does not use the least significant bit at all This codebase is pretty
|
# ¿ Nov 16, 2010 19:36 |
|
|
# ¿ Apr 25, 2024 12:07 |
|
FUCKIN' AJAX, MOTHERFUCKERS! code:
code:
Wheany posted:This codebase is pretty
|
# ¿ Nov 18, 2010 22:29 |