
The state of OOP in PHP - fredastaire
I just hat a look at the code of PHP Unit and must say this is one of the many examples where a key library uses the worst OOP patterns that lead to a complex nightmare of data ping-pong. Is there any movement that with a name against this sort of overdona OOP? Have seen this on many projects and there is so much wrong about it that I dont know where to start. It seems like OOP in PHP has a tendency to overcompensate the fact that it had been treated as kids language with spaghetti code for a long time.<p>My proposal for better code:
Don&#x27;t do public and private
Don&#x27;t use $this and use static classes
Don&#x27;t overload and dont use interfaces
Don&#x27;t do namespaces<p>Might sound a bit backwards but I am really sick of seeing this mindless OOP shit all over the place ...
======
smt88
> _Don 't do public and private Don't use $this and use static classes Don't
> overload_

You should look into functional programming.

> _and dont use interfaces_

Uhh... I guess? Interfaces are way of implementing a type system (e.g.
discriminating unions) and also necessary for mocking up tests in many OOP
projects.

> _Don 't use namespaces_

This is just a terrible idea. Namespaces are used in almost every language to
avoid collisions. Sometimes they are in the form of classes, but namespacing
is hugely important.

------
nik736
Maybe you should work on yourself instead of blaming PHP OOP code that sounds
just fine.

------
ccajas
> the fact that it had been treated as kids language with spaghetti code for a
> long time

Try using PHP with a framework.

krapp 1388 days ago [-]

Most of the arguments I've heard against PHP seem to amount to 'PHP is doesn't
semantically resemble this other language I prefer and therefore it needs to
go away.'

------
slosh
Can you explain more about what you don't like and the reasoning for it? and
can you explain more about the things you are telling us to do? this other
comment doesn't leave a lot of faith in your claims

------
meric
Sounds like you might enjoy Python. It's almost as you've described.

------
eecks
What is wrong with access modifiers?

