Upgrade to Pro — share decks privately, control downloads, hide ads and more …

10 Commandments for iOS Software Development

10 Commandments for iOS Software Development

Presentation shown in the Mobile Developer Summit in Bangalore, India, on November 2011

88dd97cf2dc7f06cc51a01d450f0b1e5?s=128

Adrian Kosmaczewski
PRO

December 27, 2011
Tweet

Transcript

  1. None
  2. Ten Commandments for iOS Software Dev Adrian Kosmaczewski, akosma software

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

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

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

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

  7. akosma software

  8. akosma.com @akosmasoftware facebook.com/akosmasoftware

  9. None
  10. None
  11. None
  12. Some questions

  13. Who’s new to iOS?

  14. Which technologies?

  15. J2EE J2ME .NET Ruby / Rails others?

  16. Which programming languages?

  17. C / C++? Java, C#? Ruby, Python, Lua? JavaScript? Fortran,

    Lisp, COBOL?
  18. None
  19. 10 Commandments

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

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

  22. None
  23. 1

  24. Thou shalt manage memory properly

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

  26. • iPhone and iPhone 3G: 128 MB RAM • iPhone

    3GS and iPad 1: 256 MB RAM • iPhone 4, 4S and iPad 2: 512 MB RAM
  27. > 70 MB for the OS!

  28. no swap file

  29. (no virtual memory)

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

  31. no garbage collection

  32. objects have a “retain count”

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

  34. basic rule:

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

  36. beware:

  37. Objective-C only allows objects on the heap

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

  39. No automatic objects on the stack (C++)

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

  41. // C++ // Memory freed when out of scope std::string

    name(“Adrian”); std::string *name = NULL; name = new std::string(“Adrian”); delete name;
  42. iPhone OS memory warnings

  43. None
  44. http://www.flickr.com/photos/tbuser/2763035540/

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

  46. None
  47. 2

  48. Thou shalt remove all compiler warnings

  49. None
  50. None
  51. GCC_TREAT_WARNINGS_AS_ERRORS -Werror

  52. None
  53. Why Warnings?

  54. • 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.
  55. Solutions

  56. Make your intentions explicit to the compiler

  57. • 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
  58. http://akosma.com/2009/07/16/objective-c-compiler-warnings/

  59. None
  60. 3

  61. Honor the Human Interface Guidelines

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

  63. None
  64. None
  65. Your Objective:

  66. avoid rejections

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

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

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

  71. http://www.apprejected.com/

  72. http://appreview.tumblr.com/

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

  74. Your Objective:

  75. avoid this

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

  77. and this

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

  79. “ 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.
  80. None
  81. 4

  82. Thou shalt optimize for performance

  83. • Drawing and scrolling • Application launch • Files and

    data • Power and battery life
  84. Drawing and scrolling

  85. • UIView subclasses are already optimized • Custom views should

    use setNeedsDisplayInRect: whenever possible • Cache static objects
  86. • Use opaque views • Avoid allocating while scrolling •

    Reuse table cells • Collapse view hierarchies
  87. Application Launch

  88. • Design apps for quick launch and short use •

    Load data lazily • Load only images needed
  89. Files and Data

  90. • Use Core Data for large datasets • Avoid loading

    large files in memory • Use plist files for structured static data
  91. Power management

  92. • 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
  93. None
  94. 5

  95. Thou shalt test in the device

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

  97. • Camera • Accelerometer • GPS • Compass • Battery

    • Network • ... Speed! http://www.flickr.com/photos/tensafefrogs/728581345/
  98. http://www.flickr.com/photos/schill/969088410/

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

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

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

  102. None
  103. 6

  104. Thou shalt unleash the power of Instruments

  105. None
  106. Instruments

  107. None
  108. None
  109. None
  110. None
  111. None
  112. 7

  113. Thou shalt use PNG files

  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
  115. Advantages

  116. Compression on build

  117. Low memory footprint

  118. Supported by all editors

  119. Quality

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

  121. Transparency

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

  123. • App icon: 57x57 “Icon.png” • Default image: 480x320 “Default.png”

    • Settings icon: 29x29 “Icon-Small.png”
  124. None
  125. App Icon

  126. Design in maximum quality, then reduce

  127. Do not apply effects

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

  129. 512x512 72 DPI TIFF file for App Store

  130. None
  131. 8

  132. Thou shalt use static analysis

  133. http://llvm.org/

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

  135. Source: Apple Documentation

  136. Source: Apple Documentation

  137. Source: Apple Documentation

  138. Source: Apple Documentation

  139. None
  140. None
  141. 9

  142. Thou shalt care about accessibility

  143. Setting the accessibility properties in Xcode

  144. None
  145. simple

  146. and there’s no reason not to do it.

  147. call to action!

  148. Add accessibility information to your apps now!

  149. None
  150. 10

  151. Thou shalt have project management hygiene

  152. • Project management • Human resource management • Developer working

    conditions • Prototypes • Quality management • Code organization
  153. http://kosmaczewski.net/2009/07/28/code-organization-in-xcode-projects/

  154. Your objective:

  155. avoid chaos

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

  157. http://www.geekonomicsbook.com/

  158. None
  159. 11

  160. Thou shalt have fun!

  161. and

  162. be creative!

  163. None
  164. None
  165. None
  166. Recap’

  167. 1. Manage memory properly 2. Remove compiler warnings 3. Read

    the Human Interface Guidelines 4. Optimize for performance 5. Test in the device
  168. 6. Know your developer tools 7. Use PNG files 8.

    Use static analysis 9. Care about accessibility 10. Have project management hygiene
  169. 11. Have fun and be creative!

  170. Thanks!

  171. Slides available in slideshare.net/akosma

  172. Questions?

  173. akosma.com @akosmasoftware facebook.com/akosmasoftware

  174. None