Object-Oriented Design of a Yahoo Mail Filter Rules Engine
Last updated: November 29, 2026
Quick Overview
Design the classes for a Yahoo Mail filters feature: users define rules with conditions on sender, subject, or body, combined with AND, OR, and NOT, and actions like move to folder, label, or mark read, applied in priority order with an optional stop-processing flag.
Yahoo
November 29, 20260
0
0 solved
Design the classes for a Yahoo Mail filters feature: users define rules with conditions on sender, subject, or body, combined with AND, OR, and NOT, and actions like move to folder, label, or mark read, applied in priority order with an optional stop-processing flag.
Mail filters are a long-standing Yahoo Mail feature, and the low-level design round uses them to test object modeling. Interviewers look for composable conditions, decoupled actions, clear rule ordering, and a design that is easy to extend and to store.
What the Interviewer Expects
- Model conditions with a common interface and composite AND, OR, and NOT nodes
- Model actions independently of conditions
- Define rule ordering by priority and a stop flag
- Keep the engine stateless so it can run in delivery workers
- Explain how rules serialize to storage and are validated
- Show extensibility for new conditions such as has-attachment
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you store these rules in a database and load them efficiently at delivery time?
- How would you detect conflicting rules, such as two rules moving the same mail to different folders?
- How would you apply a new rule retroactively to a mailbox of 100k messages?
- What limits would you put on rules to protect delivery latency?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Users create up to N rules. Each rule has a name, a priority, a condition tree, a list of actions, stop and enabled flags. The engine applies matching rules in priority order to each incoming mess...
High-Level Design
Conditioninterface withmatches(message). Leaf conditions:FieldContains,SenderDomain. Composites:AllOf,AnyOf,Not(composite pattern), so arbitrary boolean trees are possible.- `...