Test Driven Development (TDD), aka red, green, refactor. I have spent the last year creating projects using this method and these are my big takeaways.
TDD takes some getting used to. When I was first learning to code I was struggling to not only understand how the code worked but why it worked the way it did. If you're a rails dev you are probably very familiar with binding.pry
. I was the Pry King always picking a part my code line by line and testing to see how it worked, what variables I had access to, just trying to see what I could see in the code.
But once I learned to use both of those tools together, I felt so much more direct in my code. I was able to organize my code so much better and adhere to the single responsibility principle (SRP).
It is so satisfying to write a test, run it, write the code, run it and watching the tests turn from red to green. It honestly makes me so happy.
TLDR - TDD makes coding more effective and intentional. Helps with the clarity and readability of the code. Exhibits developer empathy and is great for documentation. Definitely worth learning how to do.
Top comments (0)