Hypermedia for the iOS developer - Swipe  2012
Upcoming SlideShare
Loading in...5
×
 

Hypermedia for the iOS developer - Swipe 2012

on

  • 1,099 views

What is Hypermedia and how does it help developers create network connected applications.

What is Hypermedia and how does it help developers create network connected applications.

Statistics

Views

Total Views
1,099
Views on SlideShare
1,088
Embed Views
11

Actions

Likes
1
Downloads
0
Comments
0

2 Embeds 11

https://twitter.com 8
http://www.linkedin.com 3

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial LicenseCC Attribution-NonCommercial License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Hypermedia for the iOS developer - Swipe  2012 Hypermedia for the iOS developer - Swipe 2012 Presentation Transcript

  • Network Connectedhypermedia for the iOS developerKevin O’NeillPlayUp Pty Ltd
  • Roadmap• Some background• Introduction to hypermedia• Consuming a hypermedia API• Bit’s and Pieces SWIPE CONFERENCE 2012
  • CTO PlayUp SWIPE CONFERENCE 2012
  • Blood SWIPE CONFERENCE 2012
  • This will be an introduction SWIPE CONFERENCE 2012
  • Opinionated SWIPE CONFERENCE 2012
  • ReST SWIPE CONFERENCE 2012
  • SWIPE CONFERENCE 2012
  • It’s been mutated to the point of being meaningless SWIPE CONFERENCE 2012
  • CRUD = ReST SWIPE CONFERENCE 2012
  • URL Patterns = REST SWIPE CONFERENCE 2012
  • http://example.com/products/<id> SWIPE CONFERENCE 2012
  • Well No SWIPE CONFERENCE 2012
  • Hypermedia API’s SWIPE CONFERENCE 2012
  • The Good SWIPE CONFERENCE 2012
  • Loose Coupling SWIPE CONFERENCE 2012
  • Simplicity / Uniformity SWIPE CONFERENCE 2012
  • Scale better SWIPE CONFERENCE 2012
  • The Bad SWIPE CONFERENCE 2012
  • Not the most succinct form SWIPE CONFERENCE 2012
  • Cache invalidation is hard SWIPE CONFERENCE 2012
  • It takes more thought SWIPE CONFERENCE 2012
  • What is a hypermedia API SWIPE CONFERENCE 2012
  • Use HTTP Properly* SWIPE CONFERENCE 2012
  • Use links to guide clients through processes SWIPE CONFERENCE 2012
  • "REST is software design on the scale of decades: every detail is intended to promote software longevity and independent evolution.Many of the constraints are directly opposed toshort-term efficiency. Unfortunately, people are fairly good at short-term design, and usually awful at long-term design." - Roy Fielding SWIPE CONFERENCE 2012
  • Consuming a Hypermedia API SWIPE CONFERENCE 2012
  • {    "title":  "Raiders  vs  Bulldogs",    "short_title":  "RAI  vs  BUL",    "scheduled_start_time":  "2012-­‐08-­‐24T09:35:00Z",    "start_time":  "2012-­‐08-­‐24T09:35:00Z",    "end_time":  "2012-­‐08-­‐24T12:24:54Z",        "clock":  {        "summary":  "2ND  61:56",        "minutes":  61,        "seconds":  56,        "period":  2    },    ... SWIPE CONFERENCE 2012
  • Content-­‐Type SWIPE CONFERENCE 2012
  • Content-­‐Typeapplication/json SWIPE CONFERENCE 2012
  • Content-­‐Typeapplication/vnd.example.contest.rugby_league+json SWIPE CONFERENCE 2012
  • Strategy SWIPE CONFERENCE 2012
  • @protocol  HTTPResponseHandler  <NSObject>-­‐  (void)handle:(NSHTTPURLResponse  *)response        forRequest:(id  <RequestToken>)request;@end@interface  RegistryHandler  :  NSObject  <HTTPResponseHandler>-­‐  (void)registerHandler:(id<HTTPResponseHandler>)handler                                        for:(id<TypeMatcher>)matcher;@end SWIPE CONFERENCE 2012
  • Errors SWIPE CONFERENCE 2012
  •    "scores":  [        {            "total":  34,            "summary":  "34",            "team":  {                ":href":  "http://example.com/teams/569",                ":type":  "application/vnd.example.sport.team+json"                ":links"  [                    {                        "rel":  "alternate",                        "href":  "http://example.com/teams/569.xml"                        "type":  "application/vnd.example.sport.team+xml"                    },                    {                        "rel":  "alternate",                        "href":  "http://example.com/teams/569.html"                        "type":  "text/html"                    } SWIPE CONFERENCE 2012
  •    "scores":  [        {            "total":  34,            "summary":  "34",            "team":  {                ":href":  "http://example.com/teams/569",                ":type":  "application/vnd.example.sport.team+json"                ":links"  [                    {                        "rel":  "alternate",                        "href":  "http://example.com/teams/569.xml"                        "type":  "application/vnd.example.sport.team+xml"                    },                    {                        "rel":  "alternate",                        "href":  "http://example.com/teams/569.html"                        "type":  "text/html"                    } SWIPE CONFERENCE 2012
  •    "scores":  [        {            "total":  34,            "summary":  "34",            "team":  {                ":href":  "http://example.co/t/d/dogs.json",                ":type":  "application/vnd.example.sport.team+json",                ":links"  [                    {                        "rel":  "alternate",                        "href":  "http://example.com/teams/569.xml"                        "type":  "application/vnd.example.sport.team+xml"                    },                    {                        "rel":  "alternate",                        "href":  "http://example.com/teams/569.html"                        "type":  "text/html"                    } SWIPE CONFERENCE 2012
  • Versioning and Alternates SWIPE CONFERENCE 2012
  •    "scores":  [        {            "total":  34,            "summary":  "34",            "team":  {                ":href":  "http://example.com/teams/569",                ":type":  "application/vnd.example.sport.team+json",                ":links"  [                    {                        "rel":  "alternate",                        "href":  "http://example.com/teams/569.xml"                        "type":  "application/vnd.example.sport.team+xml"                    },                    {                        "rel":  "alternate",                        "href":  "http://example.com/teams/569.html"                        "type":  "text/html"                    } SWIPE CONFERENCE 2012
  • Acceptapplication/vnd.example.sport.team+xml SWIPE CONFERENCE 2012
  • Acceptapplication/vnd.example.sport.team+xml,*/* SWIPE CONFERENCE 2012
  •    "scores":  [        {            "total":  34,            "summary":  "34",            "team":  {                ":href":  "http://example.com/teams/569",                ":type":  "application/vnd.example.sport.team+json",                ":links"  [                    {                        "rel":  "alternate",                        "href":  "http://example.com/teams/569.xml"                        "type":  "application/vnd.example.sport.team+xml"                    },                    {                        "rel":  "alternate",                        "href":  "http://example.com/teams/569.html"                        "type":  "text/html"                    } SWIPE CONFERENCE 2012
  •    NSMutableURLRequest  *request  =        [[NSMutableURLRequest  alloc]  initWithURL:url];    [request            setHTTPMethod:@"GET"];    [request            addValue:@"text/html,*/*"  forHTTPHeaderField:@"Accept"]; SWIPE CONFERENCE 2012
  • Caching SWIPE CONFERENCE 2012
  • NSURLCache  *sharedCache  =      [[NSURLCache  alloc]        initWithMemoryCapacity:kMemoryCacheSize        diskCapacity:kDiskCacheSize          diskPath:cache_path];        [NSURLCache  setSharedURLCache:sharedCache]; SWIPE CONFERENCE 2012
  • ETag"9461cf5ecc0f4df6e880ce76479aba90"Cache-­‐Controlmax-­‐age=15,  publicVaryAccept-­‐Language SWIPE CONFERENCE 2012
  • NSMutableURLRequest  *request  =          ...[request  setValue:etag  forHTTPHeaderField:@"If-­‐None-­‐Match"]; SWIPE CONFERENCE 2012
  • NSMutableURLRequest  *request  =          ...[request  setValue:etag  forHTTPHeaderField:@"If-­‐None-­‐Match"];[request  setCachePolicy:    NSURLRequestReloadIgnoringLocalCacheData]; SWIPE CONFERENCE 2012
  • static  NSUInteger  calc_timeout(NSHTTPURLResponse  *response)  {    NSUInteger  new_timeout  =  k_default_expires;        NSString  *cache_control  =  [[response  allHeaderFields]  valueForKey:@"Cache-­‐Control"];    if  (nil  !=  cache_control)    {        NSRange  maxage_range  =  [cache_control  rangeOfString:@"max-­‐age="];        if  (maxage_range.location  !=  NSNotFound)        {            NSString  *timeout_str  =  [cache_control  substringFromIndex:NSMaxRange(maxage_range)];                        NSRange  comma_range  =  [timeout_str  rangeOfString:@","];            if  (NSNotFound  !=  comma_range.location)            {                timeout_str  =  [timeout_str  substringToIndex:comma_range.location];            }                        new_timeout  =  (NSUInteger)[timeout_str  integerValue];        }    }        return  new_timeout;} SWIPE CONFERENCE 2012
  • Bits and Pieces SWIPE CONFERENCE 2012
  • Test from other countries SWIPE CONFERENCE 2012
  • Charles is your friend SWIPE CONFERENCE 2012
  • HTTPShouldUsePipelining SWIPE CONFERENCE 2012
  • gzip encoding is your friend SWIPE CONFERENCE 2012
  • Proxies Screw You SWIPE CONFERENCE 2012
  • QuestionsKevin O’NeillCTO - PlayUp@kevinoneillkevin@playup.com SWIPE CONFERENCE 2012