|
Mashi posted:Being in a loop, you get to make use of the break keyword, and you have an iterator variable (i) which indicates which step was achieved... I used it once or twice like that anyway. Are you serious? I have trouble imagining how that's more practical than something like this: code:
|
# ¿ Mar 24, 2008 17:03 |
|
|
# ¿ Apr 26, 2024 15:34 |
|
Haha. Somehow that reminded me of an ecommerce site I saw at a development firm that eventually went belly up. I think I've been blocking it from my conscious memory for the past few years. * The lead developer declared that ASP was insecure, so everything had to be written as CGI executables in Visual Basic. * He also didn't trust IIS, so the web server was O'Reilly WebSite. The 16-bit free version. * The order database was written in Access. Every order had its own MDB file. When somebody started an order, one of the CGI programs would copy an empty version of the database and populate it with a single order. Every MDB was named for its order number: 1001.mdb, 1002.mdb, etc. * The customer's credit card information was stored in plain text in the MDB. * The web server needed to be restarted several times a day because of a bug that was causing HTTP requests to hang. After a few days, I discovered the problem when I checked the server's monitor. One of the CGI programs was popping a message box with debug information. The process would halt while it waited for someone to click the OK button. * In response to the above problem, the lead developer sincerely suggested that one of us sit next to the server so we could watch for message boxes. The site finally died after 1500 orders, because each order was in a separate 200k MDB file and the server's drive ran out of space. Less than twenty of those orders were actually completed. Most of them were in-house tests. The vast majority only had one or two items in the order. Hundreds of 200k databases that each contained less than 400 bytes of actual data. And of course, after we took the machine offline for an emergency tuneup, it quickly became apparent that someone had compromised it weeks ago. Eight years later, that poor bastard of a client finally has a functional web site, but they still don't take orders online.
|
# ¿ Mar 25, 2008 06:22 |
|
1337JiveTurkey posted:This'll probably horrify some posters, but I like: Wow. The first time I saw a ternary operator, it startled me. This startles me the same way. And much like a ternary operator, I bet it would make perfect sense the third or fourth time I came across it. Neat idea. I don't know if I'll ever use it, but I like it.
|
# ¿ May 13, 2008 03:10 |
|
TSDK posted:Whilst that is a reasonable statement about compilers, I'm still worried that someone's default attitude to warnings would be "I'm a programmer, I know best". I think the default attitude that Linus implied is "Some other programmer wrote code that emits a warning, I better know why." He's talking about the possibility of introducing bugs through blind repair of compiler warnings, not advocating warning-prone code.
|
# ¿ May 13, 2008 17:37 |
|
Ugg boots posted:Just trying to be thread safe! Hahahahaha. I had a coworker who used to pepper functions with sleep calls and identical database updates as a poor attempt to work around race conditions. His code looked like the guy from Memento wrote it.
|
# ¿ Aug 28, 2008 17:13 |
|
Ugg boots posted:You don't want to do this. What if two people are accessing the website at the same time? Your two queries are not one atomic operation, meaning that two individuals' INSERT statements could fire and then their two SELECT statements (not always INSERT SELECT INSERT SELECT). Then they'd both get the same result back from LAST_INSERT_ID() which is obviously NOT what you want. The function returns the last ID inserted on the current connection. As long as those two users' inserts were performed on different connections, they will NOT get the same result from LAST_INSERT_ID().
|
# ¿ Sep 6, 2008 20:41 |
|
No Safe Word posted:I believe you mean transaction instead of connection, but obviously each connection will be a different transaction The value of LAST_INSERT_ID() is still connection-specific without transactions.
|
# ¿ Sep 6, 2008 22:22 |
|
No Safe Word posted:For one of our clients (in the healthcare business) they literally had at least five (and I think it may actually have been seven) options in the gender field. I forget them all, but it was at least: Male, Female, Unspecified and I think there was a "Neither" or "Both" in there somewhere. In an application for a county's department of animal control, there was a table for pets' genders that contained Male, Female, Spayed, and Neutered. It seemed reasonable enough until they started using it for the owner's gender, too.
|
# ¿ Jan 27, 2009 21:04 |
|
Vanadium posted:It's C++. I do not know any, either. remove()?
|
# ¿ May 13, 2009 22:53 |
|
SimpleXML weirdness in PHP Short explanation: the value of a SimpleXML object always resolves to false. php:<? $x = simplexml_load_string('<a><b>test</b></a>'); /* A valid object */ if ($x) { /* true */ } if (!$x) { /* false */ } if ($x === false) { /* false */ } if ($x == false) { /* loving TRUE */ } ?>
|
# ¿ May 28, 2011 20:48 |
|
php has E_ACTUALLY_ALL mysql has mysql_real_escape_string gcc has -W/all/arning/tf and the rest of us has neckbeards making excuses for why it's turtles all the way down
|
# ¿ May 29, 2011 06:42 |
|
Chairman Steve posted:Isn't this part of PHP's API for interacting with MySQL, and not inherently part of MySQL itself? The mysql_real_escape_string() function is part of the MySQL C API. The original PHP API for MySQL was just a bunch of wrappers around C functions. It's a double horror. Edit: Otto said it better. DaTroof fucked around with this message at 06:19 on May 30, 2011 |
# ¿ May 30, 2011 06:13 |
|
BP posted:We use SVN where I work. Depending on your team, it's actually mandated that you comment out code you wish to remove instead of just removing it. You will be called out in code review for not doing so. Wh... why? Does the entire team work off the same checkout?
|
# ¿ Jun 8, 2011 21:19 |
|
Lumpy posted:At the job I just quit, I left blocks like this in commits: I'm sorry to say I've worked projects where I'd see a comment like that and nod understandingly. And then I'd tell marketing that their request would take four days, blame half of it on you, and use the other two days to look for a new job. And those assholes wonder why their "enterprise solution" is falling behind the curve.
|
# ¿ Jun 9, 2011 03:11 |
|
Zamujasa posted:We don't use any version control system. Wow. lovely processes are usually just the result of poor planning, but that one sounds outright hostile.
|
# ¿ Jul 27, 2011 19:56 |
|
angrytech posted:Another controversial opinion: the only people who use spaces for indentation are communists and satanists. That's controversial? Using tabs and setting your own size is the easiest way to eliminate half of any team's formatting debates
|
# ¿ Jul 30, 2011 17:50 |
|
Hammerite posted:I can see why you would say it's fine if you're making a special case of objects. But if you wrote Wait, am I misunderstanding your argument? Because the code you provided echoes "true".
|
# ¿ Aug 11, 2011 18:25 |
|
Hammerite posted:I think so. I'm aware that that code echoes "true", as it should. I'm saying that by analogy, it's not unreasonable (though it could be thought naive) to expect the earlier code involving objects to echo "true", as well. Ah, I see what you mean now. An easy misunderstanding, but not a coding horror, imo.
|
# ¿ Aug 11, 2011 18:50 |
|
Smugdog Millionaire posted:How do you write 100,000 lines of code in a single file before you think to yourself "surely there's a better way to organize this"? A former coworker of mine learned the hard way that VB6 can't load more than 65,534 lines of code in a single module. To give you an idea of how terrible the code was: whenever he received data with a deeper level of recursion than his program could support, he added another nested while loop to all of his functions.
|
# ¿ Oct 29, 2011 00:45 |
|
YeOldeButchere posted:I'm not really sure what is worse here: that you need to load that many lines, that they apparently used a 16 bits integer even though I'm pretty loving sure VB6 never ran on 16 bits platforms, or that the number of lines is 65,534 and not 65,535. The VB limitations were unfortunate, but that guy's code was definitely the worst part of it. There was absolutely no excuse for that module to be more than 5000 or so lines of code. Copy/paste was his version of Maslow's hammer.
|
# ¿ Oct 29, 2011 06:10 |
|
Keevon posted:You know maybe instead of being an angry nerd and writing your paper about how poorly notch wrote a multi million dollar game you could try being productive and write your own game but properly and show him whats what. Maybe he could, but then he would still have a final paper to write.
|
# ¿ Apr 8, 2012 18:58 |
|
Hey guys, how's this for a coding horror:code:
|
# ¿ Apr 9, 2012 08:05 |
|
Suspicious Dish posted:EDIT: I also want to point out that the top result for "php mysql tutorial" also has this issue. So does the w3schools tutorial.
|
# ¿ Apr 25, 2012 20:03 |
|
XML is great for applying semantics and structure to documents. JSON is great for serializing shared data. Both turn to poo poo when you abuse them.
|
# ¿ Apr 28, 2012 01:31 |
|
yaoi prophet posted:
It gets pushed to foo, so foo.length is 1. But if you REALLY want to burn your noodle, tell me why that doesn't work but this does: code:
DaTroof fucked around with this message at 02:40 on Apr 28, 2012 |
# ¿ Apr 28, 2012 02:33 |
|
shrughes posted:Because that's the way Javascript works?? Nothing there is a mystery. If functions are first-class objects, those two snippets should have the same behavior. It's not a killer bug or anything, but it's still weird.
|
# ¿ Apr 28, 2012 02:51 |
|
pseudorandom name posted:push operates on this, not this.elems, I'm not sure why this is surprising. Because push operates on this in the first example, but it operates on this.elems in the second.
|
# ¿ Apr 28, 2012 02:59 |
|
pseudorandom name posted:Well, yeah, you're calling this.elems.push() instead of this.push(). None of this is weird or surprising. They both use foo.push(), but only one of them pushes to foo.elems. Point being, I don't know why assigning an anonymous function to this.push works, but this doesn't: code:
|
# ¿ Apr 28, 2012 03:14 |
|
ToxicFrog posted:Functions are first class objects but they aren't closures over their enclosing object; this is passed to the function at call time. Ahh, that actually makes sense. Still seems weird to me, but I get the logic now. Thanks.
|
# ¿ Apr 28, 2012 03:17 |
|
Suspicious Dish posted:The this argument is whatever is on the left-hand side of the call. Unlike other languages where a.b.c(); can be decomposed into var f = a.b.c; f();, JS needs the qualification. And after that, it doesn't even seem weird anymore. Sheesh. Maybe I need some sleep.
|
# ¿ Apr 28, 2012 03:24 |
|
Bhaal posted:My dad got an EE associates there in the 70s . I don't think it had that reputation back then, or at least he lucked out and got teachers who gave a poo poo because he got enough education from there to start his career of circuit designing, starting with DEC right out of school. I get the impression that ITT didn't turn into complete poo poo until the 90s. It's always been a meat-and-potatoes trade school, but it might not have always been worthless. One of the senior developers at my company has a degree from ITT. We basically ignored it. His technical acumen and his demonstrable work experience got him hired. Without the degree, we would have hired him anyway.
|
# ¿ May 15, 2012 02:42 |
|
epswing posted:I don't doubt that, but would he have had an interview in the first place without the degree? Yes, but you bring up a legitimate point. In my company, applications for the development team come straight to the development team. If they went through an HR department with an arbitrary set of guidelines to follow, a lack of degree might have kept us from seeing it.
|
# ¿ May 15, 2012 02:58 |
|
tef posted:I tend to find code beautiful in theory and rarely in practice. Code can only be as beautiful as the problem it solves, and most of the problems we face are ugly. That's why I was tempted to cite jQuery as an example of good code, even though the code itself isn't beautiful. It provides an elegant interface that solves difficult problems, which is often way more important than the underlying implementation.
|
# ¿ Jun 16, 2012 05:37 |
|
That Turkey Story posted:Err... what??? How can you possibly push the blame onto C. Presumably he's saying that PHP functions are inconsistent because so many of them are thin wrappers around C library APIs that are inconsistent with each other. It's a plausible explanation that excuses nothing.
|
# ¿ Jul 7, 2012 19:52 |
|
Suspicious Dish posted:In most languages, this would be the only case where $a != $a. But this is PHP. I'm sort of curious now, does PHP have any other edge cases like this? php:<?php $xml = simplexml_load_string('<foo/>'); var_dump($xml == false); // true var_dump($xml == 0); // true var_dump($xml); // SimpleXMLElement $xml = simplexml_load_string('<foo>bar</foo>'); var_dump($xml == false); // false var_dump($xml == 0); // true var_dump($xml); // SimpleXMLElement
|
# ¿ Sep 5, 2012 18:05 |
|
Hammerite posted:That violates transitivity, but that's old news. The question was about cases that violate reflexivity. Fair enough. I can't think of anything that doesn't involve coercion abuse.
|
# ¿ Sep 5, 2012 18:37 |
|
Lumpy posted:You fool! Now the one DIV where they didn't want those colors is all wrong!! Put them back! I wanted to believe it was generated from a WYSIWYG, but the comments indicate otherwise.
|
# ¿ Sep 14, 2012 13:55 |
|
The Gripper posted:I spend most of my free time at AA, reading nametags. And I'm sure the frequency of members using unpronounceable symbols to identify themselves is a problem that destroys meetings.
|
# ¿ Oct 26, 2012 01:50 |
|
Suspicious Dish posted:What part of that is OO's blame? From the article: quote:It's not that OOP is bad or even flawed. It's that object-oriented programming isn't the fundamental particle of computing that some people want it to be. When blindly applied to problems below an arbitrary complexity threshold, OOP can be verbose and contrived, yet there's often an aesthetic insistence on objects for everything all the way down. That's too bad, because it makes it harder to identify the cases where an object-oriented style truly results in an overall simplicity and ease of understanding.
|
# ¿ Dec 10, 2012 01:02 |
|
|
# ¿ Apr 26, 2024 15:34 |
|
Deus Rex posted:this reminds me of my first attempt at registering a domain name, which was to rename an HTML file to 'helloworld.com' and double-clicking it in Windows When I tried to make my first video game on a VIC-20, I just wrote a couple dozen PRINT statements that described the game. Then I ran it and experienced the earliest epiphany I can remember.
|
# ¿ Dec 24, 2012 22:04 |