I encounter this a lot in PHP where beginners and even many intermediate level developers are DEATHLY afraid of objects. It scares them away from even considering the vastly superior PDO, and it makes them use the pointless bloated mysqli_ functional wrappers instead of the object version -- even when said wrappers are pretty much full Pakled. You never go full Pakled.
I know I've been programming for so long objects are second nature, having learned them decades ago in Modula and Smalltalk -- but the level of resistance, hate, and outright fear I encounter regularly when you suggest using objects instead goes above and beyond any rational reason I can think of.
I just don't understand where this fear comes from since if the difference between this:
if (mysqli_stmt_fetch($stmt)) {
and this:
if ($stmt->fetch()) {
Is so hard to use that their reaction borders on outright terror, how the blazes did they even get as far as using the former?!?
I'd like a beginner's insight or explanation by someone who has this mentality as I'm trying to understand where it comes from as without that understanding, it's VERY hard for me not to be outright insulting about it.
Jason Knight I guess you have seen the same kind of code I see some times.
Like overuse or _SESSION and a couple of function (usually very long) with many global entries in them?
It happens that PHP devs (at least from what I can tell around me) do not have a real IT background so even if they know objects are a thing, they don't "switch" to that methodology.
I use objects (even if it's only static classes) to wrap my functions nicely.
I always favour objects even when working with arrays or json. I think objects are more logical.
When it comes to database I went from the old MySQL to PDO using the object route. When not working in a framework I use a PDO wrapper (OOP Class) I wrote to make access data easier.
If you haven't embraced objects you, give them a try!
Exactly, Even I have seen developers afraid of using objects.
Most of the PHP developers never work extensively with pure object oriented languages and hence they never realize the true power of objects.
Web-developers using PHP hardly deal with anything that can force them to use object oriented approach. ( PHP - work can be done without using objects, JavaScript - Its up-to you, your wish again ) .
Even when people are using Java on server they try to stay away from Objects in JS :P
However, i love using Object Oriented Style no matter i'm coding in PHP, JS or Java.
Ghazouane
code ♥ surf
You said it : beginners !!
Beginners + OOP = f*cking chaos (composition ? inheritance ? static ? private ? public ? asbtract ? interface ? polymorphism ? instance ? class ? OMG just let me call my function)
There is a work to understand OOP. Beginners are dealing with routing, view, db, ... So they do not give the necessary work to (very) understand what is OOP and stay afraid of until they are forced to use it.
Well, this is a supposition as i see many people are afraid of OOP.
Cheers !