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.
Showing posts with label rant. Show all posts
Showing posts with label rant. Show all posts
Wednesday, July 16, 2008
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:
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
Friday, February 29, 2008
deconstructing xyster
I've stumpled across a new framework called xyster and it's not surprising that behind the fancy web 2.0 website is lurking something evil.
Xyster is an extension to Zend Framework and extends ACL, MVC with some features and uses the Database Layer for an ORM package. So what is the evil in xyster? Evil is the Xyster_Collection package. Everyone who knows Java's collection mess. Everyone who envied languages with object oriented array's. Will have some (good or bad) emotion now. But this is not the point. The points are interoperability and simplicity. It isn't easy nor fun to convert from/to collection Foo, again and again. Indeed, in Java this is common, but Java sucks exactly for this reason (and some others)! PHP does better, just hand over some native array's that work everywhere. And if you really need a fancy collection-like-something, create an highly specialized version and integrate it in the specific domain.
There is one small chance to create a collection framework for PHP that is interoperable. Write an RFC. Write an native extension. Start an petition. Pray. An don't forget to become a landowner, in case rasmus comes around and kills you with a roundhouse kick.
This fact would be a great disadvantage, if i had a need for xyster (or any other framework with the same flaws).
Xyster is an extension to Zend Framework and extends ACL, MVC with some features and uses the Database Layer for an ORM package. So what is the evil in xyster? Evil is the Xyster_Collection package. Everyone who knows Java's collection mess. Everyone who envied languages with object oriented array's. Will have some (good or bad) emotion now. But this is not the point. The points are interoperability and simplicity. It isn't easy nor fun to convert from/to collection Foo, again and again. Indeed, in Java this is common, but Java sucks exactly for this reason (and some others)! PHP does better, just hand over some native array's that work everywhere. And if you really need a fancy collection-like-something, create an highly specialized version and integrate it in the specific domain.
There is one small chance to create a collection framework for PHP that is interoperable. Write an RFC. Write an native extension. Start an petition. Pray. An don't forget to become a landowner, in case rasmus comes around and kills you with a roundhouse kick.
This fact would be a great disadvantage, if i had a need for xyster (or any other framework with the same flaws).
Labels:
antipattern,
framework,
interoperability,
php,
phpism,
programming,
rant,
xyster
Subscribe to:
Posts (Atom)