46
Op timis tic Appr oach How to show r esults ins tead spinner s without breakin g your Applica tion by P aul T aykalo, Stanfy Paul T aykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 1

Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

  • Upload
    fwdays

  • View
    231

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Optimistic ApproachHow to show results instead spinnerswithout breaking your Application

by Paul Taykalo, StanfyPaul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 1

Page 2: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Optimistic ApproachWhat is it about?

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 2

Page 3: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Optimistic Approach4 Speeding up application

4 "Speeding" up application

4 Making user happier

4 It's all about user-friendliness

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 3

Page 4: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

How mobile application works

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 4

Page 5: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

How mobile application works4 Handle user action

4 Send request to the server

4 Get response from the server

4 Update UI

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 5

Page 6: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 6

Page 7: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

User need to wait

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 7

Page 8: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

User need to waitBut user don't like to wait

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 8

Page 9: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

User need to waitBut user don't like to waitUser don't have time to wait

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 9

Page 10: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Loading next slide

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 10

Page 11: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Solutions?Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 11

Page 12: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Solutions - Making app faster4 Decrease sizes

4 Compression

4 Opened connection to the server

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 12

Page 13: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Solutions - One step ahead4 Caching

4 Preload pages

4 Load content in the backround

4 Be prepared

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 13

Page 14: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Solutions - Entertain user

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 14

Page 15: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Solutions - Entertain the user4 Animations

4 Push/Pop

4 Spinner

4 Progress

4 Skeleton

4 Partial infoPaul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 15

Page 16: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Solutions - Predict the result4 Precalculate result

4 Show it to user

4 ????

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 16

Page 17: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Solutions - Predict the result4 Precalculate result

4 Show it to user

4 Pray :)

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 17

Page 18: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Types of userinteractions

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 18

Page 19: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Actionsand

ExpectationsPaul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 19

Page 20: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Actions and Expectations4 If I press like I expect that

4 If I edit post I expect that

4 If I follow this guy I expect that

4 If I open a post I expect that

4 If I ask for a radom number I expect that

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 20

Page 21: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Predictabevs

*elbatciderpnU_Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 21

Page 22: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

PredictablePaul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 22

Page 23: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

PredictableIf I can predict the result, why should I wait for confirmation?

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 23

Page 24: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Optimistic models

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 24

Page 25: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Non optimistic model

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 25

Page 26: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 26

Page 27: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 27

Page 28: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Following a person[self.requestManager follow:original result:^(Person *res, NSError *err) { if (err) { // Handling error resultBlock(nik, err); } else { // Updating to the new value resultBlock(res, nil); }}];

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 28

Page 29: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Following a person// Saving original for later usagePerson *original = self.person;

// Create fake resultPerson *fake = [self.person copy];fake.followingStatus = @"Following";

// Updating current objectself.person = fake;resultBlock(fake, nil);

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 29

Page 30: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Following a personif (error) { // rollback weakSelf.person = original; resultBlock(original, error);} else { // Updating to the new value weakSelf.person = updatedPerson; resultBlock(updatedPerson, nil);}

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 30

Page 31: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Following a person// Following a person

- (void)follow:(void (^)(Person *person, NSError *error))resultBlock { __weak __typeof(self) weakSelf = self;

// Saving original for later usage Person *original = self.person;

// Create fake result Person *fake = [self.person copy]; fake.followingStatus = @"Following";

// Updating current object self.person = fake; resultBlock(fake, nil);

// Calling request manager [self.requestManager followPerson:original result:^(Person *updatedPerson, NSError *error) { if (error) { // rollback weakSelf.person = original; resultBlock(original, error); } else { // Updating to the new value weakSelf.person = updatedPerson; resultBlock(updatedPerson, nil); } }];}

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 31

Page 32: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

What about non-breaking?

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 32

Page 33: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Correct View Layer

MVVM*Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 33

Page 34: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Correct View Layer

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 34

Page 35: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Correct View Layer

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 35

Page 36: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Hiperactive User?

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 36

Page 37: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Hiperactive User?like unlike like unlike like unlike like unlikelike unlike like unlike like unlike like unlikelike unlike like unlike like unlike like unlikelike unlike like unlike like unlike like unlikePaul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 37

Page 38: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

State based on multiple updates

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 38

Page 39: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

State based on multiple updatesTake a look at Parse SDKPFObjectEstimatedData.h

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 39

Page 40: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Demo?Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 40

Page 41: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Recap

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 41

Page 42: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Recap4 It's pretty easy to trick user

4 Show user what he expect

4 Fight for your users, they deserve it

4 Now you can write even cooler apps :)

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 42

Page 43: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Last slide :)

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 43

Page 44: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Optimistic ApproachHow to show results instead spinnerswithout breaking your Application

by Paul Taykalo, StanfyPaul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 44

Page 45: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Links4 http://www.reactnative.com/

4 https://speakerdeck.com/frantic/react-native-under-the-hood

4 https://medium.com/stanfy-engineering-practices/do-not-let-your-user-see-spinners-35b824c3ce2f

4 ComponentKit

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 45

Page 46: Павел Тайкало: "Optimistic Approach : How to show results instead spinners without breaking your Application"

Paul Taykalo, Optimistic Approach : How to show results instead spinners without breaking your Application, Stanfy, 2015 46