Swift 2 Design Patterns
eBook - ePub

Swift 2 Design Patterns

Julien Lange

Compartir libro
  1. 224 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

Swift 2 Design Patterns

Julien Lange

Detalles del libro
Vista previa del libro
Índice
Citas

Información del 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.

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Swift 2 Design Patterns un PDF/ePUB en línea?
Sí, puedes acceder a Swift 2 Design Patterns de Julien Lange en formato PDF o ePUB, así como a otros libros populares de Computer Science y Application Development. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
2015
ISBN
9781785887611
Edición
1

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

Índice