O'Reilly logo

Swift Programming: The Big Nerd Ranch Guide by John Gallagher, Matthew Mathias

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Protocol Composition

Protocol inheritance is a powerful tool that lets you easily create a new protocol that adds requirements to an existing protocol or set of protocols. Nevertheless, using protocol inheritance can potentially lead you to make poor decisions in creating your types. In fact, that is exactly what has happened with TabularDataSource when you made it inherit from CustomStringConvertible because you wanted to be able to print a description of the data source. (In fairness, you did it because we told you to.) There is not anything inherently CustomStringConvertible about a tabular data source. Go back and fix that misguided attempt to print data sources.

Listing 19.14 TabularDataSource should not be CustomStringConvertible ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required