Summary
- Start from the end. Define the final artifact and success criteria.
- Turn the goal into guiding questions. Gather 2β3 pieces of evidence per question.
- Build an outline from answers. Then draft.
- Log progress and communicate in bullets.
- Focus on application, not only exam tactics.
Method (step-by-step β ordered)
-
Define the outcome
- Final format: essay, solution, code, talk.
- Success criteria: what a reviewer marks correct/complete.
-
Form guiding questions
- 3β7 questions: what, why, how, trade-offs.
-
Collect evidence (2β3 per question)
- Sources: books, docs, code, experiments, benchmarks.
- Keep citations or reproducible steps.
-
Build the outline
- Intro β Questions β Evidence β Synthesis β Conclusion.
- Sequence ideas logically.
-
Draft
- Write to teach. Short sentences. Compare alternatives.
-
Review
- Each question answered with evidence.
- Remove unsupported claims. Convert notes to final artifact.
-
Progress logging and comms
- Daily: done, next, blockers.
- Weekly: what changed in understanding + open risks.
Key ideas from the notes: plan the end, pair each question with evidence, outline before writing, prioritize real application.
Worked example: Go concurrency
1) Outcome and criteria
- Artifact: post + repo with worker pool,
contextcancellation, and timeouts. - Criteria:
- Clear choice between ad-hoc goroutines vs bounded pool.
- Correct
contextusage. No goroutine leaks. - Simple benches plus failure cases.
2) Guiding questions β evidence β interim answers
Q1. When to use free goroutines vs a worker pool?
- Evidence:
- Go Blog on concurrency patterns.
x/sync/errgroupexamples.- Microbench with 10k tasks.
- Interim answer: free goroutines for few tasks or latency hiding. Pool for bounded parallelism and resource caps.
Q2. How to cancel correctly?
- Evidence:
contextdocs.- Test ensuring all goroutines exit on cancel.
pprofbefore/after.
- Interim answer: pass
contexttop-down, check<-ctx.Done()inselect, useerrgroup.WithContext.
Q3. How to handle timeouts and retries without leaks?
- Evidence:
http.Clienttimeouts.selectwithtime.After.- Race detector runs.
- Interim answer: per-op
WithTimeout, backoff with idempotency, always drain channels.
Q4. Common pitfalls?
- Evidence:
- Repro of fan-out leak without draining.
- Memory spike with unbounded goroutines.
- Data race caught by
-race.
- Interim answer: avoid unbounded fan-out, close producers, drain channels, guard shared state.
3) Outline built from answers
- Intro: problem + thesis (safe, bounded, cancelable concurrency).
- Sec 1: goroutines vs pool β trade-offs β microbench.
- Sec 2: cancellation with
contextβerrgroupexample. - Sec 3: timeouts, retries, backoff β HTTP example.
- Sec 4: pitfalls and diagnostics β leaks, races, pprof.
- Conclusion: when to choose each pattern and anti-signals.
- References: official docs and repo links.
4) Draft checklist
- Each claim has 2β3 evidences above.
- Include one counterexample: βgoroutine per requestβ leak.
- Write fail-first tests, then fix.
Progress format for mentor (β€5 bullets)
- Goal: implement worker pool with cancellation.
- Tried:
errgroup+ bounded channel. - Worked: tasks finish under cap; leak test passes.
- Failed: first version starved workers under backpressure.
- Next: HTTP timeout demo; question: best pattern for per-task timeouts inside a shared group?
Final checklist before publish
- Thesis in 1β2 lines.
- Each section answers a guiding question.
- 2β3 evidences per claim.
- One limitation acknowledged.
- Conclusion states when not to use the pattern.
Code pointers (repo)
pool.go: bounded worker pool withctx.pool_test.go: leak guard and-race.cmd/httpdemo/main.go: timeout + retry with backoff.