Abstract
Do you remember the last time you stuffed a bunch of different algorithms in the same block of code and used spaghetti of if-else / switch-case conditional statements to determine which one to use? The algorithms could be a bunch of functions/methods of similar classes that solve related problems. For example, I have a routine that validates some input data. The data itself can be of any data type (e.g., CGFloat, NSString, NSInteger, etc.). Each of the data types requires a different validation algorithm. If we can encapsulate each algorithm as an object, then we can eliminate a bunch of if-else / switch-case statements for data type checking in order to determine what algorithm to use.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights and permissions
Copyright information
© 2011 Carlo Chung
About this chapter
Cite this chapter
Chung, C. (2011). Strategy. In: Pro Objective-C Design Patterns for iOS. Apress. https://doi.org/10.1007/978-1-4302-3331-2_19
Download citation
DOI: https://doi.org/10.1007/978-1-4302-3331-2_19
Publisher Name: Apress
Print ISBN: 978-1-4302-3330-5
Online ISBN: 978-1-4302-3331-2
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)