Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Swift 2 Design Patterns

You're reading from   Swift 2 Design Patterns Build robust and scalable iOS and Mac OS X game applications

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher
ISBN-13 9781785887611
Length 224 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
 Lange Lange
Author Profile Icon Lange
Lange
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Swift 2 Design Patterns
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Creational Patterns FREE CHAPTER 2. Structural Patterns – Decorator, Proxy, and Bridge 3. Structural Patterns – Composite and Flyweight 4. Structural Patterns – Adapter and Facade 5. Behavioral Patterns – Strategy, State, and Template Method 6. Behavioral Patterns – Chain of Responsibility and Command 7. Behavioral Patterns – Iterator, Mediator, and Observer 8. Behavioral Patterns – Visitor, Interpreter, and Memento Index

The template method


The template method pattern is a simple pattern used when you need a general behavior but where the details of the algorithm must be specific to subclasses.

Role

The template method pattern isolates various parts of an algorithm. The algorithm skeleton is defined in an abstract class where some steps of the algorithm are delegated to its subclasses and some others are fixed in the abstract class itself and cannot be overridden in subclasses.

Design

The following diagram describes the generic structure of the template method:

Participants

The participants of this pattern are as follows:

  • The AbstractClass, which defines the template method, and the signature of the sub parts of the algorithm are invoked by the template method.

  • The ConcreteClass implements abstract methods used by the template method of the AbstractClass. It is possible to have several concrete classes.

Collaboration

The algorithm defined in the template method is called TemplateMethod() in the generic UML class diagram...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images