Abstract
Object-oriented programming is becoming the standard of PHP code; however, just sticking a lot of functions into a class is not enough to change the programming paradigm. What happened in languages such as C++ and Java, being used mostly procedurally, is happening in the PHP world.
During this talk we will discuss the pitfalls of object-oriented programming as taught by the PHP manual, and the common problems that a PHP developer encounters. For example:
- what to do of getters and setters, and the Tell Don’t Ask principle.
- when and how to segregate construction logic (new operators); when it doesn’t matter;
- the Singleton smell and what are the alternatives to this old pattern;
- the static Utility class smell;
- the Manager class smell.
We will also see some comparisons with the original object-oriented language, Smalltalk. But sometimes to understand how to do it right, we should first show how to do it wrong.