Debug a mock Dasher Assignment Service.
Unlock detailed company stats for this questionUpgrade
A single main.py (or equivalent in your language) contains business logic for a mock Dasher Assignment Service used to assign dashers to deliveries. Identify the logic bugs and bad design/coding practices and improve the codebase, prioritizing logic bugs.
Interfaces given:
- User class: just an ID attribute, instantiated with the ID.
- Dasher class: a special, very lightweight type of user.
- RemoteDeliveryRecordingService: a stubbed logging service you may extend, with placeholder signatures recordDasherAdd(dasherId, timestamp) and recordDasherPicking(dasherId, timestamp).
- DeliveryAssignmentService: the main code; its constructor takes a RemoteDeliveryRecordingService instance.
Implemented (buggy) functions:
- addDasher(id): takes an id and creates a Dasher object to add to the pool.
- pickKey(): random int function that chooses a random id from the pool.
- adjustMap(key): helper that tries to process the pool after a dasher is picked.
- pickDasher(): calls pickKey(), records the picked dasher through the RemoteDeliveryRecordingService, then calls adjustMap.
Follow-ups: additional test cases, and optimizing the solution beyond the broken implementation provided.
Community answers
No answers contributed by the community yet.
Related courses

Course

Course
Course
