COMP 536 • In-class lab structure (Feb 2, 2026)
2026-02-02
You are not “behind” if you haven’t coded yet.
You are behind if you don’t have a plan.
Today’s goal is to produce a small plan you can implement with confidence:
Star class and its derived quantitiespython run.py validate)python run.py test)You’ll need your laptop to read the assignment and the paper.
For the first half of class, your laptop is for:
Not for writing Python.
star.py (plus zams.py scaffolding)Project 1 has a lot in it. If you try to do everything at once, you’ll end up with tangled code and no evidence.
Today we focus on the newest idea for many of you: a class with a clean contract.
Your goal is to be able to say:
“If I give
Star(mass, Z), I know exactly what attributes exist, what units they have, and how I will validate them.”
We are practicing four habits:
Assign roles in groups of 3–4. Rotate once.
A spec (specification) is the authoritative description of what your code must do.
For Project 1, your specs include:
If you can’t point to a line in a spec, you’re guessing.
By the end of class, you must have:
Starzams.luminosity() and zams.radius() (signatures + input checks + where coefficients will live; solar \(Z\) / column 1 first)These two are the non-negotiables.
If you finish the must-haves, next do:
run.py validate plan with 3 checks (anchor + trend + one more)0–15: Slide walkthrough (what we’re doing and why)
15–35: star.py planning (contract + pseudocode + failure modes)
35–55: zams.py planning (equations + coefficient locations; solar \(Z\) / column 1 first)
55–65: Validation + tests plan (3 validation checks + 2 “first tests”)
65–75: Finalize your worksheet + checkoff
Today, the work product is your plan quality.
When I stop by, be ready to show me:
Star contract (inputs/outputs/units + 3 failure modes)Star pseudocode (including derived quantities)If you can’t show these, you haven’t started yet — even if you already wrote code.
In the last 10 minutes, I will check off your planning sheet.
I’m not grading you on “how much code you wrote today.”
I’m checking that you have a plan that can actually guide correct implementation.
Start with \(Z = 0.02\) (solar). In the Tout fits this is the simplest path:
Then, once solar passes, add the full \(Z\) dependence.
Pseudocode is how you catch misunderstandings early:
If you can’t write pseudocode, you’re not ready to code.
A trace is a written step-by-step record of how one specific input produces an output.
Use a trace when you suspect a transcription or interpretation error. For example:
Star trace: compute \(T_\mathrm{eff}\), then \(t_\mathrm{MS}\), then \(t_\mathrm{KH}\) for one masszams trace (optional): compute one numerator/denominator term at a time for one massTraces make “paper \(\to\) code” bugs visible and implementation straightforward.
Stop typing. Say this out loud:
“I think the bug is because , and I expect to see if I check ___.”
Then run one targeted check.
That is debugging.
“Specs-first” means you write down what correct means before you code (equations, tables, valid ranges, and the run.py contract).
This prevents the classic failure mode: lots of code quickly, then you discover a hidden assumption was wrong (units, \(\log_{10}\), piecewise ranges).
Specs-first forces clean structure: one source of truth, no duplicated formulas/constants, and modules you can actually test.
It also makes grading fair: I can run it, audit it, and see evidence (validation + tests), not just output that “looks plausible.”
![]()
COMP 536 • Project 1 Studio