Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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:
function forCase() {
	if (firstProcess()) {
		return a;
	}
	if (secondProcess()) {
		return b;
	}
	if (thirdProcess()) {
		return c;
	}
}
Especially since a, b, and c can be made into something more useful than an iterator value with a vague and possibly transient meaning.

Adbot
ADBOT LOVES YOU

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof
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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

1337JiveTurkey posted:

This'll probably horrify some posters, but I like:
code:
blah =	!isset(bravo)?	here(something) :
	isset(charlie)?	here(charlie) :
			nothere();
Conditions in one column, values in another and it's easy to quickly scan for what goes with what with the general else condition going at the end.

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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().

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Vanadium posted:

It's C++. I do not know any, either.

remove()?

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof
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 */ }
?>
I'm still not sure why anyone would think this behavior is correct or even desirable.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof
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

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Chairman Steve posted:

Isn't this part of PHP's API for interacting with MySQL, and not inherently part of MySQL itself?

Oh, PHP, a language that lets you define when you really mean it.

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

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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?

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Lumpy posted:

At the job I just quit, I left blocks like this in commits:
code:
/* This is code marketing asked for last week, but today they decided they 
* didn't want it, but I know the focus group tomorrow :suicide: will whine
* and they'll beg me to put it back in and I will tell then it will take two days
* and I will use that time to look for a new job

/// code 

*/

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Zamujasa posted:

We don't use any version control system.

In fact, the entire development process is as follows:

1. Install the in-house MegaCMS™. It's Zend-Guard encrypted, ofc.
2. Copy over the files for the portion we're changing to our private sites, from the private "developer server" (that is, a webserver with a lot of development files and a copy of the source code).
3. Make changes on our personal site.
4. Ship the changes over to the lead developer/CTO who will implement it the next time he does a release (currently about every 1 1/2 months), assuming it gets into that release.


That's not even getting into the code, which is abysmal. There's no documentation — even to the point the programmers are tasked with "mak[ing] a cheat sheet" on how to use one of the few classes we have, a formbuilder/validation system — almost no comments, and the various files are (ofc) Zend Guarded.

I tried asking for a copy of the source to go through and got reminded that we're supposed to develop on our encrypted copies.

:suicide:

Wow. lovely processes are usually just the result of poor planning, but that one sounds outright hostile.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

angrytech posted:

Another controversial opinion: the only people who use spaces for indentation are communists and satanists.
If you are using an IDE that doesn't allow you to set the number of spaces defined by a tab, then you a scrub.

That's controversial?

Using tabs and setting your own size is the easiest way to eliminate half of any team's formatting debates

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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

code:
$a = 5;
$b = 5;
echo $a === $b ? 'true' : 'false';
you would expect PHP to echo "true". So it is really only fine if, as I said, you anticipate it being very difficult to test whether two objects are equal, so you resort to saying that objects aren't in general equal and they should only test equal if they refer to the same thing.

But it is clear to a reader that those two things are equal. You could impose the rule that the data members of the objects are checked and if they are the same, the objects are equal. Better, though, would be to let the developer define a way to test whether two objects of a given class are equal. Unfortunately PHP doesn't do that.

Wait, am I misunderstanding your argument? Because the code you provided echoes "true".

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof
Hey guys, how's this for a coding horror:

code:
$.post('newreply.php', {
    threadid: '2803713',
    message: 'Anything about Minecraft'
});

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof
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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

yaoi prophet posted:

code:
function Foo() {
    this.elems = [];
    this.push = this.elems.push;
}

foo = new Foo();
foo.push(1);
foo.elems.length == 0; // true

foo.elems.push(1);
foo.elems.length == 1; //true
:allears:

Bonus points to anybody who knows where the hell the first 1 gets pushed.

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:
function Foo() {
    this.elems = [];
    this.push = function() {
        for (var a in arguments) {
            this.elems.push(arguments[a]);
        }
    }
}
foo = new Foo();
foo.push(1);
foo.elems.length == 1; // true
:crossarms:

DaTroof fucked around with this message at 02:40 on Apr 28, 2012

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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:
this.push = this.elems.push;

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

So:

code:
function Foo() {
    this.elems = [];
    this.push = this.elems.push;
}

foo = new Foo();
foo.push(1);       // this == foo
foo.elems.push(1); // this == foo.elems
Same function is called both times, but on different objects.

Ahh, that actually makes sense. Still seems weird to me, but I get the logic now. Thanks.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Bhaal posted:

My dad got an EE associates there in the 70s :smith:. 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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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

:negative:

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Lumpy posted:

You fool! Now the one DIV where they didn't want those colors is all wrong!! Put them back!

My guess is that whoever wrote than has no clue what a .class is.

I wanted to believe it was generated from a WYSIWYG, but the comments indicate otherwise.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

Adbot
ADBOT LOVES YOU

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

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.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply