Skip to main content

Problem Statement

Design a call center system that routes incoming calls to available employees based on a hierarchy, with escalation support when employees cannot handle calls.

Constraints and Assumptions

  • Employee levels: Operator, Supervisor, Director
  • Call routing: Operators always get initial calls
  • Escalation: If no operator is available or they can’t handle the call, escalate to supervisors, then directors
  • Director capability: Directors can handle all calls
  • Queuing: Calls are queued if nobody can answer
  • No VIP support: All calls have equal priority
  • Valid inputs: Assume inputs are valid

Design Overview

The call center system uses several classes implementing a hierarchy pattern:
  1. Rank: Enum defining employee levels
  2. Employee: Abstract base class for all employee types
  3. Operator, Supervisor, Director: Concrete employee implementations
  4. Call: Represents an incoming call
  5. CallCenter: Orchestrates call routing and queuing
This design uses the Chain of Responsibility pattern, where calls are passed through a hierarchy of handlers (operators → supervisors → directors) until one can handle it.

Implementation

Rank Enumeration

Defines the employee hierarchy:

Employee Base Class

Abstract class with common employee functionality:

Concrete Employee Classes

Each level implements the escalation logic:

Call Classes

Represent call state and properties:

CallCenter Class

Orchestrates call routing and management:

Key Design Patterns

Chain of Responsibility

Calls cascade through levels until handled:

Abstract Factory Pattern

The Employee abstract base class defines the interface, with concrete implementations for each rank level.

Observer Pattern

The notify_call_completed() and notify_call_escalated() methods allow the call center to react to state changes.

Complexity Analysis

Design Considerations

Advantages

  • Clear hierarchy: Well-defined escalation path
  • Flexible: Easy to add new employee types or ranks
  • Separation of concerns: Each class has a single responsibility
  • Extensible: Can add features like call priority or specialized routing

Call Flow

  1. Call arrives → Assigned OPERATOR rank initially
  2. Dispatch attempt → Try to find available operator
  3. Escalate if needed → Move up hierarchy
  4. Queue if all busy → Store in deque for later
  5. Complete call → Free employee for next call

Potential Improvements

  1. Priority queue: Support VIP or urgent calls
  2. Skills-based routing: Route calls based on employee expertise
  3. Load balancing: Distribute calls evenly among available employees
  4. Call statistics: Track metrics like wait time, handle time, escalation rate
  5. Automated callbacks: Call customers back when employee becomes available
  6. Concurrent handling: Use threading for simultaneous call processing
  7. Call recording: Log conversations for quality assurance