Lord Yggdrasill;11013153 wrote:Well I've heard many times in both PHP and Java world that Static Methods are not good design.
I've also heard many times that green isn't as good of a color as blue. That hasn't changed the fact that green is my favorite color, though.
Sarcastic banter aside, I really think there's enough justification for the use of static methods to prevent someone from categorically denouncing them. In fact, one justification for their use can actually be found in the blog entry you linked:
Tom Butler wrote:db::query() is functionally identical to db_query(). A global function. Which is all static methods are, namespaced global functions.
Exactly - they're "namespaced." If you happened upon a bit of code that contained db_query(), you might not know whether this was some local function or not. However, if you saw "db::query()" instead, you'd assume that you can find everything you want to know about what that query() static method is returning by referencing the 'db' class.
Why pollute the global namespace with functions and variables that don't belong there but can more appropriately be grouped together as static members of a class?
Lord Yggdrasill;11013153 wrote:Is Static methods poor OOP practices?
In my opinion, not always, no. For example, one ideal candidate for the use of static methods would be in a Factory pattern.
Can static methods be stripped from the OOP world and instead shoved back into the procedural world? Most likely, yes. But then again, you could get rid of OOP all together and revert to pure procedural, too. Just because it's possible doesn't mean not doing it is bad practice.