3 ms·
Testing isn't just about preventing bugs, it also encourages better design, and good design makes extending and enhancing your application much easier and faste
by samd 14y ago
Testing isn't just about preventing bugs, it also encourages better design, and good design makes extending and enhancing your application much easier and faster.
...in general, of course, there's always exceptions, don't be dogmatic.
- romaniv 14y agoI think this aspect of unit testing is largely overrated. True, it does stop people from writing something ridiculous, like a 1000-line method that handles a dozen different things. But it also encourages developers to go overboard in the other direction: creating endless, needless layers of abstraction, chopping logic into bits that are to small to represent anything in reality and doing dependency injection when it's not needed. It's important to keep in mind that ease of unit testing doesn't automatically ensure ease of use of your library in real code. In short, it's better to think of unit testing as bug-prevention mechanism. Thinking of it as an ultimate design mechanism doesn't end up well.