“Twelve Benefits of Writing Unit Tests First”

I ran across this post today. It’s more than a year old, but it’s still quite valid.

I discovered the joys of unit tests a couple years ago, when I was developing an internal library of C++ classes and functions. Every time I made a change, I would run the test code for the library feature(s) that I was working on. It caught a lot of bugs before they made it into the programs that were actually using the library, but it had a totally unexpected side effect: I felt a lot freer to experiment with the code, knowing that any change that broke something would probably be caught immediately. It also gave me a lot more confidence in my code, without exhaustive manual testing all the time. It seems like more work, but in the end it will save you a lot more time and effort than it costs.

I haven’t tried writing the unit tests before writing the actual code yet, but after reading that post, I can see several of the advantages to it. I’ll try that next time.

Don’t Forget To…

The hardest thing about remembering something is remembering it long enough to remember it.

Okay, that sentence is a little convoluted, but that doesn’t affect it’s accuracy. 🙂 The hardest part about remembering something is keeping it in your head for more than a few seconds in the first place — once you can do that, you can get better and faster at remembering it by constructing new memory paths to it from all the places you need them. The more you use something, the easier it is to remember it.

I’ve had several nights in the last few weeks where I just couldn’t get to sleep, or woke up in the middle of the night and couldn’t get back to sleep immediately. To usefully pass the time, I’ve stayed in bed and practiced memory techniques. Continue reading ‘Don’t Forget To…’ »