Chapter 19. Protocols
Your Swift journey has reached the point where you are ready to work with more abstract ideas about writing good code. One such abstraction is the idea of encapsulation – separating the implementation details of a system from the visible features of the system.
Rather than writing your MonsterTown program as a pile of global variables and functions,
you used structs and classes to encapsulate the details of what it means to be a Monster
or a Town
.
You improved your encapsulation by hiding certain implementation details with access control keywords like private
,
cleaning up your types’ interfaces to be as clear and meaningful as possible to developers writing programs with your types. (A type’s interface is its set of ...
Get Swift Programming: The Big Nerd Ranch Guide, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.