Object-Oriented Programming · Amazon · Medium
Composable Predicates over a Depth-First Walk The trap in this question is letting the traversal and the matching logic grow into one tangled function: every new requirement ("bigger than X", "ends in .pdf", "name contains Y", "both of the above") would then mean editing the walker. The extensible design pulls the two concerns apart. The walker's only job is to enumerate every file reachable from the starting directory. Each rule is a small, independently testable predicate…