Global Variables and States: Why So Much Hate?

Global Variables and States: Why So Much Hate?

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.

The DRY Principle: Benefits and Costs with Examples

The DRY Principle: Benefits and Costs with Examples

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.