1) The “Expert Logic” Loop (use this every time)
Frame the problem
What’s the exact goal? Success criteria? Constraints (time, memory, SLAs, security, compliance)?
Inputs → Outputs (types, ranges).
Model the domain
Name the core entities and their relationships. Draw a 5-min sketch.
Work small examples
2–3 typical cases + 3 edge cases (empty, huge, invalid, concurrent).
Start with a brute-force baseline
Make it correct first.
Prove/defend correctness
Invariants, pre/postconditions.
Measure, then optimize
Identify the hot path; change one thing at a time.
Automate guardrails
Tests, linters, type checks, CI.
Document the decision
“We chose X over Y because Z.”
Copy-paste template for tickets/notes:
Goal:
Constraints:
Inputs/Outputs:
Data model:
Examples & edge cases:
Algorithm (baseline):
Correctness argument:
Complexity:
Risks & mitigations:
Tests to write:
Data structures & algorithms: arrays, hash maps/sets, stacks/queues, heaps, trees/graphs, sorting, two-pointer, sliding window, DP.
Decomposition & interfaces: split into small pure functions with clear contracts.
State & invariants: what must always be true? (e.g., balances never negative, totals consistent).
Error handling strategy: fail fast vs graceful, retries, idempotency.
Persistence logic: SQL schemas, indexes, transactions, isolation.
Concurrency & async: race conditions, locks, queues, backpressure.
Testing pyramid: unit → integration → contract → e2e; generate fixtures; property-based tests for core logic.
Observability: logs with context, metrics, traces, feature flags.
Security & compliance basics: input validation, authn/authz, secrets, audit logs.
Next 30 days (Foundations)
30–45 min/day: one focused DSA pattern (e.g., “sliding window week”).
Implement 10 utility functions from scratch (parsers, validators, cache LRU, rate limiter).
Start a kata repo: each function with tests, docstring, complexity note.
Days 31–60 (Systems & correctness)
Build one small service end-to-end: REST API + DB + tests + CI.
Add property-based tests (e.g., Hypothesis in Python) for core logic.
Introduce observability: structured logs, a few metrics, error budgets.
Days 61–90 (Scale & architecture)
Add queues (retry, DLQ), idempotency keys, pagination, indexing strategy.
Load test & profile; write a short decision record after each change.
Perform and receive two code reviews/week with a checklist (below).
Clarity: names, function length, comments explain why, not what.
Correctness: tests reflect edge cases; invariants visible.
Complexity: simplest thing that works? unnecessary generalization?
Safety: errors, timeouts, retries, idempotency, input validation.
Data: indexes match queries; migrations are safe; N+1 avoided.
Perf: measured evidence for changes.
Observability: actionable logs/metrics for each critical path.
Specification by example: write 5 examples before coding.
Design at two levels: (a) pure core logic (framework-free) (b) thin I/O layer.
Invariant board: keep a running list: “must always hold”.
Pre-mortem: “It failed in prod—why?” design mitigations upfront.
Complexity guard: if a function > 25 lines or > 2 branches, split.
Implement:
LRU cache, circuit breaker, token bucket rate limiter, top-K with heap, interval scheduler, consistent hashing, CRDT counter (if collaborative features), pagination with keyset.
Data/AI tilt (fits your background):
A deduplication service for documents (shingling + MinHash).
Feature store: validate schemas, backfills, drift checks.
EMR mini-system: patients, meds, prescriptions with audit log, dosage checks, and conflict alerts (your pharmacy expertise = superpower).
Prefer pure functions for core rules; keep side effects at the edges.
Use type hints and pydantic/dataclasses for contracts.
Encode rules as data when possible (tables, config) so logic is testable and auditable.
Write property tests for invariants; fuzz invalid inputs.
Add a profiling path (cProfile
, time.perf_counter
) around hot logic.
Mon: select 1 pattern, write examples + tests first.
Tue–Wed: implement baseline, prove correctness, measure.
Thu: optimize only if metrics demand it.
Fri: write a 10-line decision record + do one code review.
Weekend: one real-world bug hunt in your own or open-source code.