by ajross · 18y ago · 0 comments
(And it also seems to be introducing jargon that isn't required: what on earth is a "seem". Is he trying to say "seam"? Is that something I should have heard before?)
Point 8 ("favor polymorphism over conditionals") is also pretty sketchy. I buy the argument that this makes things more testable, I guess, but there's a long-understood readability argument against this kind of thing. That kind of hyper-pure-OOP leads to unreadable code that stretches even simple algorithms across dozens of classes and source files.
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.
1. Good modular design is easy to write unit test for and doesn't require design pattern contortions. New is not a modern day plague to be avoided at all costs.
7. and 8. Taking things too far. You can not get a good design with a lot of hard and fast rules. But you might avoid terrible, impossible to maintain code. I think I see the problem now, google is about managing a whole lot of average coders, not great hackers.
Not the best software writing, kind of enterpise-ey sounding.
I also detect a hint of someone writes code, someone else writes test for it - BAD. Unit tests should be written by who ever wrote the code that is being tested. Preferably unit test first, then code.
But yeah, it's not as simple as removing "new" calls from application logic; it depends entirely on what you're trying to construct.