1.7 Basic workflow
Explanation
Use this workflow for most subsections:
- Read the short explanation.
- Write a small plan before asking an AI agent for code.
- Look up unfamiliar terms.
- Create a working directory such as
work/chapter_x.y/. - Use
answer.rsfor tiny scratch work, or create a Cargo project for tested work. - Write reusable functions in
src/lib.rswhen the exercise needs functions that can be tested. - Write tests in a
tests/directory or in#[cfg(test)]modules near the code. - Run
cargo test. - If an AI agent edits files, inspect
git diffbefore asking it to continue.
For each item in “Things to look up”, write one sentence in your own words and one example related to scientific computing. The goal is not to collect definitions; the goal is to connect the word to a calculation, code fragment, data file, or validation check.
Small scratch files are useful when the code is only a short experiment. Tested exercise work should normally use Cargo because it gives a standard project layout and a standard test command.
For example:
mkdir -p work/chapter_4.6
cd work/chapter_4.6
cargo new --lib slice_check
cd slice_check
cargo testBefore asking an AI agent to continue, review the current files and diff. A useful review should check the algorithm, inputs and outputs, boundary cases, tests or validation, use of functions or modules, and hidden global mutable state.
Things to look up
- Hand-written exercise
- Pseudocode
- Unit test
- Validation
- Reproducibility
- Worked example
- Submission artifact
- Cargo project
answer.rssrc/lib.rstestsdirectory
Exercise
For one subsection, write a short study plan that includes reading, searching, a hand-written answer, optional AI help, and an optional Rust check.
If your plan uses AI-generated answers, also write how you will check that you understand the answer in detail.
State the expected output of your work, such as a hand-written note, Markdown note, answer.rs, Cargo project, test file, saved result file, or work log.
Create a small work/chapter_x.y/ directory for the subsection you choose. Decide whether the exercise is small enough for answer.rs or should use a Cargo project with tests. Write down the command you would run before asking an AI agent to review the result.
Notes for the exercise
- Do not skip the hand-written step.
- Do not start by asking an AI agent for the final answer.
- If you later ask an AI agent for an answer, inspect it line by line.
- Ask follow-up questions about every unclear term, formula, code line, or assumption.
- Do not submit or accept an answer that you cannot explain without looking at the AI output.
- Make the validation step explicit.
- Make the submission artifact explicit when an exercise does not specify one.
- If you give an AI agent a file path, also tell it whether it may edit the file or should only review it.