Description
Course info
Rating
(16)
Level
Intermediate
Updated
Apr 5, 2017
Duration
1h 15m
Description

Software design patterns are standard, proven ways to solve various problems programmers encounter. In this course, Design Patterns in Swift: Structural, you'll learn the structural design patterns and the way they are implemented using Swift 3. First, you'll explore the adapter pattern and bridge design patter. Next, you'll discover the composite pattern and the decorator design pattern. Then, you'll cover the great Swift language feature called extension. Finally, you'll learn about the facade, flyweight, and proxy design patterns. After completing this course, you'll be able to choose the right structural design pattern and implement it in an efficient way using Apple's Swift 3 programming language.

About the author
About the author

Karoly is a veteran (mobile) developer having built several successful iOS apps and games, most of which were featured by Apple.

More from the author
Design Patterns in Swift: Behavioral
Intermediate
2h 36m
Dec 28, 2017
Design Patterns in Swift: Creational
Intermediate
1h 18m
Dec 5, 2016
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi everyone. My name is Karoly Nyisztor. Welcome to my course, Design Patterns in Swift: Structural. I am a software engineer and a professional iOS developer. This course is an overview of the structural design patterns and the way they are implemented using Swift 3. This is actually the second part of a series of courses on design patterns in Swift. So, the topics we cover in this course are the following. We'll start with the adapter pattern. Next we'll analyze the problem of exploding class hierarchies, and the solution provided through the Bridge design pattern. Then we are going to talk about the composite pattern, followed by the Decorator design pattern. We'll also take a closer look at the great Swift language feature called Extension. The facade design pattern comes next, and we are going to demonstrate its benefits by implementing an easy to use downloader framework. Next we'll talk about the flyweight pattern. We are going to create a logging framework which relies on the Unified Logging System introduced in iOS 10. We finish the course with the proxy design pattern. By the end of this course, you will have learned these patterns and more, and you will be ready to apply them in your Swift projects. Before beginning the course, you should be familiar with Swift, but you don't have to be an expert by any means. Please join me on this journey to learn structural design patterns with the Design Patterns in Swift: Structural course on Pluralsight. We hope you enjoy it.

Composite
Hi, there! In this module, we'll talk about a composite design pattern. As usual, we will start with the motivation for using this pattern. Then, I'm going to demonstrate the problem solved by the composite pattern, by a demo project called DirList. This pattern can be used to create recursive tree structures of related objects where any element can be a composition of objects or an individual object. Each element of the structure may be accessed in a uniform manner without having to know whether we use a collection or a leaf object. All types participating in the composite must implement the same interface. So, here's a formal definition. The composite pattern allows related individual objects and collections of objects to be treated uniformly. Clients can ignore the difference between leaf and composed objects, and only use one type or protocol when accessing the elements within the composite structure.

Decorator
Hello, welcome to the fifth module in this course. In this module, we are going to talk about the Decorator or Design Pattern. First of all, as always, we are going to talk about the motivation for using the Decorator Pattern. Then, we'll explore a Swift language feature called Extensions. Next, I'm going to show you how to implement the Decorator in Swift. We are going to enhance the UIColor class so that it can generate color from HTML color codes. Finally, we create a UI label Decorator which lets us easily creates labels with rounded corners and colored borders. The Decorator or Design Pattern allows adding new behavior to existing types. We can extend the functionality of the type without modifying its implementation which is a flexible alternative to subclassing. The Decorator can be implement via wrapping the object to be enhanced. Another way to extend an existing type is by using the Swift language feature called Extension. Extensions provide the ability to add additional methods to types without having to suppress or change their source code. I'm going to show you how to implement the Decorator via both object wrapping and Swift Extensions. To sum it up, the Decorator or Design Pattern adds new responsibilities to objects without modifying the code of the type used to create them.