Make code easier to read, test, and reuse
Goal
You should be able to demonstrate the result described in the lesson and explain why each step was necessary.
You should be able to demonstrate the result described in the lesson and explain why each step was necessary.
Step-by-step
01
Name by behavior
A function name should tell the reader what result it produces.
02
Keep inputs explicit
Avoid hidden global dependencies when a value can be passed as an argument.
03
Return useful values
Prefer returning a value over printing deep inside reusable logic.
04
Separate I/O from logic
Keep file, database, and network access separate from transformations when practical.
05
Handle invalid input
Define what happens when a required value is missing or malformed.
Verify before moving on
You should be able to demonstrate the result described in the lesson and explain why each step was necessary.
You should be able to demonstrate the result described in the lesson and explain why each step was necessary.
Troubleshooting
If a command or screen differs from the lesson, stop and verify the version you are using before forcing a change.
What you learned
You now understand the purpose of this part of the system and have a concrete result you can verify before continuing to the next lesson.