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
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
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
Julien Lange Julien Lange
Author Profile Icon Julien Lange
Julien Lange
Arrow right icon
View More author details
Toc

Comparing the three patterns


Though they seem dissimilar, there are several ways in which we can compare these three patterns:

  • Reusability: All three patterns aim to relieve the developer of implementing a common code repeatedly. Indeed, once the visitor has been implemented, they can be reused with different types of objects without any changes. To facilitate the reuse, you must limit the number of states the visitor needs to be aware of. The interpreter pattern is designed to parse an input where the structure is data driven. The Caretaker and memento classes of the Memento pattern are independent of the data, only the originator should be changed.

  • Working with structure: These patterns are intended to work with structures. Visitor and interpreter require the developer to write traversing codes whereas the memento pattern moves the structure as a whole, relying on the serialization to do the traversing.

  • Objects as argument: In the memento and visitor patterns, objects are passed around...

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 $19.99/month. Cancel anytime
Banner background image