Swift 2 Design Patterns
eBook - ePub

Swift 2 Design Patterns

Julien Lange

Partager le livre
  1. 224 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Swift 2 Design Patterns

Julien Lange

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

Build robust and scalable iOS and Mac OS X game applications

About This Book

  • Learn to use and implement the 23 Gang of Four design patterns using Swift 2
  • Design and architect your code for Swift application development
  • Understand the role, generic UML design, and participants in the class diagram of the pattern by implementing them in a step-by-step approach

Who This Book Is For

This book is intended for competent Swift developers who want to apply enduring design patterns with Swift to structure and scale their application code.

What You Will Learn

  • Choose the appropriate pattern depending on the problem to be solved
  • Understand the generic class diagram of each of the 23 GoF patterns and how each object participates in the pattern
  • Use Swift to implement these patterns even though the language doesn't provide all of the object-oriented programming concepts such as abstract class, interface, and so on
  • Architect your software to avoid the overuse of memory, time spent on calculations, or high network traffic
  • Find the best way to organize your code to make it more secure from the outside world
  • Prepare your code to make it more flexible when the consumer changes or the third-party component hidden code changes
  • Structure your code to change the algorithm to apply at runtime
  • Deliver Flyweight responsibility to your objects

In Detail

Swift is a multi-paradigm language. It has expressive features familiar to those used to work with modern functional languages, while also keeping the object-oriented features of Objective-C. It remains compatible with Apple's legacy codes and frameworks. A design pattern systematically names, motivates, and explains a general design that addresses a recurring design problem in object-oriented systems. It describes the problem, the solution, when to apply the solution, and its consequences. It also gives implementation hints and examples. Knowledge about design patterns is also one of the best ways to make you different compared to other low-level developers.

This book shows you how to use Swift 2 to learn about 23 Gang of Four (GoF) design patterns, and is organized into three categories. The book will present you the five creational patterns, followed by the seven structural patterns, and finishing with the 11 behavioral patterns as defined by the GoF. Each chapter will introduce the pattern by defining its role, which common problems the pattern should be used for, its generic UML representation, how each objects presented in the class diagram participate in the pattern, and what the role of each of these objects is. The book then presents you with a concrete case as an illustration that will be used to implement the pattern using Swift.

Style and approach

A step-by-step tutorial completed with screenshots and code highlights wherever necessary. Each chapter discusses one or more patterns with its definitions and a simple-to-follow illustration case using a playground or XCText project to implement it with Swift.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Swift 2 Design Patterns est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Swift 2 Design Patterns par Julien Lange en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Application Development. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2015
ISBN
9781785887611

Swift 2 Design Patterns


Table of Contents

Swift 2 Design Patterns
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
eBooks, discount offers, and more
Questions
1. Creational Patterns
The prototype pattern
Roles
Design
Participants
Collaborations
Illustration
Implementation
Usage
The factory method pattern
Roles
Design
Participants
Illustration
Implementation
Usage
The singleton pattern
Roles
Design
Participants
Collaborations
Illustration
Implementation
Usage
The abstract factory pattern
Roles
Design
Participants
Collaborations
Illustration
Implementation
Usage
The builder pattern
Roles
Design
Participants
Collaborations
Illustration
Implementation
Usage
Implementation using closures
Summary
2. Structural Patterns – Decorator, Proxy, and Bridge
Static and dynamic composition
The decorator pattern
Roles
Design
Participants
Collaboration
Sample
Implementation
Usage
The proxy pattern
Roles
Design
Participants
Collaboration
Illustration
Implementation
Usage
The bridge pattern
Roles
Design
Participants
Collaboration
Illustration
Implementation
Usage
Summary
3. Structural Patterns – Composite and Flyweight
The composite pattern
Roles
Design
Participants
Collaboration
Illustration
Implementation
Implementation of the VODComponent
Implementation of the VODItem leaf
Implementation of the VODCategory composite
Usage
The flyweight pattern
Roles
Design
Participants
Collaboration
Illustration
Implementation
Usage
Performance results
Summary
4. Structural Patterns – Adapter and Facade
The adapter pattern
Roles
Design
Participants
Collaboration
Illustration
Implementing our first prototype
Implementation
Implementation of our adaptees
Implementation of the SamSingAdapter class
Implementation of the PearAdapter class
The facade pattern
Roles
Design
Participants
Collaboration
Illustration
Implementation of the facade
Summary
5. Behavioral Patterns – Strategy, State, and Template Method
The strategy pattern
Roles
Design
Participants
Collaboration
Illustration
Implementation
The state pattern
Role
Design
Participants
Collaboration
Illustration
Implementation
The template method
Role
Design
Participants
Collaboration
Illustration
Implementation
Summary
6. Behavioral Patterns – Chain of Responsibility and Command
The chain of responsibility pattern
Roles
Design
Participants
Collaboration
Illustration
Implementation
The command pattern
Roles
Design
Participants
Collaboration
Illustration
Implementation
Comparison between the chain of responsibility and command patterns
Summary
7. Behavioral Patterns – Iterator, Mediator, and Observer
The iterator pattern
Roles
Design
Participants
Collaboration
Illustration
Implementation
The mediator pattern
Roles
Design
Participants
Collaboration
Illustration
Implementation
The observer pattern
Roles
Design
Participants
Collaboration
Illustration
Implementation
Summary
8. Behavioral Patterns – Visitor, Interpreter, and Memento
The visitor pattern
Roles
Design
Participants
Collaboration
Illustration
Implementation
The interpreter pattern
Roles
Design
Participants
Collaboration
Illustration
Implementation
The memento pattern
Roles
Design
Participants
Collaboration
Illustration
Implementation
Comparing the three patterns
Summary
Index

Swift 2 Design Patterns

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: October 2015
Production reference: 1231015
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78588-761-1
www.packtpub.com

Credits

Author
Julien Lange
Reviewers
Vladimir Pouzanov
Victor Sigler
Ye Xiaodong
Acquisition Editor
Tushar Gupta
Content Development Editor
Shali Deeraj
Technical Editor
Saurabh Malhotra
Copy Editors
Rashmi Sawant
Sneha Singh
Project Coordinator
Kinjal Bari
Proofreader
Safis Editing
Indexer
Hemangini Bari
Graphics
Disha Haria
Jason Monteiro
Abhinash Sahu
Production Coordinator
Komal Ramchandani
Cover Work
Komal Ramchandani

About the Author

Julien Lange is a 34-year-old IT expe...

Table des matiĂšres