ten commandments
play

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?


  1. Ten Commandments for iPhone Software Development

  2. Adrian Kosmaczewski

  3. akosma software

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

  5. Some questions

  6. Who ʼ s new to iOS?

  7. Which technologies?

  8. J2EE J2ME .NET Ruby / Rails others?

  9. Which programming languages?

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

  11. 10 Commandments

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

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

  14. Jérôme Commandeur

  15. http://akos.ma/gib5

  16. 1

  17. Thou shalt manage memory properly

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

  19. • iPhone 3G: 128 MB RAM • iPhone 3GS, iPad: 256 MB RAM • iPhone 4: 512 MB RAM

  20. ±70 MB for the OS!

  21. no swap file

  22. (no virtual memory)

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

  24. no garbage collection

  25. objects have a “retain count”

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

  27. basic rule:

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

  29. beware:

  30. Objective-C only allows objects on the heap

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

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

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

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

  35. iPhone OS memory warnings

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

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

  38. 2

  39. Thou shalt remove all compiler warnings

  40. GCC_TREAT_WARNINGS_AS_ERRORS -Werror

  41. Why Warnings?

  42. • 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.

  43. Solutions

  44. Make your intentions explicit to the compiler

  45. • 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

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

  47. 3

  48. Honor the Human Interface Guidelines

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

  50. Your Objective:

  51. avoid rejections

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

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

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

  55. http://www.apprejected.com/

  56. http://appreview.tumblr.com/

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

  58. Your Objective:

  59. avoid this

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

  61. and this

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

  63. “ 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 .

  64. 4

  65. Thou shalt optimize for performance

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

  67. Drawing and scrolling

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

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

  70. Application Launch

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

  72. Files and Data

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

  74. Power management

  75. • 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

  76. 5

  77. Thou shalt test in the device

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

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

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

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

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

  83. Keep your old 3G(S) or iPod touches!

  84. 6

Recommend


More recommend