In this lesson
- It starts with a question. A function called total_price also empties the shopping basket. What is wrong?
- The idea you will find. Separate working it out from doing it. — Keep the calculation in one function and the saving, sending or deleting in another. The calculation can then be tested freely, and the dangerous part is small enough to read in one go. Most of what "clean code" means is this one habit.
- How you learn it. By doing: sorting.
- Length. 5 short steps. Progress saves on this phone.
Part of Reusable Code: Functions
Packaging a piece of work under a name so it can be reused and trusted.