|
It's better thancode:
|
# ? Apr 4, 2008 04:19 |
|
|
# ? May 16, 2024 18:04 |
|
more falafel please posted:It's better than Holy moly fucckkkk!!!!!!!!!! Uggg I just want to kill myself! Yuck! Two loving spaces? God dammit! poo poo...
|
# ? Apr 4, 2008 04:25 |
|
That Turkey Story posted:Holy moly fucckkkk!!!!!!!!!! Uggg I just want to kill myself! Yuck! Two loving spaces? God dammit! Dude, whitespace changes can be incredibly annoying, and sometimes autocorrect functions don't work well.
|
# ? Apr 4, 2008 06:39 |
|
Vanadium posted:There is at least one C-inspired language that requires that return is used like a function with parentheses and all, as far as I can tell it is mostly because the compiler guy could not be bothered to specialcase return's syntax. PHP?
|
# ? Apr 4, 2008 08:20 |
|
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 |
|
more falafel please posted:It's better than Sheesh, M-x indent-region and get on with your life.
|
# ? Apr 4, 2008 10:19 |
|
king_kilr posted:PHP? code:
code:
|
# ? Apr 4, 2008 11:28 |
|
Triple Tech posted:These things, as Perl programmer, piss me off: See, I wrote code:
|
# ? Apr 4, 2008 14:34 |
|
As written, that is an improper use of map, philosophically.code:
code:
Triple Tech fucked around with this message at 14:58 on Apr 4, 2008 |
# ? Apr 4, 2008 14:53 |
|
Triple Tech posted:As written, that is an improper use of map, philosophically. Hmm, maybe I'm misreading this. What about code:
|
# ? Apr 4, 2008 17:12 |
|
If this_returns_an_array contains no side effects to the variables submitted, then both of those do nothing. They're void context. In the first one, the fact that it returns something doesn't even matter. You can't capture the output of a loop when it's written like that. In the second scenario, you're just missing the left side of the assignment. my @array = that expression. It's returning an array for each element in the elements list, and then jamming all of that into one long array, and then that array isn't going anywhere. Again, void context. For loops never get assigned to something. Maps should always be either assigned to something or chained to another process, like a function's input, or the list input to a sort or grep.
|
# ? Apr 4, 2008 18:44 |
|
Zombywuf posted:Sheesh, M-x indent-region and get on with your life. That's the problem -- I'm stuck doing that (well, gg=G, but same difference). This code is five years old, and full of crap like this -- defining log macros badly so they need double parentheses, bizarro mixes of Systems Hungarian, CamelCase, camelCase, and under_score_words, depending on this guy's mood that month, static members called m_ivpFoo (instance variable). And of course design problems -- the initializer list for one class's ctor is 124 lines long. I've asked him if he's going to fix any of it, but he says it'd be too much effort when he could just rewrite it. The problem of course is that there's never time -- it's always crunch.
|
# ? Apr 4, 2008 19:05 |
|
more falafel please posted:That's the problem -- I'm stuck doing that (well, gg=G, but same difference). This code is five years old, and full of crap like this -- defining log macros badly so they need double parentheses, bizarro mixes of Systems Hungarian, CamelCase, camelCase, and under_score_words, depending on this guy's mood that month, static members called m_ivpFoo (instance variable). And of course design problems -- the initializer list for one class's ctor is 124 lines long. Do you not have check-in access? Or is this one of those case where source control would be too large a change? quote:The problem of course is that there's never time -- it's always crunch. Always the way.
|
# ? Apr 4, 2008 21:29 |
|
Holy poo poo. I've seen some awful code on my job... but THIS has to be the worst thing I've ever seen. The function is used to create a series of dropdown boxes to select month, day, year, hour, and minute. php:<? function displayHTMLMenu( $type, $name, $class, $value_digits, $value_selected, $value_top_name, $value_top_value, $on_change_function_name, $return_or_echo_content = "echo" ) { //global $CM_app_system_path; // get menu data START if ($type == "month_names") { if( $_SESSION["sessionStat"]["lowresolution"] ) { $nxtFile = LIST_DATA_FILES_PATH . "list_date_month_names_abbrv.txt"; } else { $nxtFile = LIST_DATA_FILES_PATH . "list_date_month_names.txt"; } } else if ($type == "day_numbers") { $nxtFile = LIST_DATA_FILES_PATH . "list_date_day_numbers.txt"; } else if ($type == "year_numbers") { $nxtFile = LIST_DATA_FILES_PATH . "list_date_year_numbers.txt"; } else if ($type == "year_numbers_current_and_previous_in_january") { // no file for year_numbers_current_and_previous_in_january, generate dynamically $all_data_array[] = array (date("Y"), date("Y"), date("Y")); if (date("M") == "Jan") { $all_data_array[] = array (date("Y")-1, date("Y")-1, date("Y")-1); } } else if ($type == "hour_numbers") { $nxtFile = LIST_DATA_FILES_PATH . "list_date_hour_numbers.txt"; } else if ($type == "minute_numbers") { $nxtFile = LIST_DATA_FILES_PATH . "list_date_minute_numbers.txt"; } else // default { $nxtFile = LIST_DATA_FILES_PATH . "list_date_minute_numbers.txt"; } if( isset( $nxtFile ) && file_exists( $nxtFile ) ) { $fd = fopen ($nxtFile, "r") or die ("Could not open file"); flock ($fd, 2); while (!feof($fd)) { $buffer = fgets ($fd, 4096); $next_line_array = split("\|", $buffer); $all_data_array[] = $next_line_array; //echo $all_data_array[0]; } flock ($fd, 3); fclose($fd); } else { // file not found //echo "<h1>file not found</h1>"; } // get menu data END $content_to_return = "<select name=\"$name\" class=\"$class\" onchange=\"$on_change_function_name(this);\">"; if (!empty ($value_top_name) || !empty ($value_top_value)) { $content_to_return .= "<option value=\"$value_top_value\">$value_top_name"; } foreach ($all_data_array as $next_data_array) { //echo $next_data_array[0]; if ($next_data_array[0] != "") { // get next value START if ($value_digits == 1) // no leading zeros { $next_value = $next_data_array[1]; } else if ($value_digits == 2) // leading zeros { $next_value = $next_data_array[2]; } else { $next_value = $next_data_array[2]; // leading zeros, default } // get next value END if ($next_value == $value_selected) { $content_to_return .= "<option value=\"$next_value\" selected>$next_data_array[0]"; } else { $content_to_return .= "<option value=\"$next_value\">$next_data_array[0]"; } } } $content_to_return .= "</select>"; if( $return_or_echo_content == "return" ) { return $content_to_return; } else { echo $content_to_return; } ?>
|
# ? Apr 4, 2008 21:57 |
|
Triple Tech posted:If this_returns_an_array contains no side effects to the variables submitted, then both of those do nothing. They're void context. In the first one, the fact that it returns something doesn't even matter. You can't capture the output of a loop when it's written like that. In the second scenario, you're just missing the left side of the assignment. my @array = that expression. It's returning an array for each element in the elements list, and then jamming all of that into one long array, and then that array isn't going anywhere. Again, void context. Yea, I wrote it wrong I meant that they did have side effects on the variable being passed in.
|
# ? Apr 7, 2008 14:23 |
|
Usercontrol DateLookupWindow. It contains a textbox with a hyperlink to a calendar window so that we can pick a date and have it auto populate the textbox with the date (the user can also manually type in a date into the textbox if they want). DateLookupWindow has a property called Date, whose type is a string. WHY? Either call it Text (to indicate the text of the checkbox) or let it be a Date and in the getter/setter handle the appropriate behaviour.
|
# ? Apr 7, 2008 17:09 |
|
(C#) I'd just like to know, am I an idiot for considering adding extension methods for stuff like string.IsNullOrEmpty() and Object.ReferenceEquals because I prefer this syntax:code:
code:
|
# ? Apr 7, 2008 18:41 |
|
Yeah, you're probably an idiot, because won't s.IsNullOrEmpty() throw an exception is s is null? edit: Well gently caress me, this is totally incorrect. I just tested it out quick, and this does not throw an exception at all. I'll leave it up in case anyone wants to laugh at me . _aaron fucked around with this message at 18:54 on Apr 7, 2008 |
# ? Apr 7, 2008 18:43 |
|
_aaron posted:Yeah, you're probably an idiot, because won't s.IsNullOrEmpty() throw an exception is s is null? code:
|
# ? Apr 7, 2008 18:57 |
|
It certainly goes against expected behavior if you think about it, but I find myself typing s.IsNullOrEmpty() all the time anyway.
|
# ? Apr 7, 2008 19:30 |
|
For what it's worth, the "IsNullOrEmpty" phrase is pretty cumbersome, I much prefer Ruby's "blank?" which implies it is either null or empty (this applies to both arrays and strings.)
|
# ? Apr 7, 2008 19:45 |
|
I general, I'd keep away from stuff like s.IsNullOrEmpty(), but I think I would make an except for that specific case. Especially since the name itself acknowledges that null is a valid "argument".
|
# ? Apr 7, 2008 20:12 |
|
dwazegek posted:No, extension methods are pretty much just syntactic sugar for a call to a method in a referenced static class. Yuck. I'd like to plead on behalf of all maintenance programmers everywhere that you don't do that. Also, why should it not be possible to call a member of a null object? code:
|
# ? Apr 7, 2008 22:58 |
|
Zombywuf posted:Yuck. I'd like to plead on behalf of all maintenance programmers everywhere that you don't do that. No it doesn't. That code has undefined behavior. It is never safe to invoke a non-static member function through a null pointer.
|
# ? Apr 7, 2008 23:31 |
|
Really, even POD?
|
# ? Apr 7, 2008 23:36 |
|
Yeah, even PODS.
|
# ? Apr 7, 2008 23:38 |
|
Ah well, good job this is the coding horrors thread. I'd be interested to know if any compilers actually choke on it. Especially is foo::is_null is defined in an external compilation unit.
|
# ? Apr 7, 2008 23:57 |
|
That Turkey Story posted:No it doesn't. That code has undefined behavior. It is never safe to invoke a non-static member function through a null pointer. It may be undefined behavior because the underlying implementation is unspecified, but what the compiler's going to generate is this (using C as portable assembly): code:
|
# ? Apr 8, 2008 01:40 |
|
The Java time/date/calendar and file IO libraries.
|
# ? Apr 8, 2008 01:42 |
|
more falafel please posted:I understand why "undefined behavior" generally means no-no, but in cases like this it doesn't matter what the standard says to some degree, because it works with the only way you would implement POD types. Undefined behavior isn't "generally a no-no" it's always a no-no. It does matter what the standard says. We all know what the probable implementation will do, but that doesn't mean you should ever rely on it, especially here since there's no reason to.
|
# ? Apr 8, 2008 01:43 |
|
Zombywuf posted:Also, why should it not be possible to call a member of a null object?
|
# ? Apr 8, 2008 03:10 |
|
Here is a gem I uncovered today in a code review. This was written by an H-1B contractor. He has a masters degree and makes more than me. :[code:
|
# ? Apr 8, 2008 04:24 |
|
code:
It's not that bad, it's just irritatingly lazy.
|
# ? Apr 8, 2008 04:42 |
|
noonches posted:
That is pretty sad, especially since it'll have duplicates of whatever value's thrown in. However, what's this "tiny piece of code" you'd use to add "selected"? It's as long as that if I recall correctly.
|
# ? Apr 8, 2008 05:27 |
|
<?=($_SESSION['prefix']=="")?"selected":""?> One of those per line is not that much, esp since it's a cut and paste job and avoids a nasty dupliacte.
|
# ? Apr 8, 2008 05:35 |
|
SuperGoon posted:Here is a gem I uncovered today in a code review. This was written by an H-1B contractor. He has a masters degree and makes more than me. :[ Can you explain why it's stupid? Looks okay to me
|
# ? Apr 8, 2008 07:19 |
|
my stepdads beer posted:Can you explain why it's stupid? Looks okay to me What happens when s is null?
|
# ? Apr 8, 2008 07:29 |
|
floWenoL posted:What happens when s is null? Haha oh I see.
|
# ? Apr 8, 2008 12:27 |
|
floWenoL posted:What happens when s is null? code:
|
# ? Apr 8, 2008 14:10 |
|
|
# ? May 16, 2024 18:04 |
|
meh
|
# ? Apr 8, 2008 15:28 |