1 00:00:01,620 --> 00:00:08,160 Welcome back, my friends, to another lecture today, we are going to start start talking about the 2 00:00:08,160 --> 00:00:15,600 most important part and that is what we are going to choose for our architecture now, for the dice 3 00:00:15,600 --> 00:00:17,370 game, for the to do list. 4 00:00:17,380 --> 00:00:23,370 We didn't have any architecture, but now we're going to use some architecture. 5 00:00:23,370 --> 00:00:28,980 These maybe it's overkill for this project, but you can learn it and you can apply it for the future 6 00:00:28,980 --> 00:00:32,690 project or for the bigger project in your in future. 7 00:00:32,700 --> 00:00:40,200 For example, if you work somewhere and you see this, you will know what is going on right now for 8 00:00:40,200 --> 00:00:44,240 I'm not going to give you a PowerPoint presentation for that reason. 9 00:00:44,270 --> 00:00:49,220 I have on my blog, I have on my field recording that I have this JavaScript calories up. 10 00:00:49,240 --> 00:00:56,280 So if you open this, you can read pretty much what this app is doing, how this app is set up. 11 00:00:56,430 --> 00:00:58,230 So I'm just going to read a couple of things now. 12 00:01:00,090 --> 00:01:04,270 This is everything that we explained last time, how we add things, how this app works. 13 00:01:04,530 --> 00:01:10,740 Now, this is the part that you can read it to see how the percentage is and how we do this things right. 14 00:01:11,130 --> 00:01:12,220 How they calculate it. 15 00:01:12,570 --> 00:01:14,890 So these have given some example. 16 00:01:14,910 --> 00:01:19,310 Now, our first part is to do list, but I'm going to be back here. 17 00:01:19,350 --> 00:01:21,470 I just wanted to talk about the architecture. 18 00:01:21,750 --> 00:01:25,530 So for our application, we will use modules. 19 00:01:25,860 --> 00:01:31,890 Now, our application application will have a modular architecture and that is the most important for 20 00:01:31,890 --> 00:01:34,110 any programming language, not just JavaScript. 21 00:01:34,590 --> 00:01:36,500 When we have modules, it's easy. 22 00:01:36,630 --> 00:01:38,040 The code is cleaner. 23 00:01:38,280 --> 00:01:43,390 We can change some code in some place and that will not affect the other. 24 00:01:43,410 --> 00:01:45,300 It will not bubble it right. 25 00:01:45,300 --> 00:01:47,550 It's it's not going to affect the other modules. 26 00:01:47,550 --> 00:01:50,460 So that is why we use this modular architecture. 27 00:01:50,640 --> 00:01:57,120 And the definition is referring to the design of any composed or separate content component that can 28 00:01:57,120 --> 00:01:58,320 be connected together. 29 00:01:58,500 --> 00:01:58,840 Right. 30 00:01:58,870 --> 00:02:00,930 We can connect these modules together. 31 00:02:01,200 --> 00:02:07,890 The essence and usability of the modular architecture are that you can replace or add any new component 32 00:02:08,100 --> 00:02:10,410 module without affecting the rest of the system. 33 00:02:11,580 --> 00:02:16,500 Now, one more thing is that the modules enabled data encapsulation. 34 00:02:16,500 --> 00:02:24,060 So before reading this poor data is encapsulation is simply hiding your function, simply hiding your 35 00:02:24,060 --> 00:02:32,130 parameters, simply hiding from anyone else to see it, use it to manipulate, to add some code, to 36 00:02:32,130 --> 00:02:33,110 do some damage. 37 00:02:33,120 --> 00:02:33,470 Right. 38 00:02:33,660 --> 00:02:35,730 That is data encapsulation. 39 00:02:35,880 --> 00:02:38,340 And that is a very basic concept. 40 00:02:38,850 --> 00:02:42,030 But maybe the name is going to give you confusion. 41 00:02:42,030 --> 00:02:42,250 Right. 42 00:02:42,540 --> 00:02:51,990 But it pretty much it is what I'm trying to see, protect our application and put the things private. 43 00:02:51,990 --> 00:02:55,470 No one will be able to access them because they're private. 44 00:02:55,680 --> 00:02:55,940 Right. 45 00:02:56,070 --> 00:02:59,040 Public is something that we just giving access to anyone. 46 00:02:59,280 --> 00:03:00,960 So their public records. 47 00:03:00,960 --> 00:03:01,270 Right. 48 00:03:01,290 --> 00:03:05,910 In every country, you can find some things publicly available to the people. 49 00:03:05,910 --> 00:03:12,510 But some of the things you can't, for example, where he lives, what is his phone number, his email 50 00:03:12,510 --> 00:03:14,370 address where, I don't know, his bank account. 51 00:03:14,370 --> 00:03:15,350 That is private. 52 00:03:15,390 --> 00:03:15,690 Right. 53 00:03:16,000 --> 00:03:17,910 So that is pretty much a encapsulation. 54 00:03:17,910 --> 00:03:19,520 He's also known as data hidings. 55 00:03:19,550 --> 00:03:23,040 It's a machine that he's used to keep the data hidden from the user. 56 00:03:23,050 --> 00:03:23,420 Right. 57 00:03:24,540 --> 00:03:29,640 Therefore, the user can only perform a restricted set of operation on the hidden modules and functions. 58 00:03:29,850 --> 00:03:30,410 Right. 59 00:03:30,480 --> 00:03:31,310 That's pretty much it. 60 00:03:31,590 --> 00:03:34,080 Now we're going to have three modules in our architecture. 61 00:03:34,500 --> 00:03:36,720 The first will be graphical user interface. 62 00:03:37,590 --> 00:03:43,020 And this is pretty much the graphical user interface with this is the graphical everything that we see, 63 00:03:43,200 --> 00:03:49,140 everything that we interact with, the user that interacts with the application that is considered as 64 00:03:49,140 --> 00:03:50,710 a graphical user interface. 65 00:03:50,970 --> 00:03:54,440 Now we have the main app module and the calories module. 66 00:03:54,780 --> 00:04:04,650 So this calories module will be for anything related with computing the calories adding, burning the 67 00:04:04,650 --> 00:04:07,290 calories percentage here in this module. 68 00:04:07,290 --> 00:04:12,660 We will do that mean that module will be connection between these two modules. 69 00:04:12,660 --> 00:04:13,010 Right. 70 00:04:14,250 --> 00:04:23,280 We will not be able to access the graphical user interface, but we this module can access public functions. 71 00:04:23,400 --> 00:04:28,800 So we are going to write private functions here in public, private and public, private and public. 72 00:04:28,800 --> 00:04:32,760 So these mean module will be like a bridge. 73 00:04:32,940 --> 00:04:35,040 It will connect these two parts. 74 00:04:35,520 --> 00:04:40,350 So I hope I am very clear about this. 75 00:04:40,440 --> 00:04:45,780 So we're going to have three modules, calories module that will deal with the calories graphical user 76 00:04:45,780 --> 00:04:48,900 application module that will deal with everything that we see here. 77 00:04:49,110 --> 00:04:49,550 Right. 78 00:04:49,770 --> 00:04:55,080 So the percentage, the amount of here, here where we go there. 79 00:04:55,230 --> 00:04:55,560 Right. 80 00:04:55,590 --> 00:04:58,620 This is not finished, but that's a graphical representation. 81 00:05:00,020 --> 00:05:08,730 And what else so I'm going to go back to the first to do list, so we are going to cover this in sections. 82 00:05:08,750 --> 00:05:10,690 I'm not going to do in one go. 83 00:05:10,700 --> 00:05:17,150 It's really it's going to be hard for you and it's going to be hard for me to explain it in one go if 84 00:05:17,150 --> 00:05:18,800 I don't separate this. 85 00:05:19,040 --> 00:05:22,530 So what I'm for creating this first to do list. 86 00:05:22,550 --> 00:05:26,450 So what we are doing, we're going to add event listeners to the button here. 87 00:05:26,570 --> 00:05:26,970 Right. 88 00:05:27,590 --> 00:05:31,790 So we're going to add event listener to this program, because what we are trying basically to save 89 00:05:31,790 --> 00:05:39,920 data and unclick I just want to have a listener there and I don't know why is this open because I don't 90 00:05:39,920 --> 00:05:42,010 need it for this lecture now. 91 00:05:43,130 --> 00:05:44,890 So we're going to add event listener. 92 00:05:44,900 --> 00:05:46,760 We're going to store the data somewhere. 93 00:05:47,000 --> 00:05:47,350 Right. 94 00:05:47,360 --> 00:05:49,670 And that will be pretty much in the calories application. 95 00:05:49,670 --> 00:05:53,500 Probably we're going to save the data internally and display the result. 96 00:05:53,510 --> 00:05:53,780 Right. 97 00:05:53,810 --> 00:05:54,630 This is the result. 98 00:05:54,770 --> 00:05:57,290 So after we save this, bologna's it, right. 99 00:05:57,470 --> 00:05:58,040 Spagetti. 100 00:05:58,880 --> 00:06:06,020 The graphical user interface will kick in display this that's I need separate modules now. 101 00:06:06,020 --> 00:06:10,320 Compute the calories that are added, burn it in a percentage and update them in a meina. 102 00:06:10,460 --> 00:06:15,560 So these here number four, it's going to do with two modules. 103 00:06:15,560 --> 00:06:17,300 The first module will be the calories. 104 00:06:17,970 --> 00:06:27,310 Second module will be the graphical user interface, but the bridge will be the main controller. 105 00:06:27,500 --> 00:06:28,770 So that's pretty much it. 106 00:06:28,910 --> 00:06:32,210 So we have the main module will be the bridge between them. 107 00:06:32,240 --> 00:06:40,490 So here lether maybe I will add at the end, you know, maybe I will add some links and this is how 108 00:06:40,820 --> 00:06:42,220 our application will look. 109 00:06:42,320 --> 00:06:45,950 So don't be afraid now don't just start looking. 110 00:06:45,950 --> 00:06:53,030 But here, user inputs, calories, food or exercise in here in the app UI controller, we're going 111 00:06:53,030 --> 00:06:58,240 to do this functions in the main control or we're going to do this function in a calorie controller. 112 00:06:58,250 --> 00:06:59,540 We're going to do this function. 113 00:06:59,870 --> 00:07:04,910 Note that some of the functions, names we will probably change or they will remain the same. 114 00:07:04,910 --> 00:07:05,600 Doesn't matter. 115 00:07:05,930 --> 00:07:09,310 They're just names and here is a click or Quebrada. 116 00:07:09,350 --> 00:07:12,870 So we're going to use you will see you will you. 117 00:07:12,950 --> 00:07:20,060 We already have done the mouse click stuff like that but we will do the keyboard this time and that 118 00:07:20,060 --> 00:07:23,420 and then fire for adding or deleting items. 119 00:07:23,420 --> 00:07:23,660 Right. 120 00:07:23,690 --> 00:07:27,730 Because when we add item and after that we need to delete this item. 121 00:07:28,310 --> 00:07:32,780 So pretty much good stuff right now. 122 00:07:33,050 --> 00:07:34,430 This is the architecture. 123 00:07:34,580 --> 00:07:37,640 I've used some flowcharts here. 124 00:07:38,270 --> 00:07:43,840 You can find flowcharts on the Internet and I suggest you for every project you put before you doing 125 00:07:43,850 --> 00:07:45,110 put it in a graphical way. 126 00:07:45,110 --> 00:07:45,410 Right. 127 00:07:45,470 --> 00:07:47,380 You know what's going on, what will happen. 128 00:07:47,840 --> 00:07:51,950 So this domain controller is connection between these two. 129 00:07:52,790 --> 00:08:00,320 It's a hub that connects this to write the request by your controller, get the input from the form 130 00:08:00,320 --> 00:08:03,670 and after display the result back to the UI controller. 131 00:08:03,680 --> 00:08:03,970 Right. 132 00:08:03,980 --> 00:08:05,990 So I'm getting the input and I'm displaying back. 133 00:08:06,260 --> 00:08:09,890 So this is communicating and this one is communicating, right. 134 00:08:09,980 --> 00:08:15,080 Because we cannot connect these two I mean, these two straight away. 135 00:08:15,200 --> 00:08:21,740 So that's why the main controller will have our will be the connection between these two modules. 136 00:08:21,740 --> 00:08:23,000 So I hope you understand. 137 00:08:23,330 --> 00:08:27,770 So this is the to do list that we're going to work on. 138 00:08:28,040 --> 00:08:32,360 You can go back and see what we are doing and say, OK, now we're going to at the event. 139 00:08:32,360 --> 00:08:36,380 Listen, we got a story today that we're going to save the data and that's pretty much what we're going 140 00:08:36,380 --> 00:08:36,650 to do. 141 00:08:37,130 --> 00:08:43,370 I suggest you to always refer to this document because I don't want to do a PowerPoint presentation 142 00:08:43,550 --> 00:08:46,730 when I can have it in some block like this is not mandatory. 143 00:08:46,970 --> 00:08:48,020 You already read it. 144 00:08:48,320 --> 00:08:49,070 You can parse it. 145 00:08:49,070 --> 00:08:49,970 You can read it from here. 146 00:08:49,970 --> 00:08:52,100 You don't have to go to the link. 147 00:08:52,250 --> 00:08:52,580 Right. 148 00:08:52,640 --> 00:08:53,870 Not going to provide even a link. 149 00:08:53,870 --> 00:08:59,110 So you can go to my website and get this JavaScript calories app, and that's pretty much it. 150 00:08:59,240 --> 00:09:00,980 You can search it on top. 151 00:09:01,430 --> 00:09:02,090 That's very much it. 152 00:09:02,300 --> 00:09:04,160 So thank you for watching. 153 00:09:04,160 --> 00:09:06,590 I hope I'm going to see you in the next one. 154 00:09:06,920 --> 00:09:13,850 And this is not going to be easy or it's going to be very hard part for it's going to be more complex, 155 00:09:13,850 --> 00:09:19,310 more advanced than previous parts, but it's going to benefit you if you go from the first lecture until 156 00:09:19,310 --> 00:09:19,850 the last one. 157 00:09:19,910 --> 00:09:21,210 So that's pretty much it. 158 00:09:21,380 --> 00:09:21,920 Thank you. 159 00:09:22,070 --> 00:09:23,710 And I will see you in the next one.