Object-Oriented Design + Unit Testing
You are implementing a small in-memory model for a company and its employees. The interviewer will give only input/output expectations, so you must clarify requirements and design clean APIs.
Part 1 — Employee
Design an Employee object with at least:
-
id
(unique identifier)
-
name
-
email
Part 2 — Company
Design a Company object that manages many employees. Support operations such as:
-
Add an employee
-
Read/lookup an employee by
id
-
Update an employee’s
email
by
id
-
Delete/remove an employee by
id
Part 3 — Behavior and validation (clarify assumptions)
Define and implement behavior for edge cases such as:
-
Adding an employee with a duplicate
id
-
Looking up/updating/deleting an
id
that does not exist
-
Invalid emails (if you choose to validate)
Part 4 — Testing requirement
Write unit tests for each part/operation (the interview requires tests that can be executed successfully). Tests should cover:
-
Happy paths
-
Key edge cases and error handling
Part 5 — Code quality expectations
Aim for:
-
Clear method names and return values
-
Appropriate exceptions or error results
-
Maintainable structure (separation of concerns, minimal coupling)