Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Ten Commandments for iOS Software Dev Adrian Kosmaczewski, akosma software

Slide 3

Slide 3 text

http://www.flickr.com/photos/gi/164281467/

Slide 4

Slide 4 text

http://www.flickr.com/photos/jm3/379494322/

Slide 5

Slide 5 text

http://www.flickr.com/photos/21025851@N00/2168398185/

Slide 6

Slide 6 text

http://www.flickr.com/photos/emiliagarassino/2146648332/

Slide 7

Slide 7 text

akosma software

Slide 8

Slide 8 text

akosma.com @akosmasoftware facebook.com/akosmasoftware

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Some questions

Slide 13

Slide 13 text

Who’s new to iOS?

Slide 14

Slide 14 text

Which technologies?

Slide 15

Slide 15 text

J2EE J2ME .NET Ruby / Rails others?

Slide 16

Slide 16 text

Which programming languages?

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

10 Commandments

Slide 20

Slide 20 text

http://www.flickr.com/photos/oseillo/345879263/

Slide 21

Slide 21 text

http://www.flickr.com/photos/justdrew1985/4348527596/

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

1

Slide 24

Slide 24 text

Thou shalt manage memory properly

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

• iPhone and iPhone 3G: 128 MB RAM • iPhone 3GS and iPad 1: 256 MB RAM • iPhone 4, 4S and iPad 2: 512 MB RAM

Slide 27

Slide 27 text

> 70 MB for the OS!

Slide 28

Slide 28 text

no swap file

Slide 29

Slide 29 text

(no virtual memory)

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

no garbage collection

Slide 32

Slide 32 text

objects have a “retain count”

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

basic rule:

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

beware:

Slide 37

Slide 37 text

Objective-C only allows objects on the heap

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

No automatic objects on the stack (C++)

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

iPhone OS memory warnings

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

2

Slide 48

Slide 48 text

Thou shalt remove all compiler warnings

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

GCC_TREAT_WARNINGS_AS_ERRORS -Werror

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

Why Warnings?

Slide 54

Slide 54 text

• 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 55

Slide 55 text

Solutions

Slide 56

Slide 56 text

Make your intentions explicit to the compiler

Slide 57

Slide 57 text

• 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 58

Slide 58 text

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

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

3

Slide 61

Slide 61 text

Honor the Human Interface Guidelines

Slide 62

Slide 62 text

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

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

Your Objective:

Slide 66

Slide 66 text

avoid rejections

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

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

Slide 69

Slide 69 text

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

Slide 70

Slide 70 text

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

Slide 71

Slide 71 text

http://www.apprejected.com/

Slide 72

Slide 72 text

http://appreview.tumblr.com/

Slide 73

Slide 73 text

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

Slide 74

Slide 74 text

Your Objective:

Slide 75

Slide 75 text

avoid this

Slide 76

Slide 76 text

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

Slide 77

Slide 77 text

and this

Slide 78

Slide 78 text

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

Slide 79

Slide 79 text

“ 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 80

Slide 80 text

No content

Slide 81

Slide 81 text

4

Slide 82

Slide 82 text

Thou shalt optimize for performance

Slide 83

Slide 83 text

• Drawing and scrolling • Application launch • Files and data • Power and battery life

Slide 84

Slide 84 text

Drawing and scrolling

Slide 85

Slide 85 text

• UIView subclasses are already optimized • Custom views should use setNeedsDisplayInRect: whenever possible • Cache static objects

Slide 86

Slide 86 text

• Use opaque views • Avoid allocating while scrolling • Reuse table cells • Collapse view hierarchies

Slide 87

Slide 87 text

Application Launch

Slide 88

Slide 88 text

• Design apps for quick launch and short use • Load data lazily • Load only images needed

Slide 89

Slide 89 text

Files and Data

Slide 90

Slide 90 text

• Use Core Data for large datasets • Avoid loading large files in memory • Use plist files for structured static data

Slide 91

Slide 91 text

Power management

Slide 92

Slide 92 text

• 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 93

Slide 93 text

No content

Slide 94

Slide 94 text

5

Slide 95

Slide 95 text

Thou shalt test in the device

Slide 96

Slide 96 text

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

Slide 97

Slide 97 text

• Camera • Accelerometer • GPS • Compass • Battery • Network • ... Speed! http://www.flickr.com/photos/tensafefrogs/728581345/

Slide 98

Slide 98 text

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

Slide 99

Slide 99 text

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

Slide 100

Slide 100 text

Keep your old iPhone 3G(S), 4, or iPod touches!

Slide 101

Slide 101 text

http://en.wikipedia.org/wiki/File:3rareiphoneviews.jpg

Slide 102

Slide 102 text

No content

Slide 103

Slide 103 text

6

Slide 104

Slide 104 text

Thou shalt unleash the power of Instruments

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

Instruments

Slide 107

Slide 107 text

No content

Slide 108

Slide 108 text

No content

Slide 109

Slide 109 text

No content

Slide 110

Slide 110 text

No content

Slide 111

Slide 111 text

No content

Slide 112

Slide 112 text

7

Slide 113

Slide 113 text

Thou shalt use PNG files

Slide 114

Slide 114 text

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 text

Advantages

Slide 116

Slide 116 text

Compression on build

Slide 117

Slide 117 text

Low memory footprint

Slide 118

Slide 118 text

Supported by all editors

Slide 119

Slide 119 text

Quality

Slide 120

Slide 120 text

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

Slide 121

Slide 121 text

Transparency

Slide 122

Slide 122 text

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

Slide 123

Slide 123 text

• App icon: 57x57 “Icon.png” • Default image: 480x320 “Default.png” • Settings icon: 29x29 “Icon-Small.png”

Slide 124

Slide 124 text

No content

Slide 125

Slide 125 text

App Icon

Slide 126

Slide 126 text

Design in maximum quality, then reduce

Slide 127

Slide 127 text

Do not apply effects

Slide 128

Slide 128 text

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

Slide 129

Slide 129 text

512x512 72 DPI TIFF file for App Store

Slide 130

Slide 130 text

No content

Slide 131

Slide 131 text

8

Slide 132

Slide 132 text

Thou shalt use static analysis

Slide 133

Slide 133 text

http://llvm.org/

Slide 134

Slide 134 text

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

Slide 135

Slide 135 text

Source: Apple Documentation

Slide 136

Slide 136 text

Source: Apple Documentation

Slide 137

Slide 137 text

Source: Apple Documentation

Slide 138

Slide 138 text

Source: Apple Documentation

Slide 139

Slide 139 text

No content

Slide 140

Slide 140 text

No content

Slide 141

Slide 141 text

9

Slide 142

Slide 142 text

Thou shalt care about accessibility

Slide 143

Slide 143 text

Setting the accessibility properties in Xcode

Slide 144

Slide 144 text

No content

Slide 145

Slide 145 text

simple

Slide 146

Slide 146 text

and there’s no reason not to do it.

Slide 147

Slide 147 text

call to action!

Slide 148

Slide 148 text

Add accessibility information to your apps now!

Slide 149

Slide 149 text

No content

Slide 150

Slide 150 text

10

Slide 151

Slide 151 text

Thou shalt have project management hygiene

Slide 152

Slide 152 text

• Project management • Human resource management • Developer working conditions • Prototypes • Quality management • Code organization

Slide 153

Slide 153 text

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

Slide 154

Slide 154 text

Your objective:

Slide 155

Slide 155 text

avoid chaos

Slide 156

Slide 156 text

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

Slide 157

Slide 157 text

http://www.geekonomicsbook.com/

Slide 158

Slide 158 text

No content

Slide 159

Slide 159 text

11

Slide 160

Slide 160 text

Thou shalt have fun!

Slide 161

Slide 161 text

and

Slide 162

Slide 162 text

be creative!

Slide 163

Slide 163 text

No content

Slide 164

Slide 164 text

No content

Slide 165

Slide 165 text

No content

Slide 166

Slide 166 text

Recap’

Slide 167

Slide 167 text

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

Slide 168

Slide 168 text

6. Know your developer tools 7. Use PNG files 8. Use static analysis 9. Care about accessibility 10. Have project management hygiene

Slide 169

Slide 169 text

11. Have fun and be creative!

Slide 170

Slide 170 text

Thanks!

Slide 171

Slide 171 text

Slides available in slideshare.net/akosma

Slide 172

Slide 172 text

Questions?

Slide 173

Slide 173 text

akosma.com @akosmasoftware facebook.com/akosmasoftware

Slide 174

Slide 174 text

No content