← All topics/Networking & data

Practical interview questions

Scenario-style prompts with sample answer outlines. Focus is on how you would design and reason in real codebases.

Question 1

Designing a networking layer

How would you design a scalable and maintainable networking layer for an iOS app?

Answer outline

A scalable networking layer is built around clear separation of responsibilities — each layer has one job.

  1. 1.Transport layer — makes requests and returns responses; nothing more.
  2. 2.Endpoint definitions — describe paths, methods, headers, query parameters, and bodies in a consistent way.
  3. 3.Decoding and error-mapping — converts raw responses into typed models and app-level failures so feature code never touches URLSession directly.

Keep it protocol-driven so features depend on abstractions, not concrete URLSession code. Centralize cross-cutting concerns — authentication, retries, logging — so they don't scatter across features. As the app scales, teams should be able to add endpoints without rethinking the whole stack.

Principles

  • Split the stack into distinct layers — transport, endpoint definition, decoding, and business logic never mix.
  • Depend on protocols rather than concrete URLSession code so each layer is independently testable.
  • Map network errors into typed app-level categories at the boundary — feature code should never inspect raw status codes.
  • Centralize cross-cutting concerns like auth, retries, and logging so they stay consistent and easy to change.
  • New endpoints should be addable without touching transport or decoding layers.