Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The method that works best for me is from code complete. McConnell argues (correctly, IMO) that tests are a technique, and writing tests means more code to maintain and debug. Tests can be wrong, and if the test is wrong, the code will also be wrong. Thus, a bug is introduced. He advocates first making sure you have good software design, i.e. components are laid out, how they're going to interact with each other is well defined. So before writing any code at all, make sure you have a documented design that works conceptually.

Define the systems that make up your software, the classes that make up the systems, and then the functions they'll use to talk to each other. Once it works on paper, start coding. If the design is good, the code should be so brain dead simple to write that a monkey could write it.

I find doing this I do end up with long call stacks, because each module will do something, then pass the data on like an assembly line. In each step my functions are super short and I don't find it worth writing a test for 3 lines of code that I can tell is correct at a glance. For those few meaty functions that do more heavy logic, I will write tests for, though.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: