<p><b>Build fast and powerful applications by harnessing the power of protocol-oriented programming in Swift 4</b><p><b>About This Book</b><p><li>Leverage the power of protocol-oriented programming in your applications and learn from real-world use cases<li>Create a flexible code base with protocols
Swift Protocol-Oriented Programming: Increase productivity and build faster applications with Swift 5, 4th Edition
โ Scribed by Jon Hoffman
- Publisher
- Packt Publishing
- Year
- 2019
- Tongue
- English
- Leaves
- 217
- Category
- Library
No coin nor oath required. For personal study only.
โฆ Synopsis
Get up to speed with the protocol-oriented programming paradigm to ensure better code maintainability and increased performance with Swift programming
Key Features
- Use protocol-oriented programming to enhance your applications
- Use generics to create flexible frameworks
- Learn how to implement common design patterns in a protocol-oriented way
Book Description
Protocol-oriented programming (POP) is an incredibly powerful concept at the heart of Swift's design. Swift's standard library was developed using POP techniques, generics, and first-class value semantics, which makes it important for every Swift developer to understand these core concepts and use them effectively. This updated fourth edition will help you get to grips with the latest version of the Swift programming language.
You will start by understanding what protocol-oriented programming is and how it is different from other programming paradigms such as object-oriented programming. Next, the book will systematically guide you through memory management, before progressing to cover essential topics such as generics, Copy-On-Write, extensions, and protocols. As you advance, you'll focus on adopting design patterns in Swift. The concluding chapters will even demonstrate how you can use protocol-oriented programming techniques with the help of real-world use cases.
By the end of this book, you will have learned how to use protocol-oriented programming techniques to build powerful and practical applications.
What you will learn
- Explore the differences between object-oriented programming and protocol-oriented programming
- Understand why value types should be prioritized over reference types
- Delve into protocols, protocol inheritance, protocol composition, and protocol extensions
- Become well-versed with implementing COW (Copy-On-Write) within your custom value types
- Understand how memory management works in Swift and how to avoid common pitfalls
- Design applications by starting with the protocol rather than the implementation
Who this book is for
This book is for Swift developers who have basic knowledge of the Swift programming language and are looking to understand how they can use protocol-oriented programming techniques in their applications.
Table of Contents
- Starting with the Protocol
- Our Type Choices
- Extensions
- Generics
- Memory Management
- Object-Oriented Programming
- Protocol-Oriented Programming
- Adopting Design Patterns in Swift
- Case Studies
โฆ Table of Contents
Cover
Title Page
Copyright and Credits
About Packt
Contributors
Table of Contents
Preface
Chapter 1: Starting with the Protocol
Protocol syntax
Defining a protocol
Property requirements
Method requirements
Optional requirements
Protocol inheritance
Protocol composition
Using protocols as a type
Polymorphism with protocols
Type casting with protocols
Associated types with protocols
Delegation
Designing with protocols
Protocols in the Swift standard library
Summary
Chapter 2: Our Type Choices
Classes
Structures
Access controls
Enumerations
Tuples
Protocols
Value and reference types
Recursive data types for reference types only
Inheritance for reference types only
Dynamic dispatch
Swift's built-in types
COW
Summary
Chapter 3: Extensions
Defining an extension
Protocol extensions
Text validation
Extensions with the Swift standard library
Conforming to the Equatable protocol
Summary
Chapter 4: Generics
Generic functions
Type constraints with generics
Generic types
Associated types
Generic subscripts
COW
Generics in a protocol-oriented design
Generics in the Swift standard library
Summary
Chapter 5: Memory Management
How ARC works
Strong reference cycles
Unowned references
Weak references
Summary
Chapter 6: Object-Oriented Programming
What is object-oriented programming?
Requirements for the sample code
Swift as an object-oriented programming language
Class diagrams
Object-oriented design
Vehicle superclass
Vehicle subclasses
Polymorphism
Issues with object-oriented design
Summary
Chapter 7: Protocol-Oriented Programming
Requirements for the sample code
Swift as a protocol-oriented programming language
Protocol inheritance
Protocol composition
Protocol extensions
The Vehicle protocol
Vehicle implementations
Summarizing protocol-oriented programming and object-oriented programming
Differences between object-oriented programming and protocol-oriented programming
Protocol and protocol extensions compared with superclasses
Implementing vehicle types
Using value and reference types
The winner is...
Summary
Chapter 8: Adopting Design Patterns in Swift
What are design patterns?
Creational patterns
The singleton design pattern
Understanding the problem
Understanding the solution
Implementing the singleton pattern
The builder design pattern
Understanding the problem
Understanding the solution
Implementing the builder pattern
The factory method pattern
Understanding the problem
Understanding the solution
Implementing the factory method pattern
Structural design patterns
The bridge pattern
Understanding the problem
Understanding the solution
Implementing the bridge pattern
The facade pattern
Understanding the problem
Understanding the solution
Implementing the facade pattern
The proxy design pattern
Understanding the problem
Understanding the solution
Implementing the proxy pattern
Behavioral design patterns
The command design pattern
Understanding the problem
Understanding the solution
Implementing the command pattern
The strategy pattern
Understanding the problem
Understanding the solution
Implementing the strategy pattern
The observer pattern
Understanding the problem
Understanding the solution
Implementing the observer pattern
Summary
Chapter 9: Case Studies
Logging services
Requirements
The design
Conclusion
The data access layer
Requirements
The design
The data model layer
The data helper layer
The bridge layer
Using the data-access layer
Conclusion
Summary
Other Books You May Enjoy
Index
๐ SIMILAR VOLUMES
<p><b>Build fast and powerful applications by exploiting the power of protocol-oriented programming in Swift</b><p><b>About This Book</b><p><li>The only book that shows how to harness the power of Protocol-Oriented Programming in Swift to build real-world applications,<li>Get familiar with the proto