Skip to main content
  • 1052 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Authors

Rights and permissions

Reprints 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

Publish with us

Policies and ethics