top | item 5632556

(no title)

tabbyjabby | 13 years ago

I'd just like to note that that is not a particularly OO solution. You've essentially created a namespaced function. While this is still preferable to a bare function in a heterogenous helpers function file, it's certainly not a pure OO way of accomplishing the encapsulation of the InputSanitizer.

discuss

order

yogo|13 years ago

This is a problem that goes all the way to the core. It isn't very good OO (some will argue PHP isn't really OO anyway) because core types are not objects. Whether you have substr(..., ...), Helper::substr(..., ...) or getSomeInstance()->substr(..., ...) it's really all the same, with maybe some added benefits if you provide some wrapper functionality as in the last case.

rmrfrmrf|13 years ago

   $username = InputSanitizer::getInstance()->getPostData('username');
There. Now it's OO ;P.

z92|13 years ago

I would rather use Java in that case.

Shorel|13 years ago

And very fortunately so. 'Pure' OO is the madness that created Java.

Encapsulation is overrated. So overrated that you need another fancy concept like 'dependency injection' when it just gets in the way.

The static function is simple and because of that, it is good.

eru|13 years ago

tabbyjabby didn't say it's bad. They just said it's not OO.