Testing and Modules
In Tests We Trust
Unit Tests: Pieces of code to test the input, output, and behavior of your code
TDD: Test Driven Development. A strategy where you think and write tests first when writing code.
The best way to organize your code when thinking about TDD is AAA:
-
Arrange: organize the data you will need to test that particular piece of code.
-
Act: Execute the code being tested.
-
Assert: after execution, check that the output is the same as you originally thought. (Once this is done wih a clunky looking code block, refactor it so it is sleeker)
Recursion
Recursion: Recursion happens when a function loops back in on itself a number of times before completing itself. The example in the video cited factorials. Because the factorial function references itself, it loops for a number of loops equal to the number that it is fed. This is an example of stacking, where functions to be computed are lined up behind each other (called stack frames), in order of what gets solved last. Finally when the final and smallest function is able to be solved, the rest can then follow.
Things I want to know more about
- If I’m being completely honest the If Name = Main reading went totally over my head. I don’t think that I really grasp modules well enough yet to understand the concepts they are explaining here.