0:00:00.040,0:00:03.139 [Music] 0:00:03.360,0:00:07.200 our exercise says 0:00:04.720,0:00:09.040 what is a module what is its purpose how 0:00:07.200,0:00:10.480 do we use them with our classes 0:00:09.040,0:00:13.120 create a module for the class you create 0:00:10.480,0:00:14.719 an exercise one and include it properly 0:00:13.120,0:00:16.400 all right first you'll see that i 0:00:14.719,0:00:17.199 changed the class we were using just a 0:00:16.400,0:00:19.840 little bit 0:00:17.199,0:00:20.400 the class name is now person and the 0:00:19.840,0:00:23.279 object 0:00:20.400,0:00:24.240 is first person and it's a person.new 0:00:23.279,0:00:26.560 instead of 0:00:24.240,0:00:28.560 example class and i just did that to add 0:00:26.560,0:00:31.039 a little bit more of 0:00:28.560,0:00:32.239 clarity as to how we use modules but you 0:00:31.039,0:00:33.200 don't need to change your class it's 0:00:32.239,0:00:36.320 fine 0:00:33.200,0:00:39.840 so the first purpose of a module is to 0:00:36.320,0:00:41.440 extend functionality of a class 0:00:39.840,0:00:43.120 so let's say we have a module called 0:00:41.440,0:00:45.360 swimable and 0:00:43.120,0:00:47.039 inside this module we could put the 0:00:45.360,0:00:49.920 ability to swim 0:00:47.039,0:00:51.440 and in order to lend that functionality 0:00:49.920,0:00:54.079 to the person class 0:00:51.440,0:00:55.680 we only need to use the include keyword 0:00:54.079,0:00:56.960 and then the name of the module we want 0:00:55.680,0:00:59.280 to include 0:00:56.960,0:01:01.280 and now all the functionality inside 0:00:59.280,0:01:02.160 this module is now available to the 0:01:01.280,0:01:05.360 person class 0:01:02.160,0:01:08.080 and the objects of the person class so 0:01:05.360,0:01:10.080 that's one way to to use a module and 0:01:08.080,0:01:12.159 it's also great because you can include 0:01:10.080,0:01:13.680 a module in several different classes 0:01:12.159,0:01:16.799 this allows you to 0:01:13.680,0:01:19.119 have dry code or do not repeat yourself 0:01:16.799,0:01:20.240 another use of a module is called 0:01:19.119,0:01:22.720 namespacing 0:01:20.240,0:01:23.520 now namespacing helps you organize your 0:01:22.720,0:01:26.000 code better 0:01:23.520,0:01:26.880 so i'll give an example here let's say 0:01:26.000,0:01:30.079 we had 0:01:26.880,0:01:32.880 a module called careers 0:01:30.079,0:01:33.759 now inside here we could have classes of 0:01:32.880,0:01:36.240 different careers 0:01:33.759,0:01:37.920 for example we could have a class called 0:01:36.240,0:01:40.159 engineer 0:01:37.920,0:01:41.759 and we could also have a class called 0:01:40.159,0:01:43.920 teacher 0:01:41.759,0:01:45.600 now these classes are inside the module 0:01:43.920,0:01:46.159 so we we understand the relationship 0:01:45.600,0:01:47.920 better we're 0:01:46.159,0:01:49.600 not talking about anything except for 0:01:47.920,0:01:52.399 the career aspect 0:01:49.600,0:01:54.399 because of the module that allows us to 0:01:52.399,0:01:56.399 do some name spacing so we know we mean 0:01:54.399,0:01:58.799 engineer in the career context 0:01:56.399,0:02:00.399 we mean teacher in the career context 0:01:58.799,0:02:04.560 and the way to instantiate an 0:02:00.399,0:02:05.040 object of a class that is inside one of 0:02:04.560,0:02:08.239 these 0:02:05.040,0:02:11.200 is you prepend it with the module name 0:02:08.239,0:02:12.959 so write careers two colons and then the 0:02:11.200,0:02:15.040 class name and then new 0:02:12.959,0:02:16.160 so this part is the same we just need to 0:02:15.040,0:02:18.080 prepend it 0:02:16.160,0:02:19.760 with careers and two colons in order to 0:02:18.080,0:02:22.640 instantiate an object 0:02:19.760,0:02:24.720 so again the first purpose of a module 0:02:22.640,0:02:27.040 here is to extend functionality 0:02:24.720,0:02:29.040 especially in preserving dry code 0:02:27.040,0:02:32.720 and the second one is namespacing which 0:02:29.040,0:02:32.720 helps us organize our code a little bit 0:02:34.840,0:02:39.280 more 0:02:37.200,0:02:39.280 you