Reading-notes

TDD

Test-Driven Development

with TDD we need to think about tests first. And to be ok with the possibility of the beginning to be hard sometimes

### AAA: Arrange, Act and Assert. 1-Arrange: you need to organize the data needed to execute that piece of code (input)

2-Act: here you will execute the code being tested (exercise the behaviour)

3-Assert: after executing the code, you will check if the result (output) is the same as you were expecting.

The test file name should follow the same name of module name.

important thing about TDD: the cycle.

The cycle is made by three steps:

🆘 Write a unit test and make it fail

✅ Write the feature and make the test pass!

🔵 Refactor the code — the first version doesn’t need to be the beautiful one .

TDD is not about the money/tests

More than any checking, we need to think about our software design first.

summary:

if name == “main

Python interpreter reads source file and define few special variables/global variables.

If the python interpreter is running that module (the source file) as the main program, it sets the special name variable to have a value “main”. If this file is being imported from another module(module is a file containing Python definitions and statements), name will be set to the module’s name.

Recursion

unction calls itself directly or indirectly

Recursion is the process of defining a problem (or the solution to a problem) in terms of (a simpler version of) itself.

example uses of recursion: factorial

recursion is good for the program in term of memroy usage