|
npe posted:Dear Penthouse: I'm not familiar with VB, but is the solution to store a pointer to the objects in an array I assume?
|
# ? Nov 18, 2010 22:34 |
|
|
# ? May 17, 2024 18:27 |
|
Wheany posted:
Hey now, never mix presentation and logic, that can be very confusing! php:<? public static function weeaboo() { $obj = (anObject::getCurrent()->isChild()) ? anObject::getCurrent()->getParent() : anObject::getCurrent(); $dxml = new myDOMDocument('1.0', 'utf-8'); $dxml->loadXML('<form/>'); $dxml->documentElement->setAttribute('method', 'get'); $dxml->documentElement->setAttribute( 'action', trim(dirname($_SERVER['PHP_SELF']), '/') ); $sel = $dxml->createElement('select'); $sel->setAttribute('onchange', sprintf("window.location = '/%s/%s%s/' + this.value", trim(dirname($_SERVER['PHP_SELF']), '/'), (dmTEConfig::getInstance()->isRewriteEnabled()) ? '' : '?r=', trim(anObject::getCurrent()->getAlias(), '/'))); foreach ($obj->getChildren() as $c) { $opt = $dxml->createElement( 'option', dmString::websafe($c->getMetadata('title'))); $opt->setAttribute('value', $c->getPtr()); if ($c->getPtr() == anObject::getCurrent()->getPtr()) { $opt->setAttribute('selected', 'selected'); } $sel->appendChild($opt); } $dxml->documentElement->appendChild($sel); return $dxml->saveXML($dxml->documentElement); } ?>
|
# ? Nov 18, 2010 23:07 |
|
Wait there's such a thing as a repeater? Why don't you implement my control that displays a single business object. Yes I know this 600 lines of code is for displaying a single object and generates 14-20 lines of HTML source code! Quit changing the subject:code:
code:
Well make sure the junior developers understand the CSS box model. That won't work? Let me make 9 more rendering methods to control the layout for each of those sites and add a switch statement in the classNode's constructor so it displays differently!
|
# ? Nov 19, 2010 00:01 |
|
Dicky B posted:That is truly tragic. 11/18 NEVER FORGET
|
# ? Nov 19, 2010 00:11 |
|
I just found this today.php:<? function getSettings() { $query = "SELECT * FROM `system_settings` LIMIT 1"; $result = mysql_query($query); $row = mysql_fetch_row($result); $s['1']= $row[0]; $s['2']= $row[1]; $s['3']= $row[2]; $s['4']= $row[3]; $s['5']= $row[4]; $s['6']= $row[5]; $s['setting1']= $row[6]; $s['setting2']= $row[7]; $s['setting3']= $row[8]; $s['7']= $row[9]; return $s; } ?> php:<? for ($index = 0; $index < count(getSettings()); $index = $index + 1) { switch ($index){ case 0: $s = getSettings(); $admin_Email = $s['1']; break; case 1: $s = getSettings(); $adminname = $s['2']; break; case 2: $s = getSettings(); $sendEmailFrom = $s['3']; break; ... ?> bobthecheese fucked around with this message at 00:24 on Nov 19, 2010 |
# ? Nov 19, 2010 00:22 |
|
bobthecheese posted:I just found this today.
|
# ? Nov 19, 2010 00:23 |
|
Wheany posted:FUCKIN' AJAX, MOTHERFUCKERS! Wait, where's the AJAX?
|
# ? Nov 19, 2010 00:39 |
|
markerstore posted:Wait, where's the AJAX? Not Shown: AJAX.
|
# ? Nov 19, 2010 01:33 |
|
baquerd posted:I'm not familiar with VB, but is the solution to store a pointer to the objects in an array I assume? Everything in there is 100% pure insanity. There is no fix. If you must think about it, though, just know that most of the current code in there can be replaced with a few dozen lines of code that uses ThreadPool.QueueUserWorkItem() and follows some of the ideas in http://msdn.microsoft.com/en-us/library/ms973903.aspx But we are way past that. Fuckin' arrays, how do they work?!
|
# ? Nov 19, 2010 02:08 |
|
markerstore posted:Wait, where's the AJAX? The javascript file is in the subdirectory 'ajax' Actually, there is this bit: code:
Without X Wheany fucked around with this message at 06:09 on Nov 19, 2010 |
# ? Nov 19, 2010 05:59 |
|
Wheany posted:Actually, there is this bit: Oh sweet, so he is using jQuery, but only for long enough to turn off the useful parts.
|
# ? Nov 19, 2010 06:17 |
|
markerstore posted:Oh sweet, so he is using jQuery, but only for long enough to turn off the useful parts. Oh hell yes he's used jQuery: code:
I've already deleted a bunch of .old.php and .php.old files and commented-out code. e: To be fair: many of those jquery files are legit, but there are several versions of the base library. Wheany fucked around with this message at 07:41 on Nov 19, 2010 |
# ? Nov 19, 2010 07:38 |
|
This might not be a horror for some of you but gently caress.code:
|
# ? Nov 19, 2010 21:11 |
|
Lysandus posted:This might not be a horror for some of you but gently caress.
|
# ? Nov 19, 2010 21:51 |
|
Orzo posted:This is a preference and probably the furthest thing from a horror I can think of. Follow your team's guidelines when it comes to this one. While it is a minor quibble after maybe the third or fourth time someone accidentally fucks up an if block by adding another line you start putting the {}s everywhere you can.
|
# ? Nov 19, 2010 21:57 |
|
Orzo posted:This is a preference and probably the furthest thing from a horror I can think of. Follow your team's guidelines when it comes to this one. Our department made it a guideline long ago because we all hate it. I was reminded of it today while looking though a library from another department.
|
# ? Nov 19, 2010 21:57 |
|
The only time I leave off braces is when I do an early return (if (!foo) return false;) and then I put it all on one line so I can't make the mistake of adding lines to it.
|
# ? Nov 19, 2010 22:01 |
|
Do you guys not test your code or something? Is it really that big of a deal if somebody somehow temporarily forgets that they're coding in a language that uses braces to delimit blocks and puts a statement outside of the if?
|
# ? Nov 19, 2010 23:47 |
|
Mustach posted:Do you guys not test your code or something? Is it really that big of a deal if somebody somehow temporarily forgets that they're coding in a language that uses braces to delimit blocks and puts a statement outside of the if? It's more of a readability issue rather than a testing issue. Plus we use StyleCop to help enforce a standardized style and make it easier to maintain and peer-review.
|
# ? Nov 19, 2010 23:53 |
|
Mustach posted:Do you guys not test your code or something? Is it really that big of a deal if somebody somehow temporarily forgets that they're coding in a language that uses braces to delimit blocks and puts a statement outside of the if? You'd be surprised how often it happens. Many people never write ifs without braces, and so don't notice when they aren't there
|
# ? Nov 20, 2010 00:10 |
|
The code following an if statement should never be more than one line regardless, so it's a non-issue.
|
# ? Nov 20, 2010 00:12 |
|
Orzo posted:The code following an if statement should never be more than one line regardless, so it's a non-issue. code:
edit: quote:SA1305: The variable name 'myLittlePwny' begins with a prefix that looks like Hungarian notation. Remove the prefix or add it to the list of allowed prefixes. GOD drat YOU STYLECOP! GOD drat YOU! Fiend fucked around with this message at 00:41 on Nov 20, 2010 |
# ? Nov 20, 2010 00:35 |
|
Orzo posted:The code following an if statement should never be more than one line regardless, so it's a non-issue. Real horror found.
|
# ? Nov 20, 2010 00:38 |
|
Shavnir posted:Real horror found. No man you just create a new method with all the logic in there, that way you only need curly braces to encapsulate methods and classes and poo poo.
|
# ? Nov 20, 2010 00:43 |
|
Orzo posted:The code following an if statement should never be more than one line regardless, so it's a non-issue. Fiend posted:No man you just create a new method with all the logic in there, that way you only need curly braces to encapsulate methods and classes and poo poo. Why?
|
# ? Nov 20, 2010 02:11 |
|
mr_jim posted:
|
# ? Nov 20, 2010 02:14 |
|
Coming up next in the Coding Horrors thread, after the break: tabs v spaces brace styles toilet paper under/over
|
# ? Nov 20, 2010 02:44 |
|
Yeah, uh, I was joking by the way.
|
# ? Nov 20, 2010 03:41 |
|
Just having a single expression inside each branch of an if-then-else expression has always worked fine for me, I do not see what the big deal is how do curly braces play into this again
|
# ? Nov 20, 2010 04:01 |
|
I just remove all non-semantic whitespace and line breaks before I check anything in, that way whenever any else sees the code they just assume that something in the CVS hosed up the formatting and they'll autoformat it to their liking.
|
# ? Nov 20, 2010 07:15 |
|
Curly braces inside parentheses are how you get functional composition of expressions in C.code:
|
# ? Nov 20, 2010 08:01 |
|
rjmccall posted:Curly braces inside parentheses are how you get functional composition of expressions in C. puts(*(typeof(*"")**) what the gently caress does this do and why does it compile
|
# ? Nov 20, 2010 11:40 |
|
*"" is '\0', typeof('\0') is char, (char**) is a cast to pointer to pointer to char, and the * dereferences it so you get a pointer to char to pass to puts, which happens to point at successive elements of argv.
|
# ? Nov 20, 2010 18:30 |
|
Vanadium posted:*"" is '\0', typeof('\0') is char, (char**) is a cast to pointer to pointer to char, and the * dereferences it so you get a pointer to char to pass to puts, which happens to point at successive elements of argv. That is hosed.
|
# ? Nov 20, 2010 19:17 |
|
I would love a weekly "explain what the following obfuscated code does" contest. Kind of like ioccc but in reverse.
|
# ? Nov 20, 2010 20:56 |
|
Dicky B posted:I would love a weekly "explain what the following obfuscated code does" contest. Kind of like ioccc but in reverse. Just read the Perl thread.
|
# ? Nov 20, 2010 21:00 |
|
Vanadium posted:Just having a single expression inside each branch of an if-then-else expression has always worked fine for me, I do not see what the big deal is Part of the idea is "durability under edit". With braces, if someone goes in and adds more lines later, the braces are already there and it reduces chances of a logic error. Doesn't matter if it's a temporary thing to insert maybe debugging statements or totally new code or whatever -- it's just a matter of reducing the potential of subtle errors in logic.
|
# ? Nov 20, 2010 21:19 |
|
rjmccall posted:Curly braces inside parentheses are how you get functional composition of expressions in C.
|
# ? Nov 21, 2010 05:16 |
|
Mustach posted:This is an extension, right? Searching for "({" doesn't bring up anything relevant in n1256. It looks like it's a GNU C extension, along with typeof: http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#SEC62
|
# ? Nov 21, 2010 05:21 |
|
|
# ? May 17, 2024 18:27 |
|
Yeah, the full inventory is three GCC extensions, two unportable assumptions, either one or three instances of undefined behavior, and an illegal declaration of main. EDIT: Well, plus an extra unportable assumption mixed in with the undefined behavior. rjmccall fucked around with this message at 06:16 on Nov 21, 2010 |
# ? Nov 21, 2010 06:10 |