1 00:00:00,060 --> 00:00:00,810 There are many, 2 00:00:00,810 --> 00:00:04,330 many different ways of connecting to the internet in our world today. 3 00:00:04,330 --> 00:00:09,190 Cable modems, DSL, wi-fi, cellular, satellite, and so on. 4 00:00:10,210 --> 00:00:11,470 Any data we send back and 5 00:00:11,470 --> 00:00:14,250 forth goes through multiple different networks along the way. 6 00:00:15,260 --> 00:00:18,350 At any point during the journey something could happen. 7 00:00:18,350 --> 00:00:24,110 Either on our end as a client, on the server side or with the network itself. 8 00:00:24,110 --> 00:00:27,140 As developers, we need to make sure that our code and apps 9 00:00:27,140 --> 00:00:32,320 can adapt to these changing conditions, insulating our users from problems. 10 00:00:32,320 --> 00:00:35,375 When writing apps that involve any sort of networking code, 11 00:00:35,375 --> 00:00:38,300 we need to keep the following points in mind. 12 00:00:38,300 --> 00:00:42,180 Transfer only as much data as needed to complete the task. 13 00:00:42,180 --> 00:00:46,130 Every network call costs the user time and battery life. 14 00:00:46,130 --> 00:00:49,680 It can also cost them money if they're on a network that charges for data usage. 15 00:00:50,930 --> 00:00:53,140 Avoid network timeouts. 16 00:00:53,140 --> 00:00:55,160 Mobile connections can be slower and 17 00:00:55,160 --> 00:00:58,950 you don't want something to stop loading just because it took too long. 18 00:00:58,950 --> 00:01:02,220 Let users cancel networking operations. 19 00:01:02,220 --> 00:01:06,550 Design interfaces that give users control over a network transaction. 20 00:01:06,550 --> 00:01:09,350 For example, if you're building a podcasting or 21 00:01:09,350 --> 00:01:12,850 video streaming app, the file size could be large. 22 00:01:12,850 --> 00:01:16,410 Allow the user to pause the download and resume it when they choose. 23 00:01:17,750 --> 00:01:20,350 Handle failures gracefully. 24 00:01:20,350 --> 00:01:23,950 There are many reasons why a network might suddenly fail. 25 00:01:23,950 --> 00:01:28,000 When this happens, we need to ensure that we account for these situations and 26 00:01:28,000 --> 00:01:30,920 allow our apps to continue working as much as possible. 27 00:01:32,622 --> 00:01:36,188 Finally, we must always keep the users' security in mind. 28 00:01:36,188 --> 00:01:37,780 You never know how secure your connection is. 29 00:01:37,780 --> 00:01:41,620 So make sure to always take efforts to protect user data in 30 00:01:41,620 --> 00:01:44,992 your application when writing networking code.