Phase 1: Requirements & Use Cases
Interviewer: "Design an object-oriented version of the Unix
findcommand."Candidate: "Before I model anything, let me clarify scope. The Unix
findcommand traverses a directory tree and emits paths that satisfy one or more filter criteria. At a minimum I'm thinking: search by name, by extension, by file size, by modification time, by type (regular file vs. directory), and the ability to combine those filters with AND, OR, and NOT. Is that the right scope, or are there additional operations you want to cover?"Interviewer: "That's the right scope. What else do you want to confirm?"
Candidate: "A few things. First — are we building a callable library API, a command-line parser, or both? Second — does this need to handle the real filesystem, or are we designing against an abstraction so it can be tested in memory? Third — do we need to support
find -exec— executing an arbitrary command on each result? Fourth — should we respectfind's-maxdepthflag? Fifth — does the traversal need to detect and break circular symbolic links, as the realfinddoes?"Interviewer: "Design a library API against a filesystem abstraction. Include
-exec-style action execution and-maxdepthas Phase 6 extensions. Handle circular symlinks when you get there."Candidate: "Perfect. The actors are:
User(invokes the search, composes criteria, receives results),FileSystemTraverser(walks the directory tree via the filesystem abstraction),FileEntry(a value object representing a node in the tree — file or directory), andCriterion(the interface that each…
In the full tutorial
- Phase 2: Object Modeling
- Phase 3: Class Design & Relationships
- Phase 4: Design Patterns Application
- Phase 5: Key Implementation
- Phase 6: Edge Cases & Extensions