by akeefer · 18y ago · 0 comments
The item about polymorphism strikes me as bogus too. But then again, I absolutely abhor mocks, because my experience has been that the mocks end up diverging from the real production code and you end up with either tests that don't break when the app is broken or tests that break when the app isn't broken, so optimizing for mocking is a horrible idea in my book.
Composition over inheritance is generally a good idea, but it is actually useful for testability, though not for the reasons the author mentions. Deep inheritance hierarchies make things hard to test because testing a leaf class in the hierarchy naturally means you're testing every other class up the chain, making it very hard to test just the code on that leaf class. Deep hierarchies like that also usually involve some contract between the different levels that's inherently hard to test for.
No comments yet.