|
NotShadowStar posted:Uh can't you write if (thefile_counter == 54) { thefile_counter = 0; } on the assignment and give him an F because ffffffffff I was very frustrated when I was TAing an intro-level programming course because we were given incredibly anal grading schemes that didn't allow us to give Fs or remove more than 2 marks (out of 100) for this kind of thing. The grading scheme stopped just short of actually providing unit tests and as long as it met that spec, they got nearly full marks, even though the code is completely offensive.
|
# ? Dec 2, 2011 05:43 |
|
|
# ? Jun 4, 2024 02:01 |
|
Suspicious Dish posted:Switch statements are jump tables, so they're faster than if statements! And with more billable hours, it's truly win-win!.
|
# ? Dec 2, 2011 06:30 |
|
Spazmo posted:I was very frustrated when I was TAing an intro-level programming course because we were given incredibly anal grading schemes that didn't allow us to give Fs or remove more than 2 marks (out of 100) for this kind of thing. The grading scheme stopped just short of actually providing unit tests and as long as it met that spec, they got nearly full marks, even though the code is completely offensive. Well, can't you at least remove those 2 marks and add a note "if (thefile_counter == 54) { thefile_counter = 0; } "
|
# ? Dec 2, 2011 06:35 |
|
There's two date fields in this database that I'm working on...code:
Surely a unix timestamp should be longer than that... maybe it's only part of the time stamp, because precision isn't that important. Let's see what the data looks like: code:
gently caress.
|
# ? Dec 2, 2011 21:30 |
|
bobthecheese posted:Storing dates Why is this such a common mistake? If there is a DATE datatype, can't people see that when they're looking at the other ones (to get the decimal function for example)? I honestly don't get it.
|
# ? Dec 2, 2011 21:49 |
|
employer posted:we didn't know of unix timestamps I found other parts of the code like that which go back another 4+ years further than this one. Now I'm writing my own horror to deal with it. code:
|
# ? Dec 2, 2011 22:38 |
|
bobthecheese posted:There's two date fields in this database that I'm working on... It's the data modeling version of inception.jpg.doc.pdf.xls.eml!
|
# ? Dec 2, 2011 22:42 |
|
bobthecheese posted:So they're strings. Stored as integers ... Representing dates. The GPS devices we use encode date information that way, with 6 digits representing YYMMDD. The fact that someone would think it's a good idea on a large scale makes my head hurt.
|
# ? Dec 3, 2011 00:20 |
|
It is extremely bizarre, but it's not the worst thing ever. At least you can still test whether one time is before or after another just using comparison operators. Of course you could do that with unix timestamps too. And you can't easily find the difference between two times. And you have your work cut out for you if you want to express an idea like "one week ago" or... well actually maybe it is the worst thing ever.
|
# ? Dec 3, 2011 01:51 |
|
Apok posted:I'd think it has to do with the gigantic tables scattered throughout. If you broke things down to third normal form, you'd have a bunch of smaller tables. This is kinda meaningless. I was wanting examples of the lack of normalization. Yes, we all can assume that big tables probably means bad normalization, but 1) you can't actually say that with certainty (for all you know, all of those columns are a single unique key (a horrifying thought all on its own)) and 2) it'd be fun to see what sorts of problems their database designer actually created due to not normalizing.
|
# ? Dec 3, 2011 04:27 |
|
Most of the code at my new job is written by one of four people (Myself included, now) and most of it is pretty terrible, with mine arguably being the last bad (but still bad) and the worst, well. You know Apache log configuration? The stuff that goes "LogFile /var/logs/apache/access.log combined"? They had the bright idea to use something nonstandard there (we'll say "all_subdomains_combined"). There was, up until yesterday, hundreds of megabytes worth of rotated and zipped data filled with nothing but hundreds of thousands of lines with just "all_subdomains_combined". Oh, and most of the actual code is entirely unindented and cargo-culted. It gets worse the more I look at it. A full list of horrors would probably spawn Cthulhu, honestly. On its own it wouldn't be so bad, but there's just so much of it.
|
# ? Dec 3, 2011 07:55 |
|
Hammerite posted:It is extremely bizarre, but it's not the worst thing ever. At least you can still test whether one time is before or after another just using comparison operators. Of course you could do that with unix timestamps too. And you can't easily find the difference between two times. And you have your work cut out for you if you want to express an idea like "one week ago" or... well actually maybe it is the worst thing ever. No, the worst thing ever would be that, except in US-style MMDDYYHHMMSS format so you can't even use comparison operators to see which date comes first.
|
# ? Dec 3, 2011 16:35 |
|
What scrub languages are you guys using that doesn't have a nice date library to parse a string?
|
# ? Dec 3, 2011 16:52 |
|
NotShadowStar posted:What scrub languages are you guys using that doesn't have a nice date library to parse a string? Why would you want to pull all that data to do range queries if the dbms could have just done it for you if you simply didn't make a piece of poo poo in the first place?
|
# ? Dec 3, 2011 17:23 |
|
a recent horror that I constructed was to have a program calculate integers, then output them to a file as strings, which were then read into a different program as strings, which were then re-converted to integers, then cast as floats inside an array. then, i graphed them.
|
# ? Dec 3, 2011 18:11 |
|
Pangolin Poetry posted:a recent horror that I constructed was to have a program calculate integers, then output them to a file as strings, which were then read into a different program as strings, which were then re-converted to integers, then cast as floats inside an array. then, i graphed them. It sounds like you've implemented a poor man's version of UNIX pipes.
|
# ? Dec 3, 2011 20:58 |
|
NotShadowStar posted:Uh can't you write if (thefile_counter == 54) { thefile_counter = 0; } on the assignment and give him an F because ffffffffff The csv was to have a "special format" with the typical field descriptions being reentered after each row of records (eg: A,B,C\n 1,2,3\n A,B,C\n 4,5,6), and each row needed to end with an extra comma, and the "ID" field needed to be last. When explaining why I was frustrated about this solution, he replied: "Can you just guarantee the files will be this way?" I decided to just designate a portion of the data we created as his. It's not like he finished with his solution, anyway. I really hope I get to see it when it's done.
|
# ? Dec 4, 2011 01:49 |
|
DotFortune posted:To be fair/make things infinitely worse, this person was going to write different routines for each case: each case being the different positions of records of a csv. But each row was to have 27 records, so the idea was that he was dealing with two rows at a time. What. I would have just said "no" but maybe I'm kind of a dick?
|
# ? Dec 4, 2011 04:45 |
|
We were up against a deadline, I was tired of arguing, he wanted to feel like he contributed to the project - and if he had used a library like I had suggested then all of his hard work on typing fifty-four case statements would have been in vain. It was okay for me to just let it go.
|
# ? Dec 4, 2011 05:19 |
|
I wrote a coding horror today, in stripped down form it worked like this:code:
|
# ? Dec 4, 2011 21:05 |
|
Dessert Rose posted:What underlying language invariants does this violate? You started 100 threads that all call a method on an object that mutates shared state without synchronization. Changes to local variables are thread-safe and don't require synchronization. Activation records exist only within the context of a single thread. Activation record lifespans are coterminous with the execution of their associated method. You know, stuff that programmers generally take for granted to the point they don't even think about it any more. quote:C# handles this just fine. What's the scope of a loop variable? Closures over variables introduce a lot of subtle issues as to how a language works which closures over values don't.
|
# ? Dec 5, 2011 02:48 |
|
1337JiveTurkey posted:What's the scope of a loop variable? Closures over variables introduce a lot of subtle issues as to how a language works which closures over values don't. Sometimes closing over a value is the desired behaviour, but other times you want to close over a variable. The syntax to close over a value when your closures close over variables is simple and isolated to the point that you create the closure - while the syntax to close over a variable when your closures only close over values is ugly and affects everywhere that variable is used.
|
# ? Dec 5, 2011 03:18 |
|
So I mashed this out earlier today and it made me wonder, would it make people in this thread think I am a horror? http://pastebin.com/LYHQPXMb I am thinking particularly about lines like code:
(Don't bother castigating me over the use of mysqli_query() with variables concatenated in, I know that looks/is awful and IDGAF)
|
# ? Dec 5, 2011 04:26 |
|
Hammerite posted:So I mashed this out earlier today and it made me wonder, would it make people in this thread think I am a horror? It's PHP, so, yes Though actually, "grab everything -> munge in PHP" (when you could write a proper query and get it already-munged) probably is a horror.
|
# ? Dec 5, 2011 04:41 |
|
Jabor posted:Sometimes closing over a value is the desired behaviour, but other times you want to close over a variable. And yet other times you want partial evaluation with pass-by-reference semantics. If there's perfectly serviceable language constructs for doing something like sharing mutable state throughout a program, we don't need to shoehorn that capability into constructs never intended for that purpose.
|
# ? Dec 5, 2011 05:17 |
|
Dear GOD http://www.daniweb.com/web-development/php/threads/190561 code:
|
# ? Dec 5, 2011 17:11 |
|
Reminds me of VB code I might have written when I was in middle school.
|
# ? Dec 5, 2011 19:00 |
|
Beef posted:Dear GOD The part you quoted is the worst part but jesus christ, everything in that markup is awful. I guess it was a couple years ago, so maybe they've learned their lesson?
|
# ? Dec 5, 2011 22:13 |
|
I love how the only reply is "HAHAHAHAH"
|
# ? Dec 6, 2011 04:02 |
|
Suspicious Dish posted:Switch statements are jump tables, so they're faster than if statements! code:
|
# ? Dec 7, 2011 04:14 |
|
I just found this in my own code:code:
|
# ? Dec 7, 2011 04:30 |
|
Doesn't it count the number of vertices?
|
# ? Dec 7, 2011 04:33 |
|
Isn't the while condition going to start false and stay that way?
|
# ? Dec 7, 2011 05:01 |
|
Oh haha duh
|
# ? Dec 7, 2011 05:03 |
|
It doesn't quite fit in this thread as it's not a coding horror per say, but it did make me laugh and/or cry... Had a crash in a final build of a project at work, it was kind of like: code:
Looking at the assembly dump, that first line was basically: code:
r4 was obviously NULL and the whole thing was a NULL dereference. But the freaky part is that while I had the disassembly open I looked at the call into SomeFunc() and I saw: code:
The drat thing had everything it needed to have static code analysis tell me "Dipshit, this is going to be a NULL dereference, it literally can't be anything but." But the compiler isn't quite at that next step yet. Some day soon we're in for an amazing time. (The problem obviously was if(pClass) instead of if(!pClass) but it was such a rare edge case that it has been in the main code base for over a year without ever being hit until this week.)
|
# ? Dec 7, 2011 05:40 |
|
GrumpyDoctor posted:Isn't the while condition going to start false and stay that way? I sort of hope that in practice it manages to always run exactly twice.
|
# ? Dec 7, 2011 05:44 |
|
Plorkyeran posted:Only if operator != has a sensible definition. The loop could run one or infinite times with non-insane bugs. For all you know vertices_begin() could be unstable and give you a different value when you call it the second time.
|
# ? Dec 7, 2011 05:49 |
|
Actually, the code would "work" if vertices_begin() removed the element it returned an iterator pointer to, unless the list is empty, in which case it would simply always return end, and dereferencing end works and returns a value equal to only itself. Clearly you should alter the rest of the code to work this way.
|
# ? Dec 7, 2011 07:14 |
|
That block is in a weird source file. It's not egregiously or even particularly ugly, but it's full of weird little poo poo like that, and plenty of other ones straight-up break everything when you "fix" them. I've done a number of significant refactorings to make logic more generally usable across the whole program, but that source file can never make use of them without something breaking, and I don't know why. It's not like it was written by someone else; it's all my code. It's like a haunted house. But not the grisly kind of haunted house; rather, the kind that's vaguely creepy that you never, ever want to stay in for too long because you can swear the walls are whispering or something and every family that's moved in next door has moved out within six months. I try to keep it quarantined.
|
# ? Dec 7, 2011 09:01 |
|
|
# ? Jun 4, 2024 02:01 |
|
I know Zope is all sorts of terrible ideas and bonghits, but this is just atrocious: minjson.py. It tries to use Python's tokenizer to parse JSON. It works as well as you think it would. Considering I've made a hand-written JSON parser in an hour to win a bet, there is no excuse for this. (The bet was related to Prototype's use of regex to validate JSON and then parse it using eval(), which is a horror in and of itself. I bet money that there was no excuse -- the JSON spec was easy enough to hand-write a recursive-descent parser for in an hour. I won.)
|
# ? Dec 7, 2011 09:15 |