Analysing and Unit Testing: A crucial part of development…or not

When I first started programming (started with Turbo Pascal and then Visual Basic), I really enjoyed programming. It was a whole new world opening up for me. Whenever I needed a piece of software to make my life easier, I just sat down in front of the computer and started programming like crazy. VB was a sequential programming language where you could reuse functions by the use of modules, etc. It was fun to use and you could have a finished application within a few hours.

Then came the new hype, Object Oriented programming. The new hype, a new sherif in town. Off course when I started at college, we saw Java. I have to admit I had to get used to the idea of OO programming after being a sequential programmer for years. We also had a class where we learned how to analyse our projects and manage them in a professional way. Put that class together with Java, and you had a few hours of sleep (if people even bothered coming to class). It was just so boring, I couldn’t see myself as a programmer. Having to analyse everything into detail, and using unit tests to test your application, or even develop by the TDD method (Test Driven Development, witch means writing tests first, program later).

For my internship, I chose for the company AMI Semiconductor (now known as ON Semiconductor).  I had to develop some Testing tools for the Test Methodology Departement. After 4 months of internship, I still didn’t feel like developing. I didn’t have to analyse everything (they where very loose on that matter), but Java just didn’t got my mojo running.

Then for some twisted reason, I stumbled into the world of web development. Using PHP, but mostly Ruby (On Rails), I wouldn’t change for anything else. I’m already working for 8 months as an Information Architect, and I’m starting to realise, that the things they thought us about analysing and unit testing wasn’t to let us fall asleep. Lately, I’m starting to realise that it is really necessary to have a good analysis before you start a project, and having some Unit tests wouldn’t be that bad.

I have finished a few projects at my day job as an Information Architect, and there are a few things that I would have done differently.  One of them would be to have a clearer view of the project. Not everything was analysed, witch has become a real pain in the ass now. The client keeps on asking stuff that really requires huge changes to the system. And after a few months, I really want to put this project behind me. Second thing is to take some time to create tests. I start to believe they could really help me keeping my code clean and bug free.  Off course, that’s not only up to me. Some projects have a tight deadline, and a small budget, so the first things that get cut are analysing time and time for unit testing (creating proper tests can take time, so they say…).

I still haven’t created a single test. But I have a new project coming up, witch I’m going to develop for Netronix  (my own company) .  And I can assure you, I will analyse everything properly, not loosing the target of sight and even start to develop unit tests. This way, the project just can’t go bad and get sore. I don’t think I’m going to go for TDD (Test Driven Development), because I know I don’t have the discipline yet for doing that. But maybe in the future, when I get more experience, I’ll give it a shot.

So how about you other developers, do you take time to create unit tests and analyse everything enough so you don’t lose focus on the goal? Maybe you guys can give me some pointers on how to write Unit Tests. I already read some books, but having some practical advise would help me more out, then some theoretical rules.  My next personal project will be written on the Rails framework (sorry Symfony guys, but I think Rails will fit my needs better this time), so some Rails tips would even be better.

So when I can finish my project in success with a strong bataljon of unit test, I maybe can convince my boss to start creating unit tests for all our projects…well, I guess I’ll have to wait and see