|
Zakalwe posted:output(i) returns a reference to the i'th element of an internal array I'd guess. If so I'd personally overload[] and use output[j] = device_read(j) myself; It's a stylistic choice. Yep, that's what it does. It just looks wrong. This whole project is kind of a pain, I'm trying to write a plugin for an obscure OSS scientific computing program which has no documentation. I got it working after flailing about for a bit, but that was only the beginning!
|
# ? Aug 20, 2009 03:29 |
|
|
# ? Apr 27, 2024 17:07 |
|
I feel like I've spent my life patching other peoples idiocy. I've seen some horrors, but absolutely nothing could prepare me for thiscode:
*yeah, that part got dropped the very moment the opportunity arose.
|
# ? Aug 20, 2009 11:04 |
|
Flobbster posted:I like that the helper function they wrote to handle the null string case requires about twice as much typing as the expression itself.
|
# ? Aug 20, 2009 15:16 |
|
porkfactor posted:I feel like I've spent my life patching other peoples idiocy. I've seen some horrors, but absolutely nothing could prepare me for this I don't have a lot of C++ experience. What's the horror here?
|
# ? Aug 20, 2009 15:19 |
|
mr_jim posted:I don't have a lot of C++ experience. What's the horror here?
|
# ? Aug 20, 2009 15:40 |
|
A const_iterator conceptually iterates over const elements. That is, they can't be modified through the iterator. An example is const char *. The const_iterator defined in that example is a nonmodifiable iterator that references a non-const element. An example is char * const i. You can do *i = 'c', but you can't do ++i.
|
# ? Aug 20, 2009 15:43 |
|
OK, I get it now. It's "const pointer" vs "pointer to const" generalized to C++ iterators.
|
# ? Aug 20, 2009 15:54 |
|
Lexical Unit posted:STL style containers will offer a number of different kinds of iterators such that they can interop with algorithms. However the writer of that code doesn't appear to understand the meaning of "const_iterator." Think about it. If the iterator itself is const... it's not really an iterator, is it? const_iterator is supposed to be an iterator that doesn't allow algorithms to modify the elements being iterated over. Not an iterator that's conceptually const (which I would take to mean an iterator that only ever points to one thing). It's totally possible to make a const_iterator by using constness of the iterator itself and creating appropriate const overloads. But then you'd make it impossible to make an iterator that itself cannot be changed, so I propose using volatile for this, e.g.: code:
|
# ? Aug 20, 2009 17:39 |
|
Avenging Dentist posted:
|
# ? Aug 20, 2009 18:21 |
|
Avenging Dentist posted:No one uses "volatile" for anything but primitives, and even that is rare, so it's not like anyone would notice. *: not great.
|
# ? Aug 20, 2009 18:54 |
|
Lexical Unit posted:Yeah volatile is great* for all kinds of things, like thread safety! That article owns.
|
# ? Aug 20, 2009 19:01 |
|
Avenging Dentist posted:Seriously, if you work at Epic Systems, just loving quit, it's not worth it. I almost got flown out to Wisconsin for them before deciding to go to grad school instead, are they well known for being a lovely company or something?
|
# ? Aug 21, 2009 09:27 |
|
Insurrectum posted:I almost got flown out to Wisconsin for them before deciding to go to grad school instead, are they well known for being a lovely company or something? http://thedailywtf.com/gsearchresults.aspx?cx=007080070087309103660%3Au1mb5rvqdbu&cof=FORID%3A11&ie=UTF-8&q=mumps&sa=Search#1098
|
# ? Aug 21, 2009 09:42 |
|
Zombywuf posted:http://thedailywtf.com/gsearchresults.aspx?cx=007080070087309103660%3Au1mb5rvqdbu&cof=FORID%3A11&ie=UTF-8&q=mumps&sa=Search#1098 Goddamn. Looks like I made the right choice.
|
# ? Aug 21, 2009 09:56 |
|
I've been assigned to completely redo this small custom CMS my company did for a client. The old developer was a cheap freelancer and did a crap-tastic job. Looking through the code I just found this: php:<?php if ($totalRows_Recordset1 > 0) { do { ?> ...some html... <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); } ?> I bet I'm gonna find loads of gems in this project.
|
# ? Aug 21, 2009 21:52 |
|
wolf_man posted:a goddamn do while in PHP5!. Not having touched PHP in many years (thankfully), I guess I'm missing something here. What's the coding horror, that he should be using foreach() instead or something? What specifically makes do-while loops poo poo in PHP5?
|
# ? Aug 21, 2009 22:09 |
|
Vinterstum posted:What's the coding horror, that he should be using foreach() instead or something? Probably (except I'm not exactly a PHP expert myself)
|
# ? Aug 21, 2009 23:38 |
|
Vinterstum posted:Not having touched PHP in many years (thankfully), I guess I'm missing something here. What's the coding horror, that he should be using foreach() instead or something? What specifically makes do-while loops poo poo in PHP5? for loops are better optimized and efficient then do whiles.
|
# ? Aug 22, 2009 02:01 |
|
Saw this today:code:
wolf_man posted:for loops are better optimized and efficient then do whiles. .. really?
|
# ? Aug 22, 2009 02:39 |
|
wolf_man posted:for loops are better optimized and efficient then do whiles.
|
# ? Aug 22, 2009 04:06 |
|
Dijkstracula posted:Granted, I don't know the first thing about PHP's internals, but I would be highly surprised if a do-while construct could be "optimized" (I'm thinking of things like loop invarients) any better than a plain for-loop. it's a conditional and jump, what's to optimize It doesn't matter if it actually makes sense. PHP has stuff all over the place where there's 3 logically equivalent ways to do something and the first way is 1/10 the cost of the other two. What's really bad about this is that people start writing code based on some bullshit they picked up in a tutorial (or writing their own tutorial!) because they want their program to be "optimized" before they care about it being useful or maintainable. Examples: $array[] = $var vs. $array = array($var) print("hello") vs. print "hello"
|
# ? Aug 22, 2009 04:18 |
|
royallthefourth posted:$array[] = $var vs. $array = array($var) These are different though. For example, if you do code:
code:
royallthefourth posted:print("hello") vs. print "hello" This was also the case in Python pre-3.0.
|
# ? Aug 22, 2009 05:19 |
|
oldkike posted:Saw this today: I'm not on the up and up in C. Are you trying to say that the try block is unnecessary? Can't the cast fail and throw an exception?
|
# ? Aug 22, 2009 05:26 |
|
dynamic_cast returns NULL if it isn't a valid cast
|
# ? Aug 22, 2009 05:32 |
|
Plorkyeran posted:dynamic_cast returns NULL if it isn't a valid cast No, dynamic_cast returns NULL if the cast fails and the target type is a pointer (which it is in this case). It throws if it's a reference type.
|
# ? Aug 22, 2009 05:42 |
|
dancavallaro posted:] What do you mean "it was the case in Python", no one in the Python community writes print with parens in Python 2.x, especially not as a performance hack as the OP suggests.
|
# ? Aug 22, 2009 06:33 |
|
oldkike posted:Saw this today: dynamic_cast is the real horror here.
|
# ? Aug 22, 2009 09:57 |
|
wolf_man posted:for loops are better optimized and efficient then do whiles. Coding horrors: posts that make you laugh (or cry)
|
# ? Aug 22, 2009 10:16 |
|
ctz posted:Coding horrors: posts that make you laugh (or cry) We were so close to getting past the PHP side tracking and here you (we) go bringing it back up. See ya in 5 pages and 3 more threads.
|
# ? Aug 22, 2009 17:22 |
|
geetee posted:We were so close to getting past the PHP side tracking and here you (we) go bringing it back up. See ya in 5 pages and 3 more threads. It's not our fault PHP is a coding horror.
|
# ? Aug 22, 2009 19:29 |
|
king_kilr posted:It's not our fault PHP is a coding horror. But it is your fault for using it.
|
# ? Aug 22, 2009 19:38 |
|
Avenging Dentist posted:
Why?
|
# ? Aug 23, 2009 14:54 |
|
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 |
|
code:
|
# ? Aug 24, 2009 17:35 |
|
He must be following the new "don't use the keyword null" coding standard.
|
# ? Aug 24, 2009 20:02 |
|
Ugh, everyone knows you have to check at least 4 times
|
# ? Aug 24, 2009 20:34 |
|
It might be some 'fix' for some horrible locking bug
|
# ? Aug 24, 2009 21:48 |
|
Insurrectum posted:Goddamn. Looks like I made the right choice. MUMPS is totally awesome and will train you into a programming legend! code:
code:
|
# ? Aug 24, 2009 22:03 |
|
meinstein posted:
|
# ? Aug 24, 2009 22:03 |
|
|
# ? Apr 27, 2024 17:07 |
|
Zhentar posted:P.S. "A Case of the MUMPS" has a fairly small intersection with reality, so don't take too much of it to heart. Yeah, the reality is actually worse. EDIT: Another fun coding horror. This post was originally rendering as blank despite being valid, and only when I edited it did it show up. Avenging Dentist fucked around with this message at 22:09 on Aug 24, 2009 |
# ? Aug 24, 2009 22:05 |