SlideShare a Scribd company logo
1 of 46
Agenda
•   Project Structure
•   Design Patterns & Architecture
•   Storing Data
•   Coding Conventions
What main design pattern does
Apple recommend for
structuring
your iOS projects?
Model-View-Controller
                   Controller
            Update
                   Coordination            Changes




                    Changes       Update
    Model   Data                               View
                                               Display
Default Project




                  • Notice Classes is a
                    catch-all default
                    ‘’bucket’’ for code
MVC Formatted Project
• Remove references
• Create class folders
  in Finder
  •   AppDelegate
  •   Controllers
  •   Helpers
  •   Models
• Drag into Xcode
According to Apple, should the
model, view or controller be used
to capture events?
Roles & Responsibilities
• Model
  • Data/Algorithms/Networking
  • Most of your custom code lives here
• View
  • Display/Event Capture/Visual Appeal
  • Don’t try to reinvent UIKit, use it
• Controller
  • Coordination/Delegation/Odd Jobs
  • Transitions, Startup/Shutdown
Is this a good pattern & why?




        Update
Don’t cut out the controller!
  Avoid bi-directional messaging

 Reject
 Delay
Validate


                       Update



                 •   Network Access
                      • Multiple
                        Choices
                      • Commit
Is this a good pattern & why?
Loose Coupling

• Don’t skip MVC layers when messaging
  • Use controllers to coordinate messages
• Don’t mix MVC roles in one object
  • Don’t gather too much work in one place
• Don’t declare data in your view classes
  • Maintenance nightmare
  • You can display data in a view, just don’t store it
What are three of the design
patterns used to communicate
between the model, view &
controller?
Communication Between Objects

    Target-Action                    Notification               Delegation
   Reuse controls without           Broadcast changes             Control reuse
       subclassing                                                     “Yes”




   « When tapped, call this
         method »                       « Software keyboard        “End Editing?”
-setTarget:(id)target action:(SEL)action…about to appear! »     UIKit (UIScrollView, ect)
                                       NSNotificationCenter         Will/Did/Should
                                                              -(void)scrollViewDidZoom:
How do you create a custom
controller to split the screen in two
parts?
You Don’t!
    Use the UISplitViewController

• Don’t try to reinvent the wheel
   • UIKit has a lot of the base controls you need
   • Really question whether you need a custom
     control (and if it exists already)
• Don’t misuse framework classes
   • ie Removing views from UIViewControllers
• Don’t try to reinvent the way models, views &
  controllers talk to each other
   • Use delegates & notifications
Is this a good pattern & why?




-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
  if ([scrollView isKindOfClass:[UITableView class]}){
     // do something
  } else {
    // use UIScrollView logic
}
Class checks in delegate methods
Code unmanagable over time - EverythingControllers
Coding horror - iOS version of a GOTO
Correct Approach on
iPad
Parcel out your
controllers
MANDATORY: ALWAYS write/model out your
    iOS app design before coding!
At first, I was like…   But then, it was like…
   (in your brain)           (in the repo)
Creating an MVC diagram of your project
• Means you thought through the architecture
• Means you know how the code will be organized
  physically & logically
• Means you potentially avoided structural bugs
• Easier to validate with the team
• High quality projects & happy clients
What’s the optimal architecture for
a Universal Application?
Optimal Universal App Architecture


    iPhone App                     iPad App


       UI Framework (Views & Controllers)



    Non-UI Framework (Networking & Models)
Photo Sharing Application

                      Data from the model
                      is in both the inspector
                      and in the toolbar
MVC Structure
    Update                Change




             Change




                      Update
What are the six primary ways of
storing data on iOS?
Six Model Options

•   Property Lists
•   Archives
•   Custom Files
•   Server/iCloud/APIs
•   SQLite
•   CoreData
According to Apple, what data should
you store in your App
Defaults/Preferences?
Don’t store data in settings!

• Wrong tool for the job
• App may get rejected
• Settings Panel test
  • On/Off Advanced Features
What should you use for quick storage
of
strings, numbers, arrays, dictionaries, e
ct?
Property Lists.
What should you use to store partial
graphs?
CoreData
•   Modeling Tools
•   Simple save/restore
•   Queries
•   Data Protection
•   Ordered Relationships
•   UIManagedDocument
•   Partial Graphs
•   Undo
•   Incremental Stores
•   ect…
What should you use to include data
with queue-based concurrency in your
app?
CoreData again.
What should you use if you are dealing
with a lot of legacy code or data, or you
need to create an NSObject-based
graph?
Custom Files.
When would you want to use a data
archive?
For easily « serializing »
and « deserializing »
objects in a data file.
What are the two primary features of
SQLite?
Provides Database functionality for iOS apps
Supports Object Relational Mapping
Know Your Data Model Options

•   Property Lists
•   Archives
•   Custom Files
•   Server/iCloud/APIs
•   SQLite
•   CoreData
Coding Conventions
 •   Brace style for if-else
 •   Parenthesis style
 •   Leading underscores
 •   Code indenting
 •   CapitalizationStyle (ie capitalization_style)

 Check out the Google iOS Style guide &
 Apple docs: http://google-
 styleguide.googlecode.com/svn/trunk/objcguide
 .xml
What is KVO?
Key-Value Observing (KVO)
 •   Requires your code to be compliant
 •   Follow style guide
 •   Instrument your own notifications
 •   Automatic Change Notifications for your objects
iOS Coding Best Practices

More Related Content

What's hot

Authentication and Authorization in Asp.Net
Authentication and Authorization in Asp.NetAuthentication and Authorization in Asp.Net
Authentication and Authorization in Asp.NetShivanand Arur
 
Exceptionhandling
ExceptionhandlingExceptionhandling
ExceptionhandlingNuha Noor
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cyclemyrajendra
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Conceptsthinkphp
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycleSoham Patel
 
Android notification
Android notificationAndroid notification
Android notificationKrazy Koder
 
exception handling in java.ppt
exception handling in java.pptexception handling in java.ppt
exception handling in java.pptVarshini62
 
Introduction to iOS Development
Introduction to iOS DevelopmentIntroduction to iOS Development
Introduction to iOS DevelopmentAsim Rais Siddiqui
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language Hitesh-Java
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state managementpriya Nithya
 
Flutter presentation.pptx
Flutter presentation.pptxFlutter presentation.pptx
Flutter presentation.pptxFalgunSorathiya
 
Exception Handling In Java
Exception Handling In JavaException Handling In Java
Exception Handling In Javaparag
 

What's hot (20)

Authentication and Authorization in Asp.Net
Authentication and Authorization in Asp.NetAuthentication and Authorization in Asp.Net
Authentication and Authorization in Asp.Net
 
Exceptionhandling
ExceptionhandlingExceptionhandling
Exceptionhandling
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Applet life cycle
Applet life cycleApplet life cycle
Applet life cycle
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
 
Introduction to EJB
Introduction to EJBIntroduction to EJB
Introduction to EJB
 
Fragment
Fragment Fragment
Fragment
 
Android notification
Android notificationAndroid notification
Android notification
 
exception handling in java.ppt
exception handling in java.pptexception handling in java.ppt
exception handling in java.ppt
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Introduction to iOS Development
Introduction to iOS DevelopmentIntroduction to iOS Development
Introduction to iOS Development
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
Flutter presentation.pptx
Flutter presentation.pptxFlutter presentation.pptx
Flutter presentation.pptx
 
Android UI
Android UIAndroid UI
Android UI
 
Flutter
FlutterFlutter
Flutter
 
Exception Handling In Java
Exception Handling In JavaException Handling In Java
Exception Handling In Java
 
Windowforms controls c#
Windowforms controls c#Windowforms controls c#
Windowforms controls c#
 

Similar to iOS Coding Best Practices

Android architectural components
Android architectural componentsAndroid architectural components
Android architectural componentsMuhammad Ali
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesQamar Abbas
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to conceptsAbhishek Sur
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Thomas Robbins
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - IntroductionSagar Acharya
 
Code igniter overview
Code igniter overviewCode igniter overview
Code igniter overviewumesh patil
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutAndoni Arroyo
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015Hossein Zahed
 
Single Page Applications - Desert Code Camp 2012
Single Page Applications - Desert Code Camp 2012Single Page Applications - Desert Code Camp 2012
Single Page Applications - Desert Code Camp 2012Adam Mokan
 
iOS apps in Swift
iOS apps in SwiftiOS apps in Swift
iOS apps in SwiftNuno Dias
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCUlrich Krause
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net coreSam Nasr, MCSA, MVP
 
Customizing ERModernLook Applications
Customizing ERModernLook ApplicationsCustomizing ERModernLook Applications
Customizing ERModernLook ApplicationsWO Community
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesUlrich Krause
 
Hanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvcHanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvcdenemedeniz
 
Real-world Entity Framework
Real-world Entity FrameworkReal-world Entity Framework
Real-world Entity FrameworkLynn Langit
 
MVC + ORM (with project implementation)
MVC + ORM (with project implementation)MVC + ORM (with project implementation)
MVC + ORM (with project implementation)Prateek Chauhan
 

Similar to iOS Coding Best Practices (20)

Android architectural components
Android architectural componentsAndroid architectural components
Android architectural components
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
Code igniter overview
Code igniter overviewCode igniter overview
Code igniter overview
 
Module2
Module2Module2
Module2
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockout
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015
 
Single Page Applications - Desert Code Camp 2012
Single Page Applications - Desert Code Camp 2012Single Page Applications - Desert Code Camp 2012
Single Page Applications - Desert Code Camp 2012
 
iOS apps in Swift
iOS apps in SwiftiOS apps in Swift
iOS apps in Swift
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVC
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net core
 
Customizing ERModernLook Applications
Customizing ERModernLook ApplicationsCustomizing ERModernLook Applications
Customizing ERModernLook Applications
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPages
 
Sitecore mvc
Sitecore mvcSitecore mvc
Sitecore mvc
 
Hanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvcHanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvc
 
Real-world Entity Framework
Real-world Entity FrameworkReal-world Entity Framework
Real-world Entity Framework
 
MVC + ORM (with project implementation)
MVC + ORM (with project implementation)MVC + ORM (with project implementation)
MVC + ORM (with project implementation)
 
Php and-mvc
Php and-mvcPhp and-mvc
Php and-mvc
 

More from Jean-Luc David

Implementing Biometric Authentication & Features in iOS Apps
Implementing Biometric Authentication & Features in iOS AppsImplementing Biometric Authentication & Features in iOS Apps
Implementing Biometric Authentication & Features in iOS AppsJean-Luc David
 
Add Machine Learning to your iOS 11 App Using Core ML
Add Machine Learning to your iOS 11 App Using Core MLAdd Machine Learning to your iOS 11 App Using Core ML
Add Machine Learning to your iOS 11 App Using Core MLJean-Luc David
 
Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)
Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)
Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)Jean-Luc David
 
Intro to HTTP and Node.js
Intro to HTTP and Node.jsIntro to HTTP and Node.js
Intro to HTTP and Node.jsJean-Luc David
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBJean-Luc David
 
Venture For Canada - Growing Your Startup
Venture For Canada - Growing Your StartupVenture For Canada - Growing Your Startup
Venture For Canada - Growing Your StartupJean-Luc David
 
Venture For Canada - Growth Marketing
Venture For Canada - Growth MarketingVenture For Canada - Growth Marketing
Venture For Canada - Growth MarketingJean-Luc David
 
Venture For Canada - Growth Hacking
Venture For Canada - Growth HackingVenture For Canada - Growth Hacking
Venture For Canada - Growth HackingJean-Luc David
 
Startup Product Management - Analytics
Startup Product Management - AnalyticsStartup Product Management - Analytics
Startup Product Management - AnalyticsJean-Luc David
 
Startup Product Management - Execution
Startup Product Management - ExecutionStartup Product Management - Execution
Startup Product Management - ExecutionJean-Luc David
 
Startup Product Management - Planning
Startup Product Management - PlanningStartup Product Management - Planning
Startup Product Management - PlanningJean-Luc David
 
Building WatchKit Applications
Building WatchKit ApplicationsBuilding WatchKit Applications
Building WatchKit ApplicationsJean-Luc David
 
Confoo Developing for Wearables
Confoo   Developing for WearablesConfoo   Developing for Wearables
Confoo Developing for WearablesJean-Luc David
 
Innovation & Business Acquisitions of Smart Security
Innovation & Business Acquisitions of Smart SecurityInnovation & Business Acquisitions of Smart Security
Innovation & Business Acquisitions of Smart SecurityJean-Luc David
 
Developing For Wearables - Lessons Learned & Best Practices
Developing For Wearables - Lessons Learned & Best PracticesDeveloping For Wearables - Lessons Learned & Best Practices
Developing For Wearables - Lessons Learned & Best PracticesJean-Luc David
 
Developing for Wearables
Developing for WearablesDeveloping for Wearables
Developing for WearablesJean-Luc David
 
Ryerson DMZ iOS Development Workshop
Ryerson DMZ iOS Development WorkshopRyerson DMZ iOS Development Workshop
Ryerson DMZ iOS Development WorkshopJean-Luc David
 
Pigeon Presentation at We Are Wearables Toronto
Pigeon Presentation at We Are Wearables TorontoPigeon Presentation at We Are Wearables Toronto
Pigeon Presentation at We Are Wearables TorontoJean-Luc David
 

More from Jean-Luc David (20)

Implementing Biometric Authentication & Features in iOS Apps
Implementing Biometric Authentication & Features in iOS AppsImplementing Biometric Authentication & Features in iOS Apps
Implementing Biometric Authentication & Features in iOS Apps
 
Add Machine Learning to your iOS 11 App Using Core ML
Add Machine Learning to your iOS 11 App Using Core MLAdd Machine Learning to your iOS 11 App Using Core ML
Add Machine Learning to your iOS 11 App Using Core ML
 
Mobile Portfolio
Mobile PortfolioMobile Portfolio
Mobile Portfolio
 
Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)
Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)
Mike Krieger - A Brief, Rapid History of Scaling Instagram (with a tiny team)
 
Intro to HTTP and Node.js
Intro to HTTP and Node.jsIntro to HTTP and Node.js
Intro to HTTP and Node.js
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Venture For Canada - Growing Your Startup
Venture For Canada - Growing Your StartupVenture For Canada - Growing Your Startup
Venture For Canada - Growing Your Startup
 
Venture For Canada - Growth Marketing
Venture For Canada - Growth MarketingVenture For Canada - Growth Marketing
Venture For Canada - Growth Marketing
 
Venture For Canada - Growth Hacking
Venture For Canada - Growth HackingVenture For Canada - Growth Hacking
Venture For Canada - Growth Hacking
 
Startup Product Management - Analytics
Startup Product Management - AnalyticsStartup Product Management - Analytics
Startup Product Management - Analytics
 
Startup Product Management - Execution
Startup Product Management - ExecutionStartup Product Management - Execution
Startup Product Management - Execution
 
Startup Product Management - Planning
Startup Product Management - PlanningStartup Product Management - Planning
Startup Product Management - Planning
 
RightCycle
RightCycleRightCycle
RightCycle
 
Building WatchKit Applications
Building WatchKit ApplicationsBuilding WatchKit Applications
Building WatchKit Applications
 
Confoo Developing for Wearables
Confoo   Developing for WearablesConfoo   Developing for Wearables
Confoo Developing for Wearables
 
Innovation & Business Acquisitions of Smart Security
Innovation & Business Acquisitions of Smart SecurityInnovation & Business Acquisitions of Smart Security
Innovation & Business Acquisitions of Smart Security
 
Developing For Wearables - Lessons Learned & Best Practices
Developing For Wearables - Lessons Learned & Best PracticesDeveloping For Wearables - Lessons Learned & Best Practices
Developing For Wearables - Lessons Learned & Best Practices
 
Developing for Wearables
Developing for WearablesDeveloping for Wearables
Developing for Wearables
 
Ryerson DMZ iOS Development Workshop
Ryerson DMZ iOS Development WorkshopRyerson DMZ iOS Development Workshop
Ryerson DMZ iOS Development Workshop
 
Pigeon Presentation at We Are Wearables Toronto
Pigeon Presentation at We Are Wearables TorontoPigeon Presentation at We Are Wearables Toronto
Pigeon Presentation at We Are Wearables Toronto
 

Recently uploaded

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 

Recently uploaded (20)

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 

iOS Coding Best Practices

  • 1.
  • 2. Agenda • Project Structure • Design Patterns & Architecture • Storing Data • Coding Conventions
  • 3. What main design pattern does Apple recommend for structuring your iOS projects?
  • 4. Model-View-Controller Controller Update Coordination Changes Changes Update Model Data View Display
  • 5. Default Project • Notice Classes is a catch-all default ‘’bucket’’ for code
  • 6. MVC Formatted Project • Remove references • Create class folders in Finder • AppDelegate • Controllers • Helpers • Models • Drag into Xcode
  • 7. According to Apple, should the model, view or controller be used to capture events?
  • 8. Roles & Responsibilities • Model • Data/Algorithms/Networking • Most of your custom code lives here • View • Display/Event Capture/Visual Appeal • Don’t try to reinvent UIKit, use it • Controller • Coordination/Delegation/Odd Jobs • Transitions, Startup/Shutdown
  • 9. Is this a good pattern & why? Update
  • 10. Don’t cut out the controller! Avoid bi-directional messaging Reject Delay Validate Update • Network Access • Multiple Choices • Commit
  • 11. Is this a good pattern & why?
  • 12. Loose Coupling • Don’t skip MVC layers when messaging • Use controllers to coordinate messages • Don’t mix MVC roles in one object • Don’t gather too much work in one place • Don’t declare data in your view classes • Maintenance nightmare • You can display data in a view, just don’t store it
  • 13. What are three of the design patterns used to communicate between the model, view & controller?
  • 14. Communication Between Objects Target-Action Notification Delegation Reuse controls without Broadcast changes Control reuse subclassing “Yes” « When tapped, call this method » « Software keyboard “End Editing?” -setTarget:(id)target action:(SEL)action…about to appear! » UIKit (UIScrollView, ect) NSNotificationCenter Will/Did/Should -(void)scrollViewDidZoom:
  • 15. How do you create a custom controller to split the screen in two parts?
  • 16. You Don’t! Use the UISplitViewController • Don’t try to reinvent the wheel • UIKit has a lot of the base controls you need • Really question whether you need a custom control (and if it exists already) • Don’t misuse framework classes • ie Removing views from UIViewControllers • Don’t try to reinvent the way models, views & controllers talk to each other • Use delegates & notifications
  • 17. Is this a good pattern & why? -(void)scrollViewDidScroll:(UIScrollView *)scrollView { if ([scrollView isKindOfClass:[UITableView class]}){ // do something } else { // use UIScrollView logic }
  • 18. Class checks in delegate methods Code unmanagable over time - EverythingControllers Coding horror - iOS version of a GOTO Correct Approach on iPad Parcel out your controllers
  • 19. MANDATORY: ALWAYS write/model out your iOS app design before coding! At first, I was like… But then, it was like… (in your brain) (in the repo)
  • 20. Creating an MVC diagram of your project • Means you thought through the architecture • Means you know how the code will be organized physically & logically • Means you potentially avoided structural bugs • Easier to validate with the team • High quality projects & happy clients
  • 21.
  • 22. What’s the optimal architecture for a Universal Application?
  • 23. Optimal Universal App Architecture iPhone App iPad App UI Framework (Views & Controllers) Non-UI Framework (Networking & Models)
  • 24. Photo Sharing Application Data from the model is in both the inspector and in the toolbar
  • 25. MVC Structure Update Change Change Update
  • 26. What are the six primary ways of storing data on iOS?
  • 27. Six Model Options • Property Lists • Archives • Custom Files • Server/iCloud/APIs • SQLite • CoreData
  • 28. According to Apple, what data should you store in your App Defaults/Preferences?
  • 29. Don’t store data in settings! • Wrong tool for the job • App may get rejected • Settings Panel test • On/Off Advanced Features
  • 30. What should you use for quick storage of strings, numbers, arrays, dictionaries, e ct?
  • 32. What should you use to store partial graphs?
  • 33. CoreData • Modeling Tools • Simple save/restore • Queries • Data Protection • Ordered Relationships • UIManagedDocument • Partial Graphs • Undo • Incremental Stores • ect…
  • 34. What should you use to include data with queue-based concurrency in your app?
  • 36. What should you use if you are dealing with a lot of legacy code or data, or you need to create an NSObject-based graph?
  • 38. When would you want to use a data archive?
  • 39. For easily « serializing » and « deserializing » objects in a data file.
  • 40. What are the two primary features of SQLite?
  • 41. Provides Database functionality for iOS apps Supports Object Relational Mapping
  • 42. Know Your Data Model Options • Property Lists • Archives • Custom Files • Server/iCloud/APIs • SQLite • CoreData
  • 43. Coding Conventions • Brace style for if-else • Parenthesis style • Leading underscores • Code indenting • CapitalizationStyle (ie capitalization_style) Check out the Google iOS Style guide & Apple docs: http://google- styleguide.googlecode.com/svn/trunk/objcguide .xml
  • 45. Key-Value Observing (KVO) • Requires your code to be compliant • Follow style guide • Instrument your own notifications • Automatic Change Notifications for your objects