1 00:00:01,380 --> 00:00:07,380 Welcome back, my friends, to another lecture today, we're going to limit organize the code, we're 2 00:00:07,380 --> 00:00:09,300 going to clean the code, we're going to write some comments. 3 00:00:09,630 --> 00:00:16,710 We are going to group saw me then listeners, because that's more logical to be like that. 4 00:00:16,890 --> 00:00:26,850 Now, for us to do this, just going to show you, we need to add some comments, what we have done 5 00:00:26,850 --> 00:00:30,010 in like the last lecture. 6 00:00:30,030 --> 00:00:32,220 So because here we are not comments. 7 00:00:32,220 --> 00:00:38,610 It's not I don't want to leave you like that without comments, because with the comments, it's easier 8 00:00:38,880 --> 00:00:40,620 for someone to jump. 9 00:00:40,620 --> 00:00:46,020 Like if you don't work for a week, if you finish it or if somebody else look at you call it will be 10 00:00:46,020 --> 00:00:47,180 a little bit better. 11 00:00:47,190 --> 00:00:52,110 Now, let's write the comments here and I'm going to write the comments here. 12 00:00:52,110 --> 00:01:01,500 I'm going to see each HTML cyesis class names, private OBJ stands for Object right here. 13 00:01:01,500 --> 00:01:08,670 I'm going to put it like this public because this is a public and this is a public method that will 14 00:01:08,670 --> 00:01:09,560 return. 15 00:01:10,200 --> 00:01:18,960 Now, this here return what object with your field data or values 16 00:01:21,660 --> 00:01:26,820 here, it's saying return class name, object, object. 17 00:01:27,000 --> 00:01:28,590 Write this one from top. 18 00:01:29,640 --> 00:01:31,140 How cool is this. 19 00:01:31,440 --> 00:01:31,950 Nice. 20 00:01:32,640 --> 00:01:34,830 Now mean module controller. 21 00:01:34,850 --> 00:01:38,100 We're going to change it to mean module controller. 22 00:01:38,460 --> 00:01:40,850 Same same name just I'm going to be adding capital. 23 00:01:40,860 --> 00:01:44,850 It's looks more organized right at event. 24 00:01:44,850 --> 00:01:54,210 So I'm going to say at the event listener, an event listener and we can just shorten this little bit 25 00:01:54,540 --> 00:02:03,210 witchetty and button call we're going to say at four but we didn't call. 26 00:02:06,620 --> 00:02:16,190 Call now these I will change it to what you said will change it to keep Rense keep RESPA event listener 27 00:02:16,820 --> 00:02:24,950 for a return slash what and Turkey is a Dorji man. 28 00:02:25,190 --> 00:02:27,100 Do this now calling the calories. 29 00:02:27,110 --> 00:02:27,920 I'm not going to do. 30 00:02:27,950 --> 00:02:29,120 You don't need it anymore. 31 00:02:29,720 --> 00:02:33,220 It is now I'm going to see read. 32 00:02:34,040 --> 00:02:40,100 So in actually the calories I'm going to read input data here and here. 33 00:02:40,130 --> 00:02:44,300 I will say add calories. 34 00:02:44,720 --> 00:02:45,260 Function. 35 00:02:45,890 --> 00:02:46,900 Function Fien. 36 00:02:46,910 --> 00:02:52,190 Now as I told you, we need to do something here. 37 00:02:52,490 --> 00:02:57,530 I'm just going to I'm just going to cut this one here. 38 00:02:57,650 --> 00:02:58,790 All of this. 39 00:02:59,090 --> 00:02:59,470 Right. 40 00:02:59,850 --> 00:03:04,880 Just going to cut it and I'm going to create a private function here. 41 00:03:04,910 --> 00:03:12,470 Were making like this war group event. 42 00:03:13,100 --> 00:03:14,590 So I'm going to group the event listeners. 43 00:03:15,890 --> 00:03:19,000 So in future, if we add more, we're going to put it in this group. 44 00:03:19,190 --> 00:03:24,050 So he's going to be a function, no parameters and semicolon there. 45 00:03:24,980 --> 00:03:27,880 And I'm going to paste everything there. 46 00:03:27,890 --> 00:03:33,800 I'm just going to make it a little bit more nicer like that because it wasn't good. 47 00:03:34,040 --> 00:03:37,130 Now we need to call this function from somewhere. 48 00:03:37,250 --> 00:03:41,570 Right, because that is actually not going to work for us. 49 00:03:41,780 --> 00:03:42,950 If it's like this now. 50 00:03:42,950 --> 00:03:46,660 I mean, main controller, this function is a private. 51 00:03:46,850 --> 00:03:54,770 So remember that always everything that is for public, we should return it. 52 00:03:54,800 --> 00:03:55,160 Right. 53 00:03:55,490 --> 00:04:00,470 So I'm going to say return it here. 54 00:04:00,740 --> 00:04:03,620 I'm going to return this function, initialize. 55 00:04:06,180 --> 00:04:14,300 Initialize function and we're going to return this function and it's misspelled initialize. 56 00:04:14,450 --> 00:04:16,750 Now you put it with acid, going to give me a warning. 57 00:04:16,770 --> 00:04:22,590 In Australia we use ask, but you can use Z because that's American English and you will not have that. 58 00:04:22,590 --> 00:04:26,850 Not learning that word correction right now here. 59 00:04:28,680 --> 00:04:31,590 What I want to do is I want to call this one. 60 00:04:31,980 --> 00:04:36,390 I want to return or actually call group event listeners. 61 00:04:36,390 --> 00:04:39,770 I can do that without anything because it's from this function. 62 00:04:39,780 --> 00:04:41,090 Here it is now it's being used. 63 00:04:41,640 --> 00:04:46,950 So console log in. 64 00:04:46,950 --> 00:04:49,020 Let's say Guiseppe. 65 00:04:52,280 --> 00:04:57,790 He's initiated and I'm going to save it now. 66 00:04:59,570 --> 00:05:05,600 We have this function that will call this group the event listeners and let's see what will happen. 67 00:05:05,610 --> 00:05:09,710 It's not going to work, but I just want to show you, all right, it's not going to work. 68 00:05:09,710 --> 00:05:13,340 And this year keeps coming. 69 00:05:14,060 --> 00:05:15,300 Now, it's not going to work. 70 00:05:15,470 --> 00:05:15,730 Why? 71 00:05:15,740 --> 00:05:21,430 It's not going to work because we need this app controller, main main controller. 72 00:05:21,440 --> 00:05:22,770 We need to call it outside. 73 00:05:23,000 --> 00:05:24,700 Remember how we did it before? 74 00:05:24,920 --> 00:05:32,870 So the main app control or actually didn't need to call this function outside, and that is pretty much 75 00:05:32,870 --> 00:05:33,180 it. 76 00:05:33,560 --> 00:05:36,910 Now I want to see. 77 00:05:36,920 --> 00:05:39,010 So if I save it, I haven't save it yet. 78 00:05:39,680 --> 00:05:45,020 So when I say I want here to say the app is initiated, I'm going to save it. 79 00:05:45,410 --> 00:05:45,980 And here it is. 80 00:05:45,980 --> 00:05:48,220 The app is initiated. 81 00:05:48,410 --> 00:05:50,360 Let's check everything if it's working or not. 82 00:05:51,260 --> 00:05:52,570 So I'm just going to go for food. 83 00:05:53,660 --> 00:05:56,770 I'm going to say two to fifty six to fifty enter. 84 00:05:57,080 --> 00:05:58,490 So this is working. 85 00:05:58,500 --> 00:06:00,440 How cool is this exercise. 86 00:06:00,620 --> 00:06:06,710 Burn burn calories like five hundred and fifty. 87 00:06:06,710 --> 00:06:07,610 I'm going to hit. 88 00:06:07,610 --> 00:06:12,860 I'm not going to enter, I'm going to check in here now cuz everything is working so far. 89 00:06:12,860 --> 00:06:15,290 What we have done it is working now. 90 00:06:15,470 --> 00:06:18,050 Let's change this calories module controller. 91 00:06:21,560 --> 00:06:26,690 Module controller and how cool is this UI module controller 92 00:06:29,780 --> 00:06:37,210 controller and what else we can just make it UI like this because it's not professional. 93 00:06:37,220 --> 00:06:41,500 I've done a mistake now where we call this guy here. 94 00:06:41,780 --> 00:06:43,580 Do you remember in the first one. 95 00:06:44,660 --> 00:06:45,170 Oops. 96 00:06:46,220 --> 00:06:47,770 You I controller. 97 00:06:48,170 --> 00:06:54,250 Now this is going to be OK, but let's change this one as well UI. 98 00:06:54,410 --> 00:07:03,950 And here we call it I think we call it again here now I changed the capital I it's better now let's 99 00:07:03,950 --> 00:07:06,060 refresh the AP started. 100 00:07:06,080 --> 00:07:07,800 Let's hope it's not going to crash. 101 00:07:08,530 --> 00:07:08,930 Yeah. 102 00:07:10,460 --> 00:07:15,410 One one working with exercise is going to work. 103 00:07:15,560 --> 00:07:16,740 OK, that's it. 104 00:07:16,970 --> 00:07:18,830 So we've clean up a little bit ago. 105 00:07:19,040 --> 00:07:30,140 We add more meaningful, more meaningful comments, module controller module module pattern and that's 106 00:07:30,140 --> 00:07:30,560 pretty much it. 107 00:07:30,740 --> 00:07:31,370 Next lecture. 108 00:07:31,370 --> 00:07:32,570 We will continue working. 109 00:07:32,870 --> 00:07:35,870 Now, so far we have done a couple of things. 110 00:07:36,110 --> 00:07:44,960 We are able to grab the fields from the form and just show it displayed, return it as an object. 111 00:07:45,350 --> 00:07:46,010 Where was it? 112 00:07:47,720 --> 00:07:48,000 Right. 113 00:07:48,770 --> 00:07:52,060 So if I put it like this, we're going to return it as object. 114 00:07:52,070 --> 00:07:54,320 Also, we group the event listeners. 115 00:07:55,040 --> 00:08:01,130 We initiate the program, same as we did with the starting function for the dice game. 116 00:08:01,160 --> 00:08:02,840 Right now it's better. 117 00:08:03,110 --> 00:08:05,210 So I hope I'm going to see you in the next one. 118 00:08:05,480 --> 00:08:07,280 Enjoy and stay safe.