One of the great things about TDD is that it gives you a framework for how to approach coding problems and really how to approach work. You follow a pattern that has been proven to work by countless others. You start by proving the smallest piece of the code that you can and you work your up, bit by bit, to solve the entire issue. It sets you up for success, and makes solving complex problems easier because you don't have to worry about the entire thing. You can focus on a much simpler problem and solve that.
But you have to use it, ALL THE TIME! It shouldn't be something that you only use once in a while or when you feel like it. It shouldn't be something that you fake by writing a few, relatively meaningless, tests after you have completed your work. You shouldn't claim that writing out the tests first will take too long, and then follow up your work by throwing together some tests. Start with tests and build up as you go. Trust that the system will work, follow the mantra, and understand that you will save yourself time and effort by writing those tests first.
The reason TDD works is that you are always working from a place of certainty and confidence. You can stop at any point in time and know that you have code that is working or at least 1 step away from working, which may actually be a better place to stop. The alternative approach though, when you stop, can leave you with a lot to remember. Are you going to always be able to remember where you were? Are you going to be able to jump back in and pick up right where you left off? Probably not. So anytime you are coding and have an interruption you are going to lose time when you start again.
I know in the past when I have tired to code things without writing tests first, and things have not gone exactly as I expected, I tend to get anxious. I get worried that things aren't working, I get concerned about time constraints and wonder why what I thought would work is not working. It has led to a lot of stress and it is not something I enjoy. TDD provides a level of confidence and security that I do not get when free-coding. I don't worry about the negative things and don't have the negative feelings, which tends to produce better code in a timelier manner.
If you are getting frustrated with how a project is going, take a step back and look at how you are approaching the project. Is there something you can change that will alleviate that frustration? If you are running in circles trying to figure out why some logic doesn't work, or why functionality is not working as you expect, write some tests. Make sure that it is doing what you think it should be doing. If you find that it is not, then you can fix it and have a test to prove that it is now working. If is is doing what you expect, then where else could the system be failing that you can write a test for? Continue working through the system, bit by bit, iterating over code, until your code is fully functional and you are happy.
But you have to use it, ALL THE TIME! It shouldn't be something that you only use once in a while or when you feel like it. It shouldn't be something that you fake by writing a few, relatively meaningless, tests after you have completed your work. You shouldn't claim that writing out the tests first will take too long, and then follow up your work by throwing together some tests. Start with tests and build up as you go. Trust that the system will work, follow the mantra, and understand that you will save yourself time and effort by writing those tests first.
The reason TDD works is that you are always working from a place of certainty and confidence. You can stop at any point in time and know that you have code that is working or at least 1 step away from working, which may actually be a better place to stop. The alternative approach though, when you stop, can leave you with a lot to remember. Are you going to always be able to remember where you were? Are you going to be able to jump back in and pick up right where you left off? Probably not. So anytime you are coding and have an interruption you are going to lose time when you start again.
I know in the past when I have tired to code things without writing tests first, and things have not gone exactly as I expected, I tend to get anxious. I get worried that things aren't working, I get concerned about time constraints and wonder why what I thought would work is not working. It has led to a lot of stress and it is not something I enjoy. TDD provides a level of confidence and security that I do not get when free-coding. I don't worry about the negative things and don't have the negative feelings, which tends to produce better code in a timelier manner.
If you are getting frustrated with how a project is going, take a step back and look at how you are approaching the project. Is there something you can change that will alleviate that frustration? If you are running in circles trying to figure out why some logic doesn't work, or why functionality is not working as you expect, write some tests. Make sure that it is doing what you think it should be doing. If you find that it is not, then you can fix it and have a test to prove that it is now working. If is is doing what you expect, then where else could the system be failing that you can write a test for? Continue working through the system, bit by bit, iterating over code, until your code is fully functional and you are happy.
Comments
Post a Comment