iOS Development at Scale: App Architecture and Design Patterns for Mobile Engineers

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Scale mobile applications to handle an enormous user base and development team. This book outlines the scaling challenges that mobile engineers face and some standard techniques and design patterns to deal with those issues.

You already know the basics of iOS development, but how do you learn the key concepts and patterns to scale a mobile application? You’ll start by learning the fundamentals of the iOS platform often overlooked when using out-of-the-box iOS solutions. While standard iOS solutions might work at a small scale, the most prominent tech companies reinvent these for highly customized usage, making understanding the underlying concepts crucial. Understanding these concepts reduces ramp-up time and allows engineers to understand the "why" intuitively.

Having mastered the fundamentals, you'll next focus on architecture and design principles to build, maintain, and release features within a large codebase and the soft skills to enact change in a larger organization. You’ll be empowered with a deeper understanding of iOS design patterns and the industry knowledge necessary to take their features from idea to production. You’ll also study the people skills to get things done in a large organization―a critical step to growing one's career.

Upon completing iOS Development at Scale, you'll understand the solutions and tradeoffs you can leverage to build better applications and grow your career.

What You'll Learn

  • Apply computer science and engineering fundamentals to the iOS platform
  • Implement knowledge of iOS architecture and best practices at large-scale companies
  • Identify current gaps in your product and gain alignment within the broader organization
  • Solve problems with knowledge of systems architecture and industry best practices to identify and address gaps in your codebase

Who This Book Is For

iOS software engineers and mobile engineer managers. Additionally, any software engineer, manager, or business stakeholder wanting to learn more about mobile development and the challenges that mobile engineers face.

Author(s): Eric Vennaro
Edition: 1
Publisher: Apress
Year: 2023

Language: English
Commentary: An alternative to B6F120143634929FA3E95BBDE45180C8 which doesn't have bookmarks, the drawback is that this book has the TOC pointing to Springer's website instead of inside its own pages.
Pages: xxv, 648
City: Berkeley, CA
Tags: Mobile Architecture; iOS Engineer; Engineering; Mobile Staff Engineer; Software Engineering; iOS Systems Design; App Architecture

Table of Contents
About the Author
About the Technical Reviewers
Introduction
Chapter 1: Swift Familiarization
This Chapter Includes
Structures and Classes
Exploring Reference and Value Types
Summarizing Value and Reference Types
Inheritance for Classes
A Brief Note on Static and Dynamic Polymorphism
Inheritance vs. Polymorphism
Protocols
Wrapping Up Classes and Structs
Classes and Protocols
Classes Have Capabilities That Structs Do Not Have
Generics in Action
Generic Functions
Notes on Placeholder Types
Generic Types
Summary
Three Key Takeaways from This Chapter
Further Learning
Chapter 2: Memory Management
This Chapter Includes
Swift Program Memory Usage
The Stack
Characteristics of Stack Memory
The Heap
Characteristics of Heap Memory
Buffer Overflow and Underflow
Swift Memory Model
Swift Stack Allocation
Swift Heap Allocation
Automatic Reference Counting
Reference Counting in Action
ARC Observed Lifetime Bugs
Some Potential Solutions
Method Dispatch
Direct Static Dispatch
Dynamic Dispatch
Supporting Polymorphism for Value Types
The Existential Container
Inline Value Buffer
Value Witness Table (VWT)
Protocol Witness Table (PWT)
Handling Nested Reference Types
Handling Generics
The Implications of Different Sized Types on PWT Memory Management
Small Types
Large Types
Applied Memory Management
Bug Fixing
Summary
Further Learning
Chapter 3: iOS Persistence Options
Overview
This Chapter Includes
iOS Persistence Options
Saving to a File
File System Security
NSUserDefaults
Keychain
Core Data
Managed Objects
NSManagedObjectContext
NSPersistentStore
NSPersistentCoordinator
Considering When to Use Core Data
Diving into SQLite
What Is SQLite
Serverless
Self-Contained
Zero Configuration
SQLite Architecture
SQL Compiler: The Front End
SQLite Core
SQLite Back End
Deep Dive: B+ Tree Implementation
Search
Insert
Delete
Practical Example: Caching a Photo Stream
Performantly Fetch the Images
Persist Cached Images Across Application Launches
Encapsulate the Caching Solution
Wrapping Up
Questions for the Reader
Summary
Key Takeaways from This Chapter
Further Learning
Chapter 4: Concurrent Programming
Overview
This Chapter Includes
Concurrent Parallel or Async?
Concurrency
Multithreading
Parallelism
Asynchronous Programming
Where Is This Going?
Cost of Concurrency
Thread Cost
Managing State Sharing
Difficult to Debug
Implementing Concurrency
Threads and Locks
Brief Aside on Locks
Using GCD and Dispatch Queues
GCD Key Concepts
Applying GCD to Our Example
Operation Queues
Benefits of Operation Queues
Swift Concurrency
Async Functions
Actors
Swift Tasks
Structured Tasks
Unstructured Tasks
Applying Swift Concurrency
Contrasting with GCD
Rough Edges
Conclusion on Swift Concurrency
Deep Dive: Challenges of Implementing Concurrency
Race Condition
Deadlock
Priority Inversion
Thread Explosion
Considerations for Real-World Applications
Example 1: Scaling Meta’s Newsfeed
Key Takeaway: Design for Scaling
Example 2: Building Swift Concurrency
Key Takeaway: Principles Transcend the Implementation Details
Summary
Three Key Takeaways from This Chapter
Further Learning
Chapter 5: The Importance of Good Architecture
Overview
Defining Good Architecture
Applying Our Modular and Testable Framework to SOLID
Single Responsibility Principle
The Open-Closed Principle
Liskov Substitution Principle (LSP)
Interface Segregation Principle
Dependency Inversion
Modularity
Modularity Case Studies
Uber Redesign for Scale
Creating Component Kit
Airbnb Designing for Productivity
Wrapping Up Modularity
Testability
Testing Case Studies
Large-Scale Testing and Sapienz at Meta
Ziggurat Square’s Testable Architecture
Wrapping Up Testability
Choosing an Architecture
Summary
Three Key Takeaways from This Chapter
Further Learning
Chapter 6: Common Design Patterns
Overview
This Chapter Includes
Why Design Patterns Are the Building Blocks for Design
Specific Needs of Mobile Engineers
Design Patterns
Overarching Themes
Creational
Structural
Behavioral
Delegate Pattern
The Problem
The Solution
Architecture
Code
Trade-Offs
Facade Pattern (Structural)
The Problem
The Solution
Architecture
Pseudocode
Trade-Offs
The Builder Pattern
The Problem
The Solution
Architecture
Code
Note: A Simpler Builder
Trade-Offs
Pros
Cons
The Factory Pattern
The Problem
The Solution
For the Factory Method
For the Abstract Factory
Architecture
Code
Factory Method
Abstract Factory
Trade-Offs
Singleton
The Problem
The Solution
The Architecture
Code
Trade-Offs
Pros
Cons
Dependency Injection (DI)
The Problem
The Solution
The Architecture
Pseudocode
Trade-Offs
Coordinators
The Problem
The Solution
Architecture
Basic Coordinator
Application-Wide Coordinator
Pseudocode
Trade-Offs
Observer
The Problem
The Solution
Architecture
Example Code
Trade-Offs
Runtime Behavior
Memory Management
Complex State Management
Summary
Two Key Takeaways from This Chapter
Further Learning
Chapter 7: Model View Controller (MVC)
Overview
This Chapter Includes
A Detailed Look at MVC
MVC Components
The Model
The View Controller
The View
Component Interactions
Object Construction
Updates to the Model
Updates to the View
The View Controller’s Role
The View State Storage and Updates
Practical Example
Discussion
Trade-Offs
Modularity
A Note on Avoiding Premature Optimization
Testability
MVC at Scale
Summary
Three Key Takeaways from This Chapter
Further Learning
Chapter 8: Model View View-Model (MVVM)
Overview
This Chapter Includes
A Detailed Look at MVVM
MVVM Components
The Model
The View-Model
The View Controller
The View
Component Interactions
Object Construction
Updates to the Model
The View-Model
The View Controller
Updates to the View
The View State
Practical Example
Discussion
Trade-Offs
Overhead
Reactive Programming
Modularity
Testability
Summary
Three Key Takeaways from This Chapter
Further Learning
Chapter 9: VIPER
Overview
This Chapter Includes
A Detailed Look at VIPER
VIPER Components
The View
The View Controller
The Interactor
The Presenter
The Entity
The Router
Component Interactions
Object Construction
Updates to the Model: The Interactor
The Presenter
The View Controller
Updates to the View
The View State
Practical Example
Discussion
Trade-Offs
Advantages
Drawbacks
Modularity
Testability
Summary
Three Key Takeaways from This Chapter
Further Learning
Chapter 10: The Reactive Programming Paradigm
Overview
This Chapter Includes
Reactive Programming
The Rules of the Game
Data Propagation Techniques
Topological Sorting
Interaction with Mutable State
Functional Reactive Programming
Category Theory
Functors
Monoid
Monads
FRP and Combine
Publishers and Subscribers
Combine Behaviors
Functor
Monad
Application Architecture
Application Overview
Area Owner
Feature Owner
Benefits of Reactive Programming and FRP
Summary
Three Key Takeaways from This Chapter
Further Learning
Chapter 11: System Design Process
Overview
This Chapter Includes
Software Development Life Cycle (SDLC)
How SDLC Works
Plan
Strategy Review
Long-Range Planning Document
Road Map
Differences in Planning at Small and Big Companies
Design
Implement
Test
Deploy
Maintain
SDLC Models
Waterfall
Key Tenets
Pros and Cons
Spiral
Key Tenets
Pros and Cons
Agile
Key Tenets
Pros and Cons
Extreme Programming (XP)
Key Tenets
Pros and Cons
Methods Review
Crucial Role of the TL
A Skill-Focused View
Problem Navigation
Solution Design
Communication
Communication Framework
Understand Everyone’s Point of View
Guiding the Conversation
Using a Common Language and Value Framework
Communicating Risk
Technical Communication
Communicating Business Needs
Setting Goals for Success
S: Specific
M: Measurable
A: Achievable
R: Relevant
T: Time-Bound
Goal for Product and Infrastructure Teams
Goal for Metric-Driven Teams
Why Is SDLC Important?
Summary
Four Key Takeaways from This Chapter
Further Learning
Chapter 12: Testability
Overview
This Chapter Includes
Why Test
Unit Testing
Writing Code That Stays Testable
Setter Injection
Integration Testing
Contract Testing
UI Testing
Snapshot Testing
Manual Testing
Managing Testing at Scale
Test Case Prioritization
Categorizing Test Suites
Prioritizing Manual Testing
Managing Testing Over Time
What If I Have No Tests?
Summary
Four Key Takeaways from This Chapter
Further Learning
Chapter 13: Performance
Overview
This Chapter Includes
Why Performance Matters
iOS Factors to Consider
Key Concepts
Topline Metrics
Intermediate Metrics
Funnel Logging
Evaluating Percentiles
Monitoring and Alerting
The Complete Performance Cycle
Know Your Tools
Application Growth
Debugging Performance Problems
Apply Occam’s Razor
Continuous Testing and Evaluation
Performance Metrics
Application Size
Application Startup Time
Application Responsiveness (Hangs)
Battery Drain
Application Crashes
What Is Symbolication?
Network-Related Metrics
Latency
Load
Errors
Engagement Metrics
A Brief Practical Example
Summary
Four Key Takeaways from This Chapter
Further Learning
Chapter 14: Experimentation
This Chapter Includes
Why Experimentation Is Important
Theoretical Experimentation Platform
Universes for Experimentation
Experiment Tooling
Cluster Testing (The Network Effect)
Metrics Evaluation Platform
The Scientific Method and Hypothesis Testing
Applying the Scientific Method to Our Photo Stream Example
Experiment Design and Implementation
Choosing Test Statistics
Assess Sample Size and Distribution
Required Sample Size and Effects on Analysis
Factors That Could Impact User Eligibility
Results Analysis
Types of Errors
Understanding Statistical Significance
Calculating the P-Value
Two- vs. One-Sided Tests
Statistical Power and the Minimum Detectable Effect (MDE)
Holistic Results Analysis
Practical Example for Holistically Interpreting Results
Common Pitfalls
Multiple Comparison Problem
Experiment Pollution
Claiming Not Statistically Significant Results are Neutral
Running Experiments That Are Too Small (Underpowered)
P-Hacking
Filtering on Posttreatment Variables
Dilution
Not Waiting for Results to Stabilize
Nonrepresentative Test Experiences and Populations
Ignoring the Network Effect
Pre-AA Bias
Additional Validation Steps
Summary
Key Takeaways
Further Learning
Chapter 15: Application Release and Maintenance
This Chapter Includes
Managing Continuous Integration and Delivery: The Build Process
Keeping Master Stable
Managing Build Times
Continuous Delivery
The Release Infrastructure
Release Oncall
How to Measure System Success
Can We Move Faster?
Releasing a Large Project
When Building Our Feature
Who Are These Concerned Business Partners?
Meeting Launch Standards
Dogfooding and Limited Release
Release
Alerting and Monitoring
Logging
Monitoring
Alerting
Logging to Alerting Example
Maintenance
Summary
Key Takeaways
Further Learning
Chapter 16: Leading Multiple Teams
This Chapter Includes
Engineer Archetypes
Fixer
Tech Lead
Architect
Executive Assistant
Requirements of Senior Engineer
Breadth
Depth
Scope
Applying Depth, Breadth, and Scope
Level Three: Senior Engineer
Level Four: Staff Engineer
Level Five and Beyond: Principal Engineer and Above
Connecting the Overall System
Brief Aside for Metric-Driven Teams
Establish the Goal
Through Iterative Experimentation, Establish Leading Levers
Understand Additive Combinations for the Launch Candidate
Balancing Each Dimension
Becoming a Well-Rounded Senior Engineer
Brief Aside on Understanding Technical Concepts
Why Are Soft Skills Needed?
Situational Leadership Model
Leadership Styles
Development Levels
Common Pitfalls
Oversupervision: Micromanaging
Undersupervision
Applied to Leading Multiple Teams
Practical Example
Trade-Offs
Relationship Between Senior Engineers and Managers
Mentorship: Scaling Oneself
Building Relationships
How to Be Nice
How to Build Trust
How to Influence People
Combining the Frameworks
Summary
Key Takeaways
Further Learning
Chapter 17: Practical Example
Top-Down vs. Bottom-Up
Setting the Scene
Notes on the Planning/Scoping Phase
Jumping Back into Our Story…
Notes on the Execution/Testing Phase
Jumping Back into Our Story…
Notes on the Deployment/Maintenance Phase
Notes on the Case Study Roles and Archetypes
Archetypes
Chief Architect
Tech Lead
Executive Assistant
Fixer
Overall Notes
Summary
Appendix: Completed Five-Year Plan
Problem Alignment
High-Level Approach
Goals
Review Problem Alignment
Solution Alignment
Key Scoping Documents for MVP Feature Set
Key Flows
Key Logic
Launch Plan
Key Milestones
Operational Checklist
Changelog
Open Questions
Index