Archive for July, 2008

Object oriented PHP - a disappointment

Thursday, July 31st, 2008

It’s no news that PHP supports objects, and has been for a while now. Even if objects in PHP, before version 5, internally is represented as an array, with the result that all methods and properties are public, this was rapidly accepted and used by the community. As of PHP 5 the Zend Engine was rewritten and got a “robust and extensible object model”. This sounds good and at least it got my hopes up for OOP in PHP. It doesn’t really matter but I can mention that I’m currently running Apache 2.2.9 and PHP 5.2.6 on Windows XP, that’s the versions used for running the code below.

Unfortunately I’ve not been able to really try the OOP support in PHP 5 until now and I must say that I’m not impressed this far. Sure, PHP now internally supports a more resource saving object model which also offers common OOP functionality but you can’t still use it in a real OOP manner. For example there is no real support for overriding a method or extending an interface like in the code below.

I suggest that PHP should be divided into two separate branches, “PHP procedural” and “object oriented PHP”. The latter would benefit if it was separated and the focus changed to fit larger projects where OOP really can ease the development. This is not possible today.

I also feel that I can’t post this without mentioning the experimental PHP extension “Object overloading” and this pretty much applies to overloading in PHP 5 as well. In PHP overloading ‘provides means to dynamically “create” members and methods’. Consider it an extension of variable variables. I can honestly not see the benefits of such an extension. It produces code that is harder to read, debug and maintain. Personally I think it’s a very ugly solution (due to a poor design) and not necessary when developing web applications.

class O {}

interface S {
public function a(O $var);
}

interface E extends S {
public function a();
}

class MyS extends O implements S {}
class MyE extends MyS implements E {}

I end this by saying that I hope that I’ll be proved wrong.

Diablo 3 by Blizzard

Tuesday, July 1st, 2008

It is now announced that there will be a Diablo 3. I must say, that for a while I was in doubt due to the width of World of WarCraft, that it in a way resembles the Diablo series. Luckily I was wrong. I am really just as excited now for the upcoming Diablo 3 as I was back in 1996 while waiting for the first version of the game. Now I’m in eager expectation for more previews and media of the new game.

For me that do not play that much computer games, I only play to relax from work and “must-dos”, I must say that Diablo 3 seems more promising than the next version in the StarCraft series. While StarCraft 2 really focuses on strategy, and as I understand, requires that you know all the units from the different races to be able to play efficiently. Brute force is less of an option. In Diablo 3 I hope that you can play like before, relaxed and infrequent.