Chapter 9. Services and Service Containers

Imagine that you are in charge of maintaining a legacy code and you find a couple of classes, with over 1,000 lines of code each, which have a long list of variables, constants, methods, and so on. What a mess; even reading that code takes ages, let alone understanding and maintaining it.

You might think, okay, I can break down those big classes into, say, 10 smaller ones and instantiate them in the main class. This helps a little, but it still wastes a lot of memory and, more importantly, it is hard to test and maintain them because they are tightly coupled to each other.

So what is the solution? The best way to deal with situations like this (or implementing a big project from scratch) is to read and ...

Get Mastering Symfony now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.