> Fear of Adding Classes<p>I've seen this a lot, and is often made worse by attaching a load of unnecessary baggage/repurposing to classes.<p>For example, I've worked on PHP projects which, over time, have gained coding standards like:<p>- All classes should be in separate files, named to match the class name<p>- All classes should be built from a PHPSpec specification<p>- All classes should have their own test class<p>- No class can instantiate another, unless it's a "Manager" class which does only that. Everything else is dependency injected.<p>- Test classes can only instantiate their associated class; everything else must be mocked<p>And so on.<p>Now, each of these has its merits, but as each new practice was added, it increased the 'fear of adding classes', even if just subconsciously. Refactoring to break up classes became less and less common, since a simple code change would require:<p>- Whole new test classes (OK)<p>- New files (seems a bit like Java-envy, but OK)<p>- Injecting new instances wherever the old class was used (seems a bit overkill...)<p>- Mocking the behaviour of the first class in tests for the second, and vice versa (this is getting a bit silly...)<p>- Creating 'Manager' classes to instantiate the new classes (hmm...)<p>- Creating new test classes for these managers (erm...)<p>- Mocking the dependencies of the managers...<p>In the end, it was just far easier to just throw all new logic into existing classes, which grew and grew.