The PHP 7 Revolution: Return Types and Removed Artifacts

Which is exactly what a singleton is, a single instance of one class. “Some people” here is a red-herring. Singletons (and globals) have been objectively shown to cause problems (limited flexibility being the main one). Using them introduces problems in your codebase, which don’t need to be there.

You can hammer in a screw rather than screwing it in. It’ll work but it’ll be a pain if you need to unscrew it again. A skilled tradesman will tell you it’s a bodge job, the fact that you can do something in an objectively inferior way doesn’t mean you should.

[quote]Don’t be ridiculous. Encapsulation, Inheritance and Polymorphism are the fundamental principles of OO, so to now say that one of those principles breaks one of the others is laughable. Where did this idea come from? On the back of a packet of cornflakes? A joke in a Christmas Cracker?
[/quote]

Programmers far more experienced than you. I provided several references, the most notable being the highly regarded Gang of Four book, but here’s a few more:

http://dl.acm.org/citation.cfm?id=28702
http://eprints.uni-kiel.de/14597/1/HasselbringHandbookSE2002.pdf
http://research.microsoft.com/en-us/um/people/cszypers/pub/cioo96.pdf
http://www.javaworld.com/article/2073649/core-java/why-extends-is-evil.html
http://en.wikipedia.org/wiki/Composition_over_inheritance

Anyway it’s clear that you’re stuck in your ways and nothing is going to change that. I’ve provided references from academia, books and the blogs of professional programmers to back up my points. I suggest you read them.

As others in this topic have discovered, trying to have a meaningful discussion with you is futile so I’m out.

2 Likes