Swift 2 Design Patterns

Julien Lange

  • 出版商: Packt Publishing
  • 出版日期: 2015-10-30
  • 售價: $1,150
  • 貴賓價: 9.5$1,093
  • 語言: 英文
  • 頁數: 224
  • 裝訂: Paperback
  • ISBN: 1785887610
  • ISBN-13: 9781785887611
  • 相關分類: Apple DeveloperDesign Pattern
  • 下單後立即進貨 (約3~4週)

商品描述

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.

商品描述(中文翻譯)

建立強大且可擴展的iOS和Mac OS X遊戲應用程式

關於本書
- 使用Swift 2學習和實現23種Gang of Four設計模式
- 設計和架構Swift應用程式開發的程式碼
- 通過逐步的方法實現模式,了解模式在類圖中的角色、通用UML設計和參與者

本書適合對Swift有一定經驗的開發者,希望使用Swift應用持久的設計模式來結構化和擴展他們的應用程式程式碼。

你將學到什麼
- 根據要解決的問題選擇適當的模式
- 了解23種GoF模式的通用類圖以及每個對象在模式中的參與方式
- 使用Swift實現這些模式,即使該語言不提供所有面向對象編程概念,如抽象類、接口等
- 架構軟體以避免過度使用記憶體、計算時間或高網路流量
- 找到最佳方法組織程式碼,使其對外界更安全
- 為消費者變更或第三方組件隱藏程式碼變更時,準備好程式碼以使其更靈活
- 結構化程式碼以在運行時更改算法
- 將Flyweight責任交給對象

詳細內容
Swift是一種多範式語言,它具有對於熟悉現代函數式語言的人來說熟悉的表達性特徵,同時保留了Objective-C的面向對象特性。它仍然與蘋果的舊代碼和框架兼容。設計模式系統地命名、解釋和說明了面向對象系統中解決重複設計問題的一般設計。它描述了問題、解決方案、何時應用解決方案以及其後果。它還提供實現提示和示例。了解設計模式也是使您與其他低級開發者不同的最佳方式之一。

本書將向您展示如何使用Swift 2學習23種Gang of Four(GoF)設計模式,並分為三個類別。本書將首先介紹五種創建型模式,然後是七種結構型模式,最後是GoF定義的11種行為型模式。每個章節將通過定義模式的角色、應該使用該模式解決的常見問題、通用UML表示法以及類圖中每個對象的參與方式來介紹該模式,並使用Swift實現該模式的具體案例。

風格和方法
本書以逐步教程的形式呈現,並配有必要的截圖和程式碼突出顯示。每個章節討論一個或多個模式,並使用Playground或XCText項目來實現Swift。