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

Jérôme Commandeur

slide-19
SLIDE 19

http://akos.ma/gib5

slide-20
SLIDE 20

1

slide-21
SLIDE 21

Thou shalt manage memory properly

slide-22
SLIDE 22

http://www.flickr.com/photos/blakespot/3030107382/

slide-23
SLIDE 23
  • iPhone 3G: 128 MB RAM
  • iPhone 3GS, iPad: 256 MB RAM
  • iPhone 4: 512 MB RAM
slide-24
SLIDE 24

±70 MB for the OS!

slide-25
SLIDE 25

no swap file

slide-26
SLIDE 26

(no virtual memory)

slide-27
SLIDE 27

http://www.flickr.com/photos/cheek/699407283/

slide-28
SLIDE 28

no garbage collection

slide-29
SLIDE 29
  • bjects have a

“retain count”

slide-30
SLIDE 30

http://cocoadevcentral.com/d/learn_objectivec/

slide-31
SLIDE 31

basic rule:

slide-32
SLIDE 32

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

slide-33
SLIDE 33

beware:

slide-34
SLIDE 34

Objective-C only allows

  • bjects on the heap
slide-35
SLIDE 35

http://linguiniontheceiling.blogspot.com/2008/10/thats-madame-trash-heap-to-you.html

slide-36
SLIDE 36

No automatic objects

  • n the stack (C++)
slide-37
SLIDE 37

http://www.futuregov.net/photologue/photo/2008/aug/30/stack-papers/

slide-38
SLIDE 38

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

slide-39
SLIDE 39

iPhone OS memory warnings

slide-40
SLIDE 40
slide-41
SLIDE 41

http://www.flickr.com/photos/tbuser/2763035540/

slide-42
SLIDE 42

http://akosma.com/2009/01/28/10-iphone-memory-management-tips/

slide-43
SLIDE 43
slide-44
SLIDE 44

2

slide-45
SLIDE 45

Thou shalt remove all compiler warnings

slide-46
SLIDE 46
slide-47
SLIDE 47
slide-48
SLIDE 48

GCC_TREAT_WARNINGS_AS_ERRORS

  • Werror
slide-49
SLIDE 49
slide-50
SLIDE 50

Why Warnings?

slide-51
SLIDE 51
  • 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-52
SLIDE 52

Solutions

slide-53
SLIDE 53

Make your intentions explicit to the compiler

slide-54
SLIDE 54
  • 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-55
SLIDE 55

http://akosma.com/2009/07/16/objective-c-compiler-warnings/

slide-56
SLIDE 56
slide-57
SLIDE 57

3

slide-58
SLIDE 58

Honor the Human Interface Guidelines

slide-59
SLIDE 59

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

slide-60
SLIDE 60
slide-61
SLIDE 61
slide-62
SLIDE 62

Your Objective:

slide-63
SLIDE 63

avoid rejections

slide-64
SLIDE 64
slide-65
SLIDE 65

http://flyosity.com/application-design/iphone-application-design-patterns.php

slide-66
SLIDE 66

http://www.smashingmagazine.com/2009/07/21/iphone-apps- design-mistakes-overblown-visuals/

slide-67
SLIDE 67

http://www.mobileorchard.com/avoiding-iphone-app-rejection-from-apple/

slide-68
SLIDE 68

http://www.apprejected.com/

slide-69
SLIDE 69

http://appreview.tumblr.com/

slide-70
SLIDE 70

http://kosmaczewski.net/2009/08/03/risk-management-in-iphone-projects/

slide-71
SLIDE 71

Your Objective:

slide-72
SLIDE 72

avoid this

slide-73
SLIDE 73

http://www.flickr.com/photos/gruber/2635257578/

slide-74
SLIDE 74

and this

slide-75
SLIDE 75

http://smokingapples.com/iphone/app-store-iphone/the-worst-twitter-client-ever/

slide-76
SLIDE 76

” “

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-77
SLIDE 77
slide-78
SLIDE 78

4

slide-79
SLIDE 79

Thou shalt optimize for performance

slide-80
SLIDE 80
  • Drawing and scrolling
  • Application launch
  • Files and data
  • Power and battery life
slide-81
SLIDE 81

Drawing and scrolling

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

setNeedsDisplayInRect: whenever possible

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

Application Launch

slide-85
SLIDE 85
  • Design apps for quick launch and short

use

  • Load data lazily
  • Load only images needed
slide-86
SLIDE 86

Files and Data

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

Power management

slide-89
SLIDE 89
  • 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-90
SLIDE 90
slide-91
SLIDE 91

5

slide-92
SLIDE 92

Thou shalt test in the device

slide-93
SLIDE 93

http://blogs.tech-recipes.com/itouchmyiphone/2008/03/26/from-iphone-sdk-to- simple-app-in-less-than-452-seconds/

slide-94
SLIDE 94

http://www.flickr.com/photos/edans/1526393678/

slide-95
SLIDE 95
  • Camera
  • Accelerometer
  • GPS
  • Compass
  • Battery
  • Network
  • ... Speed!

http://www.flickr.com/photos/tensafefrogs/728581345/

slide-96
SLIDE 96

http://www.flickr.com/photos/schill/969088410/

slide-97
SLIDE 97

http://www.flickr.com/photos/jaytamboli/3788327603/

slide-98
SLIDE 98

Keep your old 3G(S)

  • r iPod touches!
slide-99
SLIDE 99
slide-100
SLIDE 100

6

slide-101
SLIDE 101

Remember your developer tools

slide-102
SLIDE 102
slide-103
SLIDE 103
slide-104
SLIDE 104

Shark

slide-105
SLIDE 105
slide-106
SLIDE 106
slide-107
SLIDE 107

Instruments

slide-108
SLIDE 108
slide-109
SLIDE 109
slide-110
SLIDE 110
slide-111
SLIDE 111
slide-112
SLIDE 112

7

slide-113
SLIDE 113

Thou shalt use PNG files

slide-114
SLIDE 114

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-115
SLIDE 115

Advantages

slide-116
SLIDE 116

Compression on build

slide-117
SLIDE 117

Low memory footprint

slide-118
SLIDE 118

Supported by all editors

slide-119
SLIDE 119

Quality

slide-120
SLIDE 120

http://en.wikipedia.org/wiki/File:Comparison_of_JPEG_and_PNG.png

slide-121
SLIDE 121

Transparency

slide-122
SLIDE 122

http://en.wikipedia.org/wiki/Portable_Network_Graphics

slide-123
SLIDE 123
  • App icon: 57x57

“Icon.png”

  • Default image: 480x320

“Default.png”

  • Settings icon: 29x29

“Icon-Small.png”

slide-124
SLIDE 124

App Icon

slide-125
SLIDE 125

Design in maximum quality, then reduce

slide-126
SLIDE 126

Do not apply effects

slide-127
SLIDE 127

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

slide-128
SLIDE 128

512x512 72 DPI TIFF file for App Store

slide-129
SLIDE 129
slide-130
SLIDE 130

8

slide-131
SLIDE 131

Thou shalt use static analysis

slide-132
SLIDE 132

http://llvm.org/

slide-133
SLIDE 133

http://clang-analyzer.llvm.org/

slide-134
SLIDE 134
slide-135
SLIDE 135

Source: Apple Documentation

slide-136
SLIDE 136

Source: Apple Documentation

slide-137
SLIDE 137

Source: Apple Documentation

slide-138
SLIDE 138

Source: Apple Documentation

slide-139
SLIDE 139
slide-140
SLIDE 140

9

slide-141
SLIDE 141

Thou shalt have project management hygiene

slide-142
SLIDE 142
  • Project management
  • Human resource management
  • Developer working conditions
  • Prototypes
  • Quality management
  • Code organization
slide-143
SLIDE 143

http://kosmaczewski.net/2009/07/28/code-organization-in-xcode-projects/

slide-144
SLIDE 144

Your objective:

slide-145
SLIDE 145

avoid chaos

slide-146
SLIDE 146

http://www1.standishgroup.com/newsroom/chaos_2009.php

slide-147
SLIDE 147

http://www.geekonomicsbook.com/

slide-148
SLIDE 148
slide-149
SLIDE 149

10

slide-150
SLIDE 150

Thou shalt have fun!

slide-151
SLIDE 151

and

slide-152
SLIDE 152

be creative!

slide-153
SLIDE 153
slide-154
SLIDE 154
slide-155
SLIDE 155
slide-156
SLIDE 156

Recapʼ

slide-157
SLIDE 157
  • 1. Manage memory properly
  • 2. Remove compiler warnings
  • 3. Read the Human Interface Guidelines
  • 4. Optimize for performance
  • 5. Test in the device
slide-158
SLIDE 158
  • 6. Know your developer tools
  • 7. Use PNG files
  • 8. Use static analysis
  • 9. Have project management hygiene
  • 10. Have fun and be creative!
slide-159
SLIDE 159

Thanks!

slide-160
SLIDE 160

Slides available in

slideshare.net/akosma

slide-161
SLIDE 161

Questions?

slide-162
SLIDE 162

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/