bcquality/microsoft/knowledge/performance/avoid-findfirst-with-next.md
Jesper Schulz-Wedde 23184480d0 Triage seed knowledge and document admission test for preview
Remove seven knowledge files whose content is generic software-engineering
guidance that a capable LLM already applies without BCQuality present
(HTTPS-only, secret-leakage-in-errors, no-credentials-in-URLs, silent
security-error swallowing, short transaction scope, HTTP timeouts,
StrSubstNo-vs-concatenation). These fail the remedial-knowledge premise
and dilute the signal of the preview corpus.

Strip the "Seed article — domain stewards should expand" banner from ten
files that are ready to showcase (AA0232/AA0233 rules, FindSet read-only
semantics, SetLoadFields ordering and usage, CalcFields-in-loops,
SecretText end-to-end, DataClassification). The banner remains on files
that still need domain-steward refinement.

Add a "What belongs here" section to the README stating the admission
test: a file exists only if a modern LLM would get something wrong or
miss something without it. Gives contributors a concrete yes/no filter
before they open a PR.
2026-04-23 15:47:01 +02:00

1 KiB

bc-version domain keywords technologies countries application-area
26..28
performance
findfirst
findlast
get
next
aa0233
al
w1
all

Do not pair FindFirst, FindLast, or Get with Next

Description

CodeCop rule AA0233 flags loops that start with FindFirst, FindLast, or Get and then call Next. FindFirst and FindLast retrieve a single row and reposition the cursor; calling Next after them forces the platform to re-seek and stream the rest of the set, which is slower than the correct FindSet pattern and signals intent incorrectly to reviewers and the optimizer.

Best Practice

Choose the Find variant that matches the operation: FindSet for full iteration, FindFirst or FindLast when you want exactly one row, Get when the primary key is known. Never call Next after FindFirst, FindLast, or Get.

Anti Pattern

Writing if Rec.FindFirst() then repeat ... until Rec.Next() = 0 is the canonical AA0233 offender. The loop wastes bandwidth and obscures the author's intent.

See sample: avoid-findfirst-with-next.bad.al.