maandag 20 april 2009

Why I hate developing in PHP

This is wrong at so many levels:

if($this->mail_protocol == "pop3")
{
$port = "110";
}
else
{
if($mods["imap"]["SSL Support"] == "enabled" && ($this->ssltype == "tls" || $this->ssltype == "ssl"))
{
$port = "993";
}
else
{
$port = "143";
}
}



Whoever can name the most anti-patterns in this small snippet wins a honorable mention in the credits of this post.

2 opmerkingen:

Unknown zei

This isn't the problem of PHP. you can do the very same thing in any other language

Erik van Brakel zei

@tehlike:
Agreed, but PHP makes it so painfully obvious that you can. There's a few reasons most PHP samples you find on the web are low quality (even the ones in the online manual are questionable).
One of those reasons is that PHP is very easy to get into, which is good in itself. However, people who are relatively new to programming think they're good at PHP, post samples like this and tell others to do it as well. Take a good look at a bunch of popular PHP projects, and weep.