Swift 2 Design Patterns
eBook - ePub

Swift 2 Design Patterns

Julien Lange

Condividi libro
  1. 224 pagine
  2. English
  3. ePUB (disponibile sull'app)
  4. Disponibile su iOS e Android
eBook - ePub

Swift 2 Design Patterns

Julien Lange

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Informazioni sul libro

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.

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
Swift 2 Design Patterns è disponibile online in formato PDF/ePub?
Sì, puoi accedere a Swift 2 Design Patterns di Julien Lange in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Computer Science e Application Development. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Anno
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...

Indice dei contenuti