liveBook · Manning

Protocol-oriented programming

As explained in Classic Computer Science Problems in Swift: Essential techniques for practicing programmers

A programming style that emphasizes protocols and composition over class inheritance.

Protocol-oriented programming puts interfaces and composition ahead of inheritance. Protocols serve as the main building blocks, while generics keep concrete vertex types flexible. section 4.1

A protocol-first graph framework combines:

  • An Edge protocol describing vertex indices, reversal, and printable representations. section 4.1

A reusable city graph

An UnweightedGraph<String> stores cities as vertices and adds undirected connections such as Seattle–Chicago and Phoenix–Dallas. Printing the graph exposes each city's adjacency list.

How Classic Computer Science Problems in Swift: Essential techniques for practicing programmers covers it

How deep it goes
Works through protocols, generics, extensions, adjacency lists, and a concrete graph, without developing the paradigm broadly.
Examples
Demonstrates an Edge protocol, an UnweightedGraph<String>, and a city adjacency list.
What you can do after
Builds a generic graph framework by defining protocols, extending shared behavior, and composing concrete graph types.
How it connects
Connects protocols with composition, inheritance, generics, interfaces, and graph representations.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Classic Computer Science Problems in Swift: Essential techniques for practicing programmers. The section links point to the parts of the book it draws on.