Jump to a problem, path or page
Jump to a problem, path or page
01 · Frame the problem
Design a reusable file search library over a supplied directory provider. Queries combine name, type and size predicates with AND/OR/NOT. Traversal needs cancellation, budgets and explicit error behavior.
Traversal and matching have different responsibilities and failure modes. Analyse predicate semantics, inaccessible entries and the point where work limits make a result incomplete rather than an authoritative empty answer.
02 · Find the design pressure
Begin with pure predicates over normalized entries and an iterative provider traversal. Mixing callbacks with directory recursion makes composition and error handling fragile. Bound depth/work/results and return partial coverage explicitly when traversal cannot finish.
03 · Define success
04 · Identify the correctness boundary
Compile predicates independently from traversal so name, size and boolean combinations can be tested as pure rules. Iterative traversal avoids call-stack dependence, while explicit entry/depth/result budgets prevent unbounded work. Provider errors and exhausted budgets require a partial-result status distinct from a complete empty result.
05 · Make it concrete
Search for large files under a directory with an unreadable child. Matching files from readable branches may be returned with the access failure recorded. Reaching the result budget marks truncation. The caller must not infer that omitted branches contained no matching files.