Medium TechTalk — iOS

download Medium TechTalk — iOS

of 152

  • date post

    21-Feb-2017
  • Category

    Software

  • view

    208
  • download

    0

Embed Size (px)

Transcript of Medium TechTalk — iOS

  • How might we create a simple and intuitive mobile consumption experience

    for Medium?

  • How might we create a simple and intuitive mobile consumption

    experience for Medium?

  • How might we create a delightful, simple and intuitive

    mobile consumption experience for Medium?

  • History stack Future stack

    Cover Flow

  • ?

  • 60 FPS Memory Parallax

    UIKit & TextKit

  • { "content": { ... "bodyModel": { "elements": , "sections": }, ... },}

  • { "name": "8419", "type": 1, "text": "...song Walking in LA?", "markups": [ { "type": 3, "start": 300, "end": 315, "href": "https://somewhere.com", "title": "", "rel": "" } ]}

  • { "name": "24cc", "type": 4, "text": "", "markups": [], "layout": 1, "metadata": { "id": "1*WwSQ20QNvf-WovuMLLslEA.jpeg", "originalWidth": 453, "originalHeight": 301 }}

  • { "name": "38d2", "startIndex": 6}

  • { "name": "7b28", "startIndex": 31, "backgroundImage": { "id": "1*DhgXe8j0YqltMNM6-pRy6Q.jpeg", "originalWidth": 1920, "originalHeight": 1200 }, "textLayout": 2, "imageLayout": 2}

  • Cover Flow

    View

  • Cover Flow

    View

    Post View

  • Cover Flow

    View

    Post View

    Section View

  • Cover Flow

    View

    Post View

    Section View

    Section Image View

  • Cover Flow

    View

    Post View

    Section View

    Section Image View

    Section Content View

  • Cover Flow

    View

    Post View

    Section View

    Section Content View

    Element

    Element

    Element

    Section Image View

  • Cover Flow

    View

    Post View

    Section View

    Section Content View

    Element

    Element

    Element

    Section Image View

  • Cover Flow

    View

    Post View

    Section View

    Section Content View

    Element

    Element

    Element

    Section Image View

    Element

  • Cover Flow

    View

    Post View

    Section View

    Section Content View

    Element

    Element

    Element

    Section Image View Elem

    ent

  • Cover Flow

    View

    Post View

    Section View

    Section Content View

    Element

    Element

    Section Image View Elem

    ent

  • Cover Flow

    View

    Post View

    Section View

    Section Content View

    Element

    Element

    Section Image View Elem

    ent

    Section View

    Section Image View

    Section Content View

    Element

  • Cover Flow

    View

    Post View

    Section View

    Section Content View

    Element

    Section Image View Elem

    ent

    Section View

    Section Image View

    Section Content View

    Element

    Element

  • Cover Flow

    View

    Post View

    Section View

    Section Image View

    Section Content View

    Element

    Element

  • Cover Flow

    View

    Post View

    Section View

    Section Image View

    Section Content View

    Element

    Element

  • Cover Flow

    View

    Post View

    Section View

    Section Image View

    Section Content View

    Element

    Element

    Section View

    Section Image View

  • Cover Flow

    View

    Post View

    Section View

    Section Image View

    Section Content View

    Element

    Section View

    Section Image View

    Section Content View

    Element

  • Cover Flow

    View

    Post View

    Section View

    Section Image View

    Section Content View

    Element

  • Cover Flow

    View

    Post View

    Section View

    Section Image View

    Section Content View

    Element

    Element

  • Cover Flow

    View

    Post View

    Section View

    Section Image View

    Section Content View

    Element

    Element

  • Cover Flow

    View

    Post View

    Section View

    Section Image View

    Section Content View

    Element

    Element

  • Thank You! Questions?

    !

    Grant Oladipo grant@medium.com

    @kocodude

    mailto:grant@medium.comhttps://twitter.com/kocodude

  • Shapes & things

    Building the data layer of the Medium iOS app !

    !

    Elizabeth Ford @infraredflower

  • Title Body text Other stuff

  • User !

    Collection

  • Users name Bio List of stories

  • How will we deal with the possibility of API changes?

    especially since the app will be long-lived How do we minimize the number of requests

    from the iOS app to the server? How can we avoid making separate API routes

    for the iOS app (and every client thereafter)?

    Questions

  • Clearly bad ideas

    Make multiple requests to display one Post, User, or Collection

    Make new iOS routes with exactly what we need

    Only save full objects

  • Clearly bad ideas

    Save partial objects and if we need a full object, just check to see if all the fields are set in the object in the cache

    Is the field supposed to be or was it never set?

  • Speaking of which

    How should we deal with merging two objects?

  • Merging a full post and a partial post

    Example

  • Shapes!

  • Shapes!

  • Saving objects

  • Merging objects

  • Complexity hidden by data layer

    merges objects determines when to make

    network requests

  • Complexity hidden by data layer

  • What about dealing with a changing API?

    explicit definitions for the resources returned by API endpoints

    tests based on these definitions

  • Possible areas for improvement

    one service to return any shape (instead of a separate data service for each type of object)

    autogenerate shape definitions from protocol buffers (on both server and client)

  • easy to add features on the iOS side easy to make changes on the server

    side without breaking the iOS client minimize # of server requests

    Shapes!

  • Thank You! Questions?

    !

    Elizabeth Ford eford@medium.com

    @infraredflower

  • Meet the Singletons

    Jimmy ONeill Engineer, Medium

    @jmyonl

  • + (id)sharedResource { static id _instance; static dispatch_once_t onceToken; ! dispatch_once(&onceToken, ^{ _instance = [[Resource alloc] init]; }); ! return _instance; }

  • A singleton restricts the instantiation of a class to one object.

    They are often lazily instantiated.

    They can be accessed globally by any module of a program.

  • UIApplication NSFileManager NSNotificationCenter NSURLSession

  • Since singletons are so commonplace in CocoaTouch, many developers overuse them.

  • A lot of this: Singletons are bad!!

    !

    Not a lot of this: Singletons can be bad because ____. Heres a real example!

  • !

    !

    !

    Im going to focus on this: Singletons can be bad because ____. Heres a real example!

  • - (AuthCredential *)mediumAuthCredential; !- (void)saveMediumAuthCredential:(AuthCredential *)credential;

    AuthCredentialDataService

    Keychain

    AuthCredentialDataService

  • - (void)fetch:(NetRequest *)request completion:(void (^)(NetResponse *, NSError *))completion;

    Net

    AuthCredentialDataService

    NetNet

  • - (void)fetchPostById:(NSString *)postId completion:(void(^)(Post *post, NSError *error))completion;

    PostService

    Net

    AuthCredentialDataService

    PostService

  • - (void)fetchPostViewDataWithPostId:(NSString *)postId completion:(void(^)(Post *post, PostViewModel *postViewModel, PostUserData *postUserData, NSError *error))callback;

    PostViewService

    PostService

    Net

    AuthCredentialDataService

    PostViewService

  • PostViewController

    PostViewService

    PostService

    Net

    AuthCredentialDataService

    PostViewController

  • PostViewController

    PostViewService

    PostService

    Net

    AuthCredentialDataService

    PostViewController

  • PostViewController

    PostViewService

    PostService

    Net

    AuthCredentialDataService

    Data dependenceTime dependence

    AuthCredentialDataService

    PostViewController

  • Time dependence isnt an issue until the underlying

    data starts changing.

    PostViewController

    PostViewService

    PostService

    Net

    AuthCredentialDataServiceAuthCredentialDataService

    PostViewController

  • If your app supports sign out, the underlying authentication

    data is changing.

    PostViewController

    PostViewService

    PostService

    Net

    AuthCredentialDataServiceAuthCredentialDataService

    PostViewController

  • What problems does time dependence cause?

    - Functional impurity - Leaky abstraction - Background task failures - Difficult to test

    PostViewController

    PostViewService

    PostService

    Net

    AuthCredentialDataServiceAuthCredentialDataService

    PostViewController

  • Example.

  • PostViewController

  • PostViewController

  • LoginViewC