PHP Tip: Always Put Constants on the Left in Boolean Comparisons

This was a standard I enforced at my last company: Whenever you are doing a boolean check (such as an IF or WHILE), always place constants on the left side of the comparison. The following is BAD: // BAD if($user == LOGGED_IN) { The following is good: // GOOD if(LOGGED_IN == $user) { Why is […]

Incentives and the Related Dangers

Incentives are just as dangerous as they are powerful. I have the running theory that most incentives can actually do the exact opposite of the intended goal when executed wrong. Let’s start with an example to illustrate. You’re in charge of a small company that picks up garbage after events like street fairs and parades. […]

The Destruction of the Head Hunting Industry

This is a random thought that just popped in my head. With information becoming increasingly available, I’ve been thinking that the headhunting business will go through a major destructive phase in the next few years. There are two things the Internet changed: Better distribution of information on job openings Better distribution of information on candidates Definition: For […]

Google’s Real Goal Behind All Their Free APIs

Ever wonder why Google gives away so many web-developer tools? Tools that otherwise seem like complete money-and-bandwidth-pissing schemes (notice how most of these don’t directly show ads): Maps Widgets Charts API Open Social YouTube embeds Unified AJAX libraries Android General Search APIs This is all about obtaining browsing behavior in a long term bid to […]

BUG: Constructors, Interfaces, and Abstracts Don’t Mix Well

I just discovered a bug today in PHP 5.1 (haven’t confirmed if it was fixed in newer versions). When trying to enforce interface arguments on constructors, PHP behaves unexpectedly. Normally, interfaces allow you to enforce argument counts or types in child class methods, but not with the constructor (and probably destructor). Crash course on interfaces: […]