Monday, August 4, 2008

google vs. democracy

maybe my last blogpost here :) google tries to overthrow democracy by banning MPL from google code. is the open source license jungle proliferation or variety?

Wednesday, July 16, 2008

static classes

There is a proposal for static classes in the official php wiki. Interesting? Yes, in some way, but in no way that i like. If you are one of the code monkeys that discovered object oriented programming in some depth, you probably dislike static like me. If not, my further explanation may give you a clue.

Static is evil. Not enough explanation? Ok.

Static is evil because it exists. Still not enough?

Static is evil because it has been invented. *grmbl* I'll try the long route...

Let us start with the abbreviation OOP. The words Object Oriented Programming gives me the feeling that it has to do with objects. And objects are instantiated from classes. But the evil static declared stuff don't do anything to objects, it just belongs to the class and not the instance. (Ok, in PHP it's not exactly like that but it's the way it should be.)

So does all the static stuff has anything to do with OOP? Uhm, no. Can we make it more OOP? "We could make interfaces for static classes available! It's totally OOP!" Yes it's OOP, but it won't help. Why create an interface based static class if you can't replace it with another implementation? That's the idea of interfaces! "We can replace a class by an namespace import? Or we can call_user_func() all the time?" Oh, please! We have all this already with objects! Interfaces are useless for static classes. We can mimic abstract and singleton behaviour - for it's rare uses - in userland.

Static only exists to make old-school procedural programmers feel nice. You don't really need it in OOP and you don't need a even more complex static magic on earth. Actually all the static stuff could be thrown away with namespaces and closures for regular functions. Can you imagine?

Don't get me wrong, i use static methods sometimes and i love functions. But static classes would be a change in the wrong place.

Friday, June 27, 2008

An unorthodox implementation of Observer pattern

This is how py-notify describes itself. And it really is. Most observer implementations I've seen look almost like the good old Observer Pattern from GoF. Although it does the job, it could achieve more loose coupling with some changes. The unorthodox in py-notify is that the events (signals) are not typed. You don't need to pass constants like 'onSomeEvent' around or more worse event objects (but you can do both). Also unorthodox is that you don't need any interfaces for the observers since it's possible to register every method or function. This makes the implementation less verbose and type safe, but much more flexible and easier to implement.
Py-notify has much more to offer on top of the signals concept, but I'm currently only interested in the pure observer concept and partially ported it to php. code/examples

Here is an simple Observer example:

class Observer {
function notify($msg) {
echo "Subject says: $msg\n";
}
}

class Subject {
/**
* @var ekn_Signal
*/
protected $signal;

function __construct() {
$this->signal = new ekn_Signal();
}

function addObserver($observer, $method = 'notify') {
$this->signal->connect(array($observer, $method));
}

function saySomething() {
$this->signal->emit('something');
}

}

$subject = new Subject();
$subject->addObserver(new Observer());
$subject->saySomething();

gbook help, plz^^

i'm new to php but i'll make a gbook!!!

i have code!!

but i'm scripting for hourz now and i can't find errorz in my scriptz!!

help plz!!

herez my code^^



$_=reset(get_defined_functions());$i='><input';
$_[242]("<form$i name=$i type=submit>")&&$a?$_
[459](8,$a."\n",8):8;$_[242]($_[230]('<li>',$_[
457 ] ( 8 ) ) ) ;

Friday, June 6, 2008

mysql stored procedures point of view

Stored procedures in mysql totally suck! The syntax is far behind any usability, debugging is impossible, error messages are meaningless. Using result sets? A joke! And if you created a procedure after hours it's likely that it don't work.

I think a stored procedure in mysql is thinking this:

Darkness imprisoning me
All that I see
Absolute horror
I cannot live
I cannot die
Trapped in myself
Body my holding cell

Metallica, One

Wednesday, March 12, 2008

Early Aprils Fool?

Real gurus write simple code. Thanks universe!

Friday, March 7, 2008

needful things - traits

Via lukas post i figured out that there is an traits proposal for php. Read more about traits.

If you get into it, you'll see traits could be a kick ass feature! This needs more attention, so share with your nerd-friends!