1 00:00:00,360 --> 00:00:02,640 So did you think long and hard about that? 2 00:00:03,360 --> 00:00:03,840 Well. 3 00:00:06,320 --> 00:00:11,420 You probably came up with something like this, you had three integers, whatever they are, seven, 4 00:00:11,420 --> 00:00:16,130 four, three in my case, you said if I want to multiply them together, I'm just going to go to my 5 00:00:16,130 --> 00:00:22,370 new array and I'm going to get Elements zero way to multiply it by my new array. 6 00:00:23,410 --> 00:00:24,340 Element one. 7 00:00:26,530 --> 00:00:28,660 And multiply it by my new array. 8 00:00:29,550 --> 00:00:36,570 Element to now, I'm sorry if I forgot to mention that the index is of a actually increment upwards 9 00:00:36,570 --> 00:00:37,520 012. 10 00:00:37,800 --> 00:00:42,460 I don't think actually you said that, but I would guess that maybe that was implied. 11 00:00:42,510 --> 00:00:43,030 I don't know. 12 00:00:43,560 --> 00:00:49,230 And of course, if we run that we get seven times four times three, which is apparently 80 for. 13 00:00:50,830 --> 00:00:57,580 Now, before the break, I told you that I want you to think logically about these things, this is 14 00:00:57,580 --> 00:00:58,360 bad code. 15 00:00:59,080 --> 00:01:02,260 Can you guess why it's bad code? 16 00:01:02,260 --> 00:01:05,760 Because an array could be any size. 17 00:01:06,130 --> 00:01:12,640 Usually you'll get something like an array from your database, from your server, and you don't actually 18 00:01:12,640 --> 00:01:13,870 know how big it is. 19 00:01:14,350 --> 00:01:15,400 Or maybe you do. 20 00:01:15,400 --> 00:01:18,990 You know, the 50 items are coming from your server to play music to the end user. 21 00:01:19,780 --> 00:01:23,290 But what if someone changes that to 40 items to reduce load on the server? 22 00:01:23,650 --> 00:01:24,490 What do you do then? 23 00:01:25,360 --> 00:01:28,360 Well, your code is wrong if you have 50 items that you multiply. 24 00:01:28,630 --> 00:01:34,420 And besides that, imagine repeating that, what, 15, 16 times? 25 00:01:35,110 --> 00:01:36,170 You don't want to do that. 26 00:01:36,170 --> 00:01:41,020 Do you say what I was trying to get across to you and I'm not going to give you the solution here? 27 00:01:41,020 --> 00:01:47,770 It'll become it'll become pretty obvious what the solution is as you proceed through this course. 28 00:01:48,250 --> 00:01:52,900 But what I want you to think about is, is this unsustainable? 29 00:01:53,110 --> 00:01:56,380 And if it is, how would I go about fixing this? 30 00:01:56,740 --> 00:02:02,620 I'm going to give you the tools to fix it in a couple of lectures time when we talk about control, 31 00:02:02,620 --> 00:02:07,150 flow effects and statements like that, that will solve these problems for us. 32 00:02:07,750 --> 00:02:14,440 But I just wanted you to think about the dangers that lurk when you just have a throwaway piece of code 33 00:02:14,440 --> 00:02:15,970 moment and say, I'll just do it like this. 34 00:02:16,480 --> 00:02:22,150 And you don't realize that in the future that's going to cause you a world of pain anyway. 35 00:02:22,180 --> 00:02:26,200 That's enough of me bleating on about this onto the next one.