Ten Commandments for iPhone Software Development Adrian - - PowerPoint PPT Presentation

ten commandments
SMART_READER_LITE
LIVE PREVIEW

Ten Commandments for iPhone Software Development Adrian - - PowerPoint PPT Presentation

Ten Commandments for iPhone Software Development Adrian Kosmaczewski akosma software akosma.com github.com/akosma linkedin.com/in/akosma formspring.me/akosma twitter.com/akosma slideshare.com/akosma Some questions Who s new to iOS?


slide-1
SLIDE 1

Ten Commandments

for iPhone Software Development

slide-2
SLIDE 2

Adrian Kosmaczewski

slide-3
SLIDE 3

akosma software

slide-4
SLIDE 4

akosma.com github.com/akosma linkedin.com/in/akosma formspring.me/akosma twitter.com/akosma slideshare.com/akosma

slide-5
SLIDE 5
slide-6
SLIDE 6
slide-7
SLIDE 7

Some questions

slide-8
SLIDE 8

Whoʼs new to iOS?

slide-9
SLIDE 9

Which technologies?

slide-10
SLIDE 10

J2EE J2ME .NET Ruby / Rails

  • thers?
slide-11
SLIDE 11

Which programming languages?

slide-12
SLIDE 12

C / C++? Java, C#? Ruby, Python, Lua? JavaScript? Fortran, Lisp, COBOL?

slide-13
SLIDE 13
slide-14
SLIDE 14

10 Commandments

slide-15
SLIDE 15 http://www.flickr.com/photos/oseillo/345879263/
slide-16
SLIDE 16 http://www.flickr.com/photos/justdrew1985/4348527596/
slide-17
SLIDE 17
slide-18
SLIDE 18

1

slide-19
SLIDE 19

Thou shalt manage memory properly

slide-20
SLIDE 20 http://www.flickr.com/photos/blakespot/3030107382/
slide-21
SLIDE 21
  • iPhone 3G: 128 MB RAM
  • iPhone 3GS, iPad: 256 MB RAM
  • iPhone 4: 512 MB RAM
slide-22
SLIDE 22

±70 MB for the OS!

slide-23
SLIDE 23

no swap file

slide-24
SLIDE 24

(no virtual memory)

slide-25
SLIDE 25 http://www.flickr.com/photos/cheek/699407283/
slide-26
SLIDE 26

no garbage collection

slide-27
SLIDE 27
  • bjects have a

“retain count”

slide-28
SLIDE 28 http://cocoadevcentral.com/d/learn_objectivec/
slide-29
SLIDE 29

basic rule:

slide-30
SLIDE 30

for every [alloc], [retain], [copy] there must be a [release]

slide-31
SLIDE 31

beware:

slide-32
SLIDE 32

Objective-C only allows

  • bjects on the heap
slide-33
SLIDE 33 http://linguiniontheceiling.blogspot.com/2008/10/thats-madame-trash-heap-to-you.html
slide-34
SLIDE 34

No automatic objects

  • n the stack (C++)
slide-35
SLIDE 35 http://www.futuregov.net/photologue/photo/2008/aug/30/stack-papers/
slide-36
SLIDE 36

// C++ // Memory freed when out of scope std::string name(“Adrian”); std::string *name = NULL; name = new std::string(“Adrian”); delete name;

slide-37
SLIDE 37

iPhone OS memory warnings

slide-38
SLIDE 38
slide-39
SLIDE 39 http://www.flickr.com/photos/tbuser/2763035540/
slide-40
SLIDE 40 http://akosma.com/2009/01/28/10-iphone-memory-management-tips/
slide-41
SLIDE 41
slide-42
SLIDE 42

2

slide-43
SLIDE 43

Thou shalt remove all compiler warnings

slide-44
SLIDE 44
slide-45
SLIDE 45
slide-46
SLIDE 46

GCC_TREAT_WARNINGS_AS_ERRORS

  • Werror
slide-47
SLIDE 47
slide-48
SLIDE 48

Why Warnings?

slide-49
SLIDE 49
  • Using deprecated symbols;
  • Calling method names not declared in included headers;
  • Calling methods belonging to implicit protocols;
  • Forgetting to return a result in methods not returning “void”;
  • Forgetting to #import the header file of a class declared as a

forward “@class”;

  • Downcasting values and pointers implicitly.
slide-50
SLIDE 50

Solutions

slide-51
SLIDE 51

Make your intentions explicit to the compiler

slide-52
SLIDE 52
  • Make implicit protocols explicit
  • Create categories for private methods
  • Turn implicit type conversions and casts into

explicit ones

  • Use @class in the @interface, #import on the

@implementation

slide-53
SLIDE 53 http://akosma.com/2009/07/16/objective-c-compiler-warnings/
slide-54
SLIDE 54
slide-55
SLIDE 55

3

slide-56
SLIDE 56

Honor the Human Interface Guidelines

slide-57
SLIDE 57

http://developer.apple.com/iphone/ library/documentation/ userexperience/conceptual/ mobilehig/

slide-58
SLIDE 58
slide-59
SLIDE 59
slide-60
SLIDE 60

Your Objective:

slide-61
SLIDE 61

avoid rejections

slide-62
SLIDE 62
slide-63
SLIDE 63 http://flyosity.com/application-design/iphone-application-design-patterns.php
slide-64
SLIDE 64 http://www.smashingmagazine.com/2009/07/21/iphone-apps-design- mistakes-overblown-visuals/
slide-65
SLIDE 65 http://www.mobileorchard.com/avoiding-iphone-app-rejection-from-apple/
slide-66
SLIDE 66 http://www.apprejected.com/
slide-67
SLIDE 67 http://appreview.tumblr.com/
slide-68
SLIDE 68 http://kosmaczewski.net/2009/08/03/risk-management-in-iphone-projects/
slide-69
SLIDE 69

Your Objective:

slide-70
SLIDE 70

avoid this

slide-71
SLIDE 71 http://www.flickr.com/photos/gruber/2635257578/
slide-72
SLIDE 72

and this

slide-73
SLIDE 73 http://smokingapples.com/iphone/app-store-iphone/the-worst-twitter-client-ever/
slide-74
SLIDE 74

” “

I canʼt find one redeeming quality about this app. Itʼs slow to start [on a 3GS], doesnʼt respond to taps while itʼs trying to load other things, and crashes if you try to change modes a lot. Itʼs limited to only timeline, replies, and messages. It has no other functionality. Oh wait… I forgot its killer feature, you can have custom backgrounds and choose the color of your tweets. That totally makes up for its lack of useful features and sluggish performance. Iʼm not sure why someone would bother building such an inferior app other than that they wanted to find some suckers and score a quick buck. It seems even more insane to me that theyʼd be actively seeking out reviewers to cover this. I was given a promo code for ChillTwit, and even for free I didnʼt want it on my phone. I was sad just from looking at

  • screenshots. Actually seeing it running confirmed all of my fears. If it was a free

app, I might forgive the developer, but the fact that heʼs trying to get $0.99 out of people pisses me off to no end. Go buy Tweetie. If you somehow werenʼt scared away by all my bitching and whinning, you can see ChillTwit on the app store here. But seriously, if you buy this, weʼre not friends anymore.

slide-75
SLIDE 75
slide-76
SLIDE 76

4

slide-77
SLIDE 77

Thou shalt optimize for performance

slide-78
SLIDE 78
  • Drawing and scrolling
  • Application launch
  • Files and data
  • Power and battery life
slide-79
SLIDE 79

Drawing and scrolling

slide-80
SLIDE 80
  • UIView subclasses are already optimized
  • Custom views should use

setNeedsDisplayInRect: whenever possible

  • Cache static objects
slide-81
SLIDE 81
  • Use opaque views
  • Avoid allocating while scrolling
  • Reuse table cells
  • Collapse view hierarchies
slide-82
SLIDE 82

Application Launch

slide-83
SLIDE 83
  • Design apps for quick launch and short use
  • Load data lazily
  • Load only images needed
slide-84
SLIDE 84

Files and Data

slide-85
SLIDE 85
  • Use Core Data for large datasets
  • Avoid loading large files in memory
  • Use plist files for structured static data
slide-86
SLIDE 86

Power management

slide-87
SLIDE 87
  • 3G communications are expensive
  • Wi-Fi slightly cheaper
  • Send small chunks of data at low frequency
  • Prefer “chunky” to “chatty” protocols
  • Better performance ==

longer battery life

slide-88
SLIDE 88
slide-89
SLIDE 89

5

slide-90
SLIDE 90

Thou shalt test in the device

slide-91
SLIDE 91 http://blogs.tech-recipes.com/itouchmyiphone/2008/03/26/from-iphone-sdk-to-simple- app-in-less-than-452-seconds/
slide-92
SLIDE 92 http://www.flickr.com/photos/edans/1526393678/
slide-93
SLIDE 93
  • Camera
  • Accelerometer
  • GPS
  • Compass
  • Battery
  • Network
  • ... Speed!
http://www.flickr.com/photos/tensafefrogs/728581345/
slide-94
SLIDE 94 http://www.flickr.com/photos/schill/969088410/
slide-95
SLIDE 95 http://www.flickr.com/photos/jaytamboli/3788327603/
slide-96
SLIDE 96

Keep your old 3G(S)

  • r iPod touches!
slide-97
SLIDE 97
slide-98
SLIDE 98

6

slide-99
SLIDE 99

Remember your developer tools

slide-100
SLIDE 100
slide-101
SLIDE 101
slide-102
SLIDE 102

Shark

slide-103
SLIDE 103
slide-104
SLIDE 104
slide-105
SLIDE 105

Instruments

slide-106
SLIDE 106
slide-107
SLIDE 107
slide-108
SLIDE 108
slide-109
SLIDE 109
slide-110
SLIDE 110

7

slide-111
SLIDE 111

Thou shalt use PNG files

slide-112
SLIDE 112

Portable Network Graphics (PNG) is a bitmapped image format that employs lossless data compression. PNG was created to improve upon and replace GIF (Graphics Interchange Format) as an image-file format not requiring a patent license. It is pronounced /ˈpɪŋ/ [1] or spelled out as P-N-G. The PNG acronym is optionally recursive, unofficially standing for “PNG's Not GIF”.[2]

http://en.wikipedia.org/wiki/Portable_Network_Graphics
slide-113
SLIDE 113

Advantages

slide-114
SLIDE 114

Compression on build

slide-115
SLIDE 115

Low memory footprint

slide-116
SLIDE 116

Supported by all editors

slide-117
SLIDE 117

Quality

slide-118
SLIDE 118 http://en.wikipedia.org/wiki/File:Comparison_of_JPEG_and_PNG.png
slide-119
SLIDE 119

Transparency

slide-120
SLIDE 120 http://en.wikipedia.org/wiki/Portable_Network_Graphics
slide-121
SLIDE 121
  • App icon: 57x57

“Icon.png”

  • Default image: 480x320

“Default.png”

  • Settings icon: 29x29

“Icon-Small.png”

slide-122
SLIDE 122

App Icon

slide-123
SLIDE 123

Design in maximum quality, then reduce

slide-124
SLIDE 124

Do not apply effects

slide-125
SLIDE 125 http://developer.apple.com/iphone/library/documentation/userexperience/conceptual/mobilehig/
slide-126
SLIDE 126

512x512 72 DPI TIFF file for App Store

slide-127
SLIDE 127
slide-128
SLIDE 128

8

slide-129
SLIDE 129

Thou shalt use static analysis

slide-130
SLIDE 130 http://llvm.org/
slide-131
SLIDE 131 http://clang-analyzer.llvm.org/
slide-132
SLIDE 132
slide-133
SLIDE 133 Source: Apple Documentation
slide-134
SLIDE 134 Source: Apple Documentation
slide-135
SLIDE 135 Source: Apple Documentation
slide-136
SLIDE 136 Source: Apple Documentation
slide-137
SLIDE 137
slide-138
SLIDE 138

9

slide-139
SLIDE 139

Thou shalt care about accessibility

slide-140
SLIDE 140

Setting the “name” property in Interface Builder makes widgets accessible

slide-141
SLIDE 141
slide-142
SLIDE 142

simple

slide-143
SLIDE 143

and thereʼs no reason not to do it.

slide-144
SLIDE 144

call to action!

slide-145
SLIDE 145

Add accessibility information to your apps now!

slide-146
SLIDE 146
slide-147
SLIDE 147

10

slide-148
SLIDE 148

Thou shalt have project management hygiene

slide-149
SLIDE 149
  • Project management
  • Human resource management
  • Developer working conditions
  • Prototypes
  • Quality management
  • Code organization
slide-150
SLIDE 150 http://kosmaczewski.net/2009/07/28/code-organization-in-xcode-projects/
slide-151
SLIDE 151

Your objective:

slide-152
SLIDE 152

avoid chaos

slide-153
SLIDE 153 http://www1.standishgroup.com/newsroom/chaos_2009.php
slide-154
SLIDE 154 http://www.geekonomicsbook.com/
slide-155
SLIDE 155
slide-156
SLIDE 156

11

slide-157
SLIDE 157

Thou shalt have fun!

slide-158
SLIDE 158

and

slide-159
SLIDE 159

be creative!

slide-160
SLIDE 160
slide-161
SLIDE 161
slide-162
SLIDE 162
slide-163
SLIDE 163

Recapʼ

slide-164
SLIDE 164

1. Manage memory properly 2. Remove compiler warnings 3. Read the Human Interface Guidelines 4. Optimize for performance 5. Test in the device

slide-165
SLIDE 165

6. Know your developer tools 7. Use PNG files 8. Use static analysis 9. Care about accessibility

  • 10. Have project management hygiene
slide-166
SLIDE 166
  • 11. Have fun and be creative!
slide-167
SLIDE 167

Thanks!

slide-168
SLIDE 168

Slides available in

slideshare.net/akosma

slide-169
SLIDE 169

Questions?

slide-170
SLIDE 170

Ces slides sont disponibles avec une licence Creative Commons Attribution-No Derivative Works 3.0 Unported License http://creativecommons.org/licenses/by-nd/3.0/