Daily iOS
Architecture

Protocol-oriented composition

In an iOS ride service feature with route guidance, fare calculation, and live location updates, the inheritance hierarchy has gotten complicated. With protocol-oriented design, how would you compose the shared capabilities and the per-service differences?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Instead of an inheritance hierarchy, one small protocol per capability, like location streaming, fare calculation, and route guidance. Service types like taxi or designated driver adopt only the protocols they need, and shared implementation goes into protocol extension defaults or a concrete object owned as a property.

Share a question