Code Stutter

In all my experience as programmer (~9 years) I have contemplated, seen and created a few coding and naming conventions. But there was one kind of convention that always struck me as odd and lately as extremely annoying.
Read more of this post

PHP and PDO – Use it!

A lot of novice programmers exploring object orientation get their feet wet by implementing a database abstraction class. It’s a good learning assignment, but has no more use in production code ever since PHP introduced PDO.
Read more of this post

PHP project and library structure tips

I thought I’d share some tips on working on larger projects, and how to name and structure stuff.  Most importantly, whatever conventions you come up with, they should be as simple as possible, but no simpler.  If these conventions and structures are too complicated, no one (not even yourself) will adhere to them and everything will revert/degrade into one big mess in a heart beat.  However, they shouldn’t be too simplistic (constrictive) to keep you from extending them (ie. rules like: only one depth of namespaces, only 20 characters for class names.)

Read more of this post

Returning Arrays from __get

Sometimes you have a class that has magic properties, ie. it implements property access overload methods. And you might have had the problem that one of these magic properties holds an array. And you just can’t seem to update that array what-so-ever.

Read more of this post

About Overloading…

I was playing around with PHP’s overload operators and wondered what would happen if you overloaded both __call() and __get(). Turns out PHP does the right thing (for once). If you use the function call syntax on the magic property, the __cal()l overload is used and if you don’t PHP uses the __get()/__set() overload.

This could be used to create some funky black magic code…

Polymorphic Methods in PHP5

Since PHP does not allow function/method overloading, it has become practice to define functions/methods following a scheme of function <funcname><typename>(). So I thought to myself, maybe there is a way to use that naming scheme, PHP’s variable function names together with some inflection and create the polymorpic dispatch myself.

Read more of this post