Global variables are common pitfalls many developers fall into. Indeed, difficult to scale and maintain an application crippled with globals. Why is that? Isn't it convenient to be able to access variables and their values everywhere? The global state problem is only part of a bigger one, namely leaking states and the lack of encapsulation.
Simplicity is one of the most important concept to understand and apply as a developer. This article will first define what simplicity and complexity mean. Then, I will explain why simplicity is really important, to finally go over the main practices you can apply to make your codebase simpler.
Today is a great day: you will begin to develop the new greenfield project of the soon-very-successful startup you work for, as a PHP Ninja Wizard of the Crown. But wait! You're teaming with Dave, your colleague developer! He's creating an Anemic Domain Model! Why? Is it that bad?
The DRY principle (Don't Repeat Yourself) is easy to understand but difficult to apply. Should we never repeat our code? What was the true purpose of the principle's authors? Let's decipher what should be DRY in our code, and what should not.