Skip to main content

Documentation? You mean tests?

"I hate writing documentation!"

I've seen more than a few programmers say this.  To be honest, I've been guilty of saying it occasionally.  This post isn't about convincing you to like writing documentation.  I already wrote that post.  This post is about something I was talking to a coworker about just the other day.

Tests are documentation

I don't just mean that like when other programmers say it.  "Tests are one form of documentation."  This is much bigger than that.  When you test correctly and thoroughly, it's better than documentation.  That's when sh*t gets real.  I talked a bit about testing before, but what I said was only a piece of the whole.  Tests are the best form of documentation there is.  When you test code you don't understand, the test is a window into what you were thinking at the time.  It shows how the code works when it's done, but only by showing how you figured it out.  How many times have you looked at a piece of code and thought "What was he/she thinking when he/she wrote this?"  That's exactly what a test clarifies.

I'm not talking about TDD, but I am talking about testing.  I have yet to effectively use TDD.  It feels like predicting the future.  I don't know what I'll need to write before I write it, so I write it, then test it.  But I do test it.  I write End to End Tests, Unit Tests, and Acceptance Tests.  And, I demand nearly 100% code coverage.  I don't test generated code, but all of my code is tested, and well tested at that, I'm talking about testing by passing null parameters, and even with junk data.  I judge the quality of a Solution based on the size of the testing Project. Why?  Because if I ever don't know how something works, I can just run the tests for it and know everything about it.  (In fact, I'd love to see VS add to the context menu "Run Tests that Include this Method")

Tests are better than other technical documentation forms

While automated testing is useless at making end user documentation, this form of documentation is more detailed than standard technical docs, and on top of that it changes as the code changes, so it's always up to date.  More than that, it also gets checked into source control, so you can see the historical documentation side-by-side with the historical code.  This form of documentation grows with your code, it is "living" documentaiton.  More than anything else, it's ACCURATE.  There's not a 10 year old piece of paper suggesting that Server XYZ currently hosts the database for this project.  It's all there and you can see proof that this is how things work.  It's beyond documentation.  It's amazing when done properly.

It's not going to happen overnight

Do not imagine this is some magic wand that you can wave.  I'm working on a 3 week contract that I opened up a Solution with 0 tests on my first day.  While building code for the project I've only had time to write about 3 tests (by the end of week 2).  This is something you should implement on any new projects and work to implement over time on old projects.  But as a result, you'll never have to be afraid of making a change again.  Can you imagine that?  I know I would love to be in that position.


Popular posts from this blog

Managing Developers is HARD

I've been a software dev for a long time.  I've also been running my own software company for a few years now.  This is important information because of why I do these things.  I am a sofware developer because I love learning.  I slack off when doing a job that bores me, and software development always has something new to experience which keeps me excited and interested.  Why start a software company then?  That puts me in the role of manager rather than developer.  The truth is simple.  I've worked for a lot of companies, and I don't see any of them doing a great job of managing their software development.  That's not to say none of them have done a good job, but no one out there seems to be doing a great job.

How are they different?
A lot of companies get this part right.  Software developers are different from other employees.  The distinction is important in the same way it's important to acknowledge that an insurance agent is different from a construction…

When Is Software Done?

I have some very exciting news.  A piece of software I've been working on for over 2 years is released to the general public!  This is a little exciting if it were software I'd been working on for some big company.  It's very exciting because it's software I have been working on for my company.  That's right!  My company is ready to start selling software and start making money!

I'm not gonna use this blog post to talk about my company and what it does.  You can read about that in our press release.  Instead, I'm going to talk about the software industry and the concept of done.  Because, as with everything, it's more complicated than it seems.

Software is never really done
Actually that's a misnomer.  Software can really be done.  But done is sort of a quantum state--there and not there at the same time.  First and foremost, anyone can understand that software that works is complete.  If the software's purpose is to process a credit card, if th…

How to identify a skilled programmer during an interview

How does one identify a skilled programmer?  No company that has interviewed me could tell the difference between myself and other programmers they'd interview.  The interview process is truly a game of luck in this industry--on both sides.  Both the programmer and the company are basing their actions entirely on luck.

Companies have come up with numerous methods to attempt to discern a good programmer from a bad one.  The best tricks they have include a series of math problems, algorithms, problem solving technique tests, and even obscure programming questions, some without definitive answers.  As an example: Is there an authoritative source of information on the core principles that define object oriented programming?  I've heard everywhere from 3 to 7.  In a field of research about a synthetic concept, an authoritative answer is almost impossible to obtain.

Programmers were then forced to study to the interview.  Careercup is one of my favorite sites for this.  This almost …