Pretty standard OOD topic but the interviewer was cold the whole time, hard to tell if I was on the right track or completely off.
Start by clarifying requirements and scope (e.g., single machine vs distributed, in-memory vs persistent, POSIX-like features). Then model the core entities (File, Directory, FileSystem) using OOP principles like inheritance, composition, and polymorphism, and discuss trade-offs in your design choices. Finally, walk through key operations (create, read, write, delete, list) and how your design supports them efficiently.
Pro tip: Demonstrate Amazon Leadership Principles by explicitly calling out trade-offs (e.g., simplicity vs extensibility) and tying your design decisions to customer needs like scalability and reliability. Also, mention how you would test the design and handle edge cases.
Ask questions to understand the expected scale, features (e.g., permissions, symbolic links), and constraints (e.g., distributed, persistent). This ensures your design addresses the right problem.
Define the main classes (File, Directory, FileSystem) and their relationships. Use inheritance for common attributes (e.g., name, timestamps) and composition for hierarchical structures.
Outline methods for operations like create, read, write, delete, and list. Consider how polymorphism (e.g., a common Node interface) simplifies traversal and manipulation.
Explain choices such as using a tree structure vs a flat map, and how to support future features (e.g., permissions, versioning) without major refactoring.
If relevant, discuss how the design could scale (e.g., sharding, caching) and ensure reliability (e.g., atomic operations, error handling).
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.