OOD / Concurrency• Patterns: Strategy, Observer
Ride Sharing
Hard
Problem Summary
Design a ride-sharing pool system (similar to Uber Pool) where riders share a trip and split fares dynamically.
Functional Scope
- Match riders travelling along similar routes (coordinate routes checks).
- Calculate fare dynamically based on distance, time, and active splits.
- Real-time coordination of driver pick-up sequences.
Entity-Relationship (ER) Schema
PoolTrip [1] <---> [1..4] Rider PoolTrip [1] <---> [1] Driver PoolTrip [1] <---> [1] Route Route [1] <---> [2..8] Location
Design Approach
Model routing as a directed graph traversal problem. Decouple pickup sequences from driver location tracking using a modular route manager.
Core Classes & Models
PoolTrip (Multiple Rider list, Driver, Route mapping)Route (Sequence of pick-up and drop-off coordinates)FareSplitter (Strategy for split rates)
Code Blueprint
public class PoolTrip {
private List<Rider> riders = new ArrayList<>();
public synchronized boolean join(Rider r) { return true; }
}