Bad Cocoa

Bad Cocoa

How-to guide for building the kind of code you will deeply regret later

B5ff8c85fb809e9966436593b40f1063?s=128

Delisa Mason

May 28, 2014
Tweet

Transcript

  1. 1.

    Bad Cocoa How to write the code of deep regret

    quickly and easily - @kattrali
  2. 4.

    Test Private Stuff ensure every test will break during refactors

    maximize the number of mocks, stubs, and performSelector() calls
  3. 6.

    Use Delegates with Callbacks If you don't need asynchronous callbacks

    for synchronous code, you aren't trying hard enough -initWithDelegate:callback:
  4. 7.
  5. 8.

    Categoriception Extend your own classes with several categories instead of

    containing each unit of related functionality in a single class
  6. 10.

    Safely assign many responsibilities using protocols @class MyController : NSObject

    <MyControllerDelegate, Why, God, Please, Stop, WithTheProtocols>
  7. 11.

    Safely assign many responsibilities using protocols BONUS: Make each component

    of a protocol optional, for maximum flexibility and verbosity (and less warnings!!)
  8. 14.

    Always Swing the Heaviest Hammer NSOperation and Core Data all

    day every day - maximize boilerplate code (GCD and NSCoding don't real)
  9. 15.

    Make Code Styles Inconsistent increase the difficulty of using or

    extending your project avoid code style tools like clang- format and Uncrustify
  10. 18.

    When in doubt, add to AppDelegate There is no better

    place to dump bits of code which do not belong anywhere and need access to application state certainly not new classes
  11. 19.

    #define over static variables get the most of your available

    memory for your numbers, strings, and colors