Vincent Toms - SDK Design

Vincent Toms - SDK Design

Vincent Toms presenting at the September 2014 Brooklyn Swift Developers Meetup: http://meetup.com/Brooklyn-Swift-Developers/events/201722272/

Video: https://vimeo.com/107419504

Tweet

Transcript

  1. SDK Design, past, present and Future Vincent Toms

  2. who am I? @vincenttoms Native iOS Lead zipcar 19 years

    experience 10 years focused on mobile Objective C, Swift, C, C++, Java, Ruby, Perl (publishing, medical, cloud, carsharing)
  3. SDK what? Software Development Kit, A collection of classes &

    methods that encapsulate complex functionality to allow 3rd party developers an easy way to interact with your system.
  4. Why did we decided to build an SDK Zipcar has

    a fairly complex back end. We wanted to allow 3rd party developers access to our platform. Isolation and testability of a very dynamic platform.
  5. When To Create an SDK? Yes: Complicated interactions with underlying

    hardware or remote system. Would like to share our service with others but can’t give away the code. No: Simple interactions with a small web service, and little to no front end business logic. No need to share libraries internally or externally.
  6. Getting started 1. Identify coding standards and patterns; and stick

    with these. 2. Do all I/O or processing in the background don’t get in way of the UI thread. Be thread safe! 3. Hide complex functionality from the consumer 4. Document, document, and document….
  7. Patterns and Standards Don’t Change - delegation? - block based?

    -@Zipcar we picked a block based approach, for more clear and testable code. -All functions taking blocks should only ever have a single block parameter. -It must be the last parameter.
  8. Do slow work in background We never want to have

    our consumer’s app lock up because of something we are doing. Generally good practice, Cocoa makes this easy. Using blocks be mindful of retain cycles and handle those for the consumer too.
  9. Hide Complex Functionality Our version: -(void)findVehiclesForDriver:(ZIPDriver*)driver withAccountID:(ZIPAccount*)account centerPoint:(CLLocation*)location withStartTime:(NSDate*)startDate andEndTime:(NSDate*)endDate

    withPagingOffset:(int)offset withResponseBlock:(^)(NSArray *vehicles, NSError* error); Theirs: -(void)findVehiclesForCenterPoint:(CLLocation*)location withStartTime:(NSDate*)startDate andEndTime:(NSDate*)endDate withResponseBlock:(^)(NSArray *vehicles, NSError* error);
  10. Document Document and Document -Do all documentation in .h files

    (objectiveC) -Use a documentation generator -Follow the Apple standards so it plays nicely with XCode. -Be clear, concise. -Assume the developer on the other end knows little to nothing about your product.
  11. Results? New developer unfamiliar with backend was able to contribute

    and build a nearly functional app within 1 week of starting. Current understanding is much improved. Near current API changes have not impacted timeline.
  12. Full TDD suite in place nearly 100% coverage. Rewrites tests

    in Swift. Then tackle SDK red->green Should be straight forward adherence to modern ObjectiveC syntax, blocks are always last parameter. Optionals are potentially the biggest problem. Swift?
  13. Information. Questions? vincent@vincenttoms.com http://www.raywenderlich.com/41377/creating- a-static-library-in-ios-tutorial