3 ms·
I share your perspective on this. I have also found that writing tests forces you to write testable code (goes without saying). Often times, if code is impossib
by xwowsersx 12y ago
I share your perspective on this. I have also found that writing tests forces you to write testable code (goes without saying). Often times, if code is impossible to test and requires to you to mock and inject a bunch of different things just to write the test then you're design is probably no good. So, while this necessarily mean you have to do TDD, it's interesting to see that testable code and good design kind of line up.
- tieTYT 12y ago> it's interesting to see that testable code and good design kind of line up They can line up, but I'm not sure there's a causation. There are many different ways to write tests the wrong way. It's taken a lot of trail and error for me to get better at it (I can't even say I'm "great" yet). I'd have given up long ago if I wasn't a passionate developer. A less passionate developer would think the whole concept is BS and give up long ago if he took my path. One of the first mistakes I made was using a mocking framework to test my implementation. The test read like, "first call this method, then call this, then call this". Needless to say it was worthless. I was just writing my code twice. Then you can use mocks inside-out and end up writing code you don't even need to call, etc. I'm sure there's many ways to do TDD right, but from in my personal experience, there's more ways to do it wrong.