More Related Content
Similar to エンジニア戦記 〜小さなチーム、大きな未来〜 (20)
エンジニア戦記 〜小さなチーム、大きな未来〜
- 21. Copyright © Classmethod, Inc.
{
"header": {
"status": "success",
"message": "..."
},
"response": {
"topics": [{
"topic_id": 123,
"topic_title": "...",
"topic_content": "...",
"category_id": 456,
"category_name": "..."
}]
}
}
- 23. Copyright © Classmethod, Inc.
{
"header": {
"status": "success",
"message": "..."
},
"response": {
"topics": [{
"topic_id": 123,
"topic_title": "...",
"topic_content": "...",
"category_id": 456,
"category_name": "..."
}]
}
}
- 24. Copyright © Classmethod, Inc.
{
"header": {
"status": "success",
"message": "..."
},
"response": {
"topics": [{
"topic_id": 123,
"topic_title": "...",
"topic_content": "...",
"category_id": 456,
"category_name": "..."
}]
}
}
HTTPステータスコードで
表してくれればいいのに!
- 26. Copyright © Classmethod, Inc.
AFHTTPRequestOperationManager *manager;
[manager GET:@"http://xxx.com/possts"
parameters:nil
success:^(...) {
// 成功時の処理
} failure:^(...) {
// 失敗時の処理
}];
エラーが発生しても
こっち
- 28. Copyright © Classmethod, Inc.
{
"header": {
"status": "success",
"message": "..."
},
"response": {
"topics": [{
"topic_id": 123,
"topic_title": "...",
"topic_content": "...",
"category_id": 456,
"category_name": "..."
}]
}
}
- 29. Copyright © Classmethod, Inc.
{
"header": {
"status": "success",
"message": "..."
},
"response": {
"topics": [{
"topic_id": 123,
"topic_title": "...",
"topic_content": "...",
"category_id": 456,
"category_name": "..."
}]
}
}
いらないのに
- 30. Copyright © Classmethod, Inc.
@interface CLMTopic : NSObject
@property (nonatomic) NSInteger topicIdentifier;
@property (nonatomic) NSString *topicTitle;
@property (nonatomic) NSString *topicContent;
@end
格好悪いなぁ
- 32. Copyright © Classmethod, Inc.
{
"topics": [{
"id": 123,
"title": "...",
"content": "...",
"category_id": 456,
"category_name": "..."
}]
}
- 41. Copyright © Classmethod, Inc.
{
"topics": [{
"id": 123,
"title": "...",
"content": "...",
"category_id": 456,
"category_name": "..."
}]
}
{
"categories": [{
"id": 456,
"name": "..."
}]
}
- 43. Copyright © Classmethod, Inc.
@interface CLMTopic : NSObject
@property (nonatomic) NSInteger identifer;
@property (nonatomic) NSString *title;
@property (nonatomic) NSString *content;
@property (nonatomic) NSInteger categoryIdentifier;
@property (nonatomic) NSInteger categoryName;
@end
@interface CLMCategory : NSObject
@property (nonatomic) NSInteger identifier;
@property (nonatomic) NSInteger name;
@end
しっくりこない・・・
- 45. Copyright © Classmethod, Inc.
{
"topics": [{
"id": 123,
"title": "...",
"content": "...",
"category": {
"id": 456,
"name": "..."
}
}]
}
- 46. Copyright © Classmethod, Inc.
@interface CLMTopic : NSObject
@property (nonatomic) NSInteger identifer;
@property (nonatomic) NSString *title;
@property (nonatomic) NSString *content;
@property (nonatomic) CLMCategory *category;
@end
@interface CLMCategory : NSObject
@property (nonatomic) NSInteger identifier;
@property (nonatomic) NSInteger name;
@end
- 53. Copyright © Classmethod, Inc.
目的 エンドポイント
トピック一覧取得 https://api.xxx.com/v1/topics/
カテゴリー一覧取得 https://api.xxx.com/v1/categories/
おすすめ商品取得 https://api.xxx.com/v1/products/recommend
ユーザー情報取得 https://api.example.com/v1/user/
- 64. Copyright © Classmethod, Inc.
1画面を表示するのに、何度も異なるAPIにアクセ
スしなければならず、非効率ですし、画面を表示す
るまでに時間もかかってしまい、ユーザーを待たせ
てしまいます。これは良いユーザー体験とはいえま
せん。何度もAPIへのアクセスを繰り返すことは、
速度の問題だけでなく、データの一部だけが表示さ
れてしまうといった問題を引き起こす可能性もあり
ます。したがってとにかくホーム画面で表示する情
報を1つに詰め込んだ "ホーム画面専用" APIを作
成し、それに1回アクセスするだけですべての情報
が取得できた方が確実に利便性が高いです。
詳しくは "Web API The Good Parts" をご覧ください。