Design employee and company classes with tests
Object-Oriented Design and Unit Testing
You are tasked with implementing a small, in-memory model for a company and its employees. The interviewer will provide only high-level input/output expectations, requiring you to clarify detailed requirements and design clean, intuitive APIs.
Part 1: Employee Object Design
Design an Employee object that must include at least the following attributes:
id: A unique identifier for the employee.name: The employee's full name.email: The employee's email address.
Part 2: Company Object Design
Design a Company object responsible for managing a collection of employees. This object must support the following core operations:
- Add an employee to the company.
- Read or look up an employee by their unique
id. - Update an existing employee's
emailaddress, identified by theirid. - Delete or remove an employee from the company by their
id.
Part 3: Behavior and Validation
Define and implement robust behavior for various edge cases and clarify any assumptions made during design. Consider scenarios such as:
- Attempting to add an employee with an
idthat already exists. - Attempting to look up, update, or delete an employee using an
idthat does not exist within the company. - Handling invalid email formats, if you choose to implement email validation.
Part 4: Testing Requirement
Write comprehensive unit tests for each part and operation designed. These tests must be executable and successfully pass. Ensure test coverage for:
- All "happy path" scenarios where operations proceed as expected.
- Key edge cases and the corresponding error handling mechanisms.
Part 5: Code Quality Expectations
Your solution should demonstrate high code quality, aiming for:
- Clear, descriptive method names and well-defined return values.
- Appropriate use of exceptions or other error reporting mechanisms.
- A maintainable structure, exhibiting good separation of concerns and minimal coupling between components.
AI interview prep
Core dilemma
Balancing the need for a simple, quick in-memory implementation with robust, testable, and extensible object-oriented design principles.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design employee and company classes with tests
Object-Oriented Design and Unit Testing
You are tasked with implementing a small, in-memory model for a company and its employees. The interviewer will provide only high-level input/output expectations, requiring you to clarify detailed requirements and design clean, intuitive APIs.
Part 1: Employee Object Design
Design an Employee object that must include at least the following attributes:
id: A unique identifier for the employee.name: The employee's full name.email: The employee's email address.
Part 2: Company Object Design
Design a Company object responsible for managing a collection of employees. This object must support the following core operations:
- Add an employee to the company.
- Read or look up an employee by their unique
id. - Update an existing employee's
emailaddress, identified by theirid. - Delete or remove an employee from the company by their
id.
Part 3: Behavior and Validation
Define and implement robust behavior for various edge cases and clarify any assumptions made during design. Consider scenarios such as:
- Attempting to add an employee with an
idthat already exists. - Attempting to look up, update, or delete an employee using an
idthat does not exist within the company. - Handling invalid email formats, if you choose to implement email validation.
Part 4: Testing Requirement
Write comprehensive unit tests for each part and operation designed. These tests must be executable and successfully pass. Ensure test coverage for:
- All "happy path" scenarios where operations proceed as expected.
- Key edge cases and the corresponding error handling mechanisms.
Part 5: Code Quality Expectations
Your solution should demonstrate high code quality, aiming for:
- Clear, descriptive method names and well-defined return values.
- Appropriate use of exceptions or other error reporting mechanisms.
- A maintainable structure, exhibiting good separation of concerns and minimal coupling between components.