Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Design Patterns with Swift

You're reading from   Hands-On Design Patterns with Swift Master Swift best practices to build modular applications for mobile, desktop, and server platforms

Arrow left icon
Product type Paperback
Published in Dec 2018
Publisher Packt
ISBN-13 9781789135565
Length 414 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (3):
Arrow left icon
Giordano Scalzo Giordano Scalzo
Author Profile Icon Giordano Scalzo
Giordano Scalzo
Florent Vilmart Florent Vilmart
Author Profile Icon Florent Vilmart
Florent Vilmart
Sergio De Simone Sergio De Simone
Author Profile Icon Sergio De Simone
Sergio De Simone
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Refreshing the Basics 2. Understanding ARC and Memory Management FREE CHAPTER 3. Diving into Foundation and the Standard Library 4. Working with Objective-C in a Mixed Code Base 5. Creational Patterns 6. Structural Patterns 7. Behavioral Patterns 8. Swift-Oriented Patterns 9. Using the Model-View-Controller Pattern 10. Model-View-ViewModel in Swift 11. Implementing Dependency Injection 12. Futures, Promises, and Reactive Programming 13. Modularize Your Apps with Swift Package Manager 14. Testing Your Code with Unit and UI Tests 15. Going Out in the Open (Source) 16. Other Books You May Enjoy

Refreshing the Basics

In order to properly kick-start our journey through Swift's best practices and design patterns, I believe it's important that we take some time to go back to the basics. It's important to always keep your foundation strong; the more we advance through this book, the more we'll rely on those concepts.

I'll assume that you have a proper understanding of object-oriented programming (OPP) fundamentals, classes, inheritance, composition, and other techniques, as well as a fundamental understanding of the differences between value and reference types. If you're rusty on these concepts, you shouldn't worry too much, as we'll cover them shortly.

This chapter will dive deeply into the Swift language. What is a struct, and what is a class? What are their differences? Should you use an enum or an OptionSet? All of these questions will be answered in this chapter. We'll go back to the basics of classes and inheritance, and we'll discover the power of value types and immutability. We'll look it functions, closures, and currying. If you're unfamiliar with these constructs, or if you just want to get a refresher, you should tag along as we go back to the basics. These basics are essential to the Swift language, and are required to successfully apply efficient design patterns and best practices.

In this first chapter, we'll take the time to go back to the basics by covering the following topics:

  • Classes and structs: what they are, and how they behave
  • Exploring enums and their capabilities and extensibility
  • Getting functional with closures and functions
  • Introducing protocols and scratching the surface of extending protocols
  • Concluding with other useful language constructs, such as type aliases, tuples, and generics
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime