CodeFab LLC iPhone Development & Training Architecting a complex iPhone application Alex Cone - Alpha Geek - CodeFab LLC Wednesday, October 7, 2009 1
So What’s The Problem? • No Apple examples of full featured applications • Books cover implementation of features, but not architecture • Developers tend to start with examples and evolve - leading to poor architecture CodeFab LLC iPhone Development & Training Wednesday, October 7, 2009 2
Application Tasks • First Launch • News Preferences • Location Acquisition • Story Load, Caching CodeFab LLC iPhone Development & Training Wednesday, October 7, 2009 3
Application Tasks • Relaunch Update • Recheck Location • Check Data Freshness • Update Data CodeFab LLC iPhone Development & Training Wednesday, October 7, 2009 4
Application Tasks • Handle User Activity • Story Reading • Queries • Sharing... • Advertising • Image Caching • Saving State... CodeFab LLC iPhone Development & Training Wednesday, October 7, 2009 5
Design Challenge • Application Design • Managing Long Running Tasks • Managing Concurrency • Managing Variable Connectivity • Managing Data • Managing State • Managing Complexity CodeFab LLC iPhone Development & Training Wednesday, October 7, 2009 6
Advanced Technology • Singletons • Notifications • Threads • NSOperation/NSOperationQueue CodeFab LLC iPhone Development & Training Wednesday, October 7, 2009 7
Singletons • Decoupled Objects • Data Managers • Cache Managers • State Managers • Specialty Controllers (e.g. LaunchController) • NSApplication, NSUserDefaults, etc... CodeFab LLC iPhone Development & Training Wednesday, October 7, 2009 8
Singletons UIImage *userPic = [[ImageCache shared] cachedImageForKey:[user name]]; ... + (id)shared { static ImageCache *shared = nil; if(!shared){ shared = [[ImageCache allocWithZone:NULL] init]; } return shared; } CodeFab LLC iPhone Development & Training Wednesday, October 7, 2009 9
Notifications • More Object Decoupling • Status Notification • State Change • Pub/Sub Events • NSNotificationCenter CodeFab LLC iPhone Development & Training Wednesday, October 7, 2009 10
Notifications [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateHUD:) name:@”TweetStatusNotification” object:nil]; ... - (void) updateHUD:(NSNotification *)notification { if (nil != self.view.window) { NSString *msg = [[notification userInfo] valueForKey:@”Message”]; [[HUDManager shared] showMessage:msg]; } CodeFab LLC iPhone Development & Training Wednesday, October 7, 2009 11
Threads • UIKit & Foundation Support • performAfterDelay • Background execution with delegate callback (NSHTTPConnection, etc) • NSThreads, NSOperationQueues CodeFab LLC iPhone Development & Training Wednesday, October 7, 2009 12
Process Challenge • Application Development • Managing Development Cycles • Managing Teams • Managing Releases • Testing and QA • Code Reuse CodeFab LLC iPhone Development & Training Wednesday, October 7, 2009 13
Advanced Process • Hyper-Agile Methodology • Daily Iterations • Partial Pair Programming • Monthly Releases CodeFab LLC iPhone Development & Training Wednesday, October 7, 2009 14
Advanced Process • Code Reuse Strategies • Static Libraries • Overlapping Projects Project Project 2 1 Shared Code CodeFab LLC iPhone Development & Training Wednesday, October 7, 2009 15
CodeFab LLC iPhone Development & Training Q&A Architecting Complex iPhone Applications Alex Cone CodeFab LLC abc@codefab.com Wednesday, October 7, 2009 16
Recommend
More recommend