1 00:00:00,500 --> 00:00:02,880 We can't talk about objects without talking about types. 2 00:00:02,880 --> 00:00:06,670 You see every object is of a certain type. 3 00:00:06,670 --> 00:00:10,200 Remember when we use strings, ints, doubles before? 4 00:00:10,200 --> 00:00:12,960 They're called types because they form the template for 5 00:00:12,960 --> 00:00:15,530 the values that are of that type. 6 00:00:15,530 --> 00:00:20,180 In C sharp every value that a variable can take on is an object, so 7 00:00:20,180 --> 00:00:24,970 we've already used a bunch of objects, five, ten and 8 00:00:24,970 --> 00:00:28,048 23 are all objects of type int. 9 00:00:28,048 --> 00:00:34,140 3.14 10.5 100.2 are all objects of type double. 10 00:00:34,140 --> 00:00:38,210 Hello Bob and We the People are all objects of type string. 11 00:00:39,290 --> 00:00:43,910 These are all types that are built into the C Sharp language and .net framework. 12 00:00:43,910 --> 00:00:47,420 We can create our own types though, that's what classes are for. 13 00:00:47,420 --> 00:00:52,180 A class is the template for making individual objects of a particular type. 14 00:00:53,260 --> 00:00:58,310 Each individual object that a class makes is called an instance of that class. 15 00:00:58,310 --> 00:01:02,010 Remember we can use the words type and class interchangeably. 16 00:01:02,010 --> 00:01:06,010 So we could also say that an object is an instance of a type. 17 00:01:07,170 --> 00:01:10,550 You can think of classes like a cookie cutter. 18 00:01:10,550 --> 00:01:13,140 And the cookies are instances of that class. 19 00:01:14,190 --> 00:01:16,810 This cookie cutter makes heart shaped cookies. 20 00:01:16,810 --> 00:01:20,540 So all the cookies that this cookie cutter makes are of that type. 21 00:01:21,760 --> 00:01:23,910 Each of these cookies is a distinct object, 22 00:01:25,110 --> 00:01:26,650 even though they're all shaped like hearts. 23 00:01:27,800 --> 00:01:31,080 Also, just because we're using the same cookie cutter, 24 00:01:31,080 --> 00:01:33,610 doesn't mean all of the cookies have to look the same. 25 00:01:34,620 --> 00:01:37,740 We can make each heart shaped cookie a little different. 26 00:01:37,740 --> 00:01:41,490 For example, we could add food coloring to the dough, and 27 00:01:41,490 --> 00:01:43,690 have pink heart shaped cookies. 28 00:01:43,690 --> 00:01:46,760 The color is one of the attributes of the cookie. 29 00:01:46,760 --> 00:01:50,050 Likewise, we can create different objects from a class 30 00:01:50,050 --> 00:01:51,870 by changing the attributes of that class. 31 00:01:53,210 --> 00:01:56,580 Let's take a look at a graphical user interface of a piece of software to get 32 00:01:56,580 --> 00:01:59,910 an idea of how it's composed of classes and objects. 33 00:01:59,910 --> 00:02:02,630 Take a look at the Chrome browser for example. 34 00:02:02,630 --> 00:02:06,010 You're probably very familiar with what a web browser looks like. 35 00:02:06,010 --> 00:02:08,860 But have you ever thought about how it's put together? 36 00:02:08,860 --> 00:02:13,020 In the code for the Chrome browser there's a class that models a tab. 37 00:02:13,020 --> 00:02:17,640 This tab that I'm pointing to right here is just one instance of that class. 38 00:02:17,640 --> 00:02:19,470 I can make many tab instances. 39 00:02:20,580 --> 00:02:23,670 Each of these tabs is a separate object and 40 00:02:23,670 --> 00:02:25,390 they're all created from the tab class. 41 00:02:26,610 --> 00:02:31,270 Each tab has a title attribute that is different for each tab. 42 00:02:31,270 --> 00:02:33,120 They also have a behavior so 43 00:02:33,120 --> 00:02:37,000 that when they're clicked, their content is shown in the Window. 44 00:02:37,000 --> 00:02:42,240 There's a menu class with that many menu objects created from that class. 45 00:02:42,240 --> 00:02:46,430 There's a button class and many unique objects created from the button class. 46 00:02:48,090 --> 00:02:52,660 I hope you're starting to get an idea of what object-oriented programming is and 47 00:02:52,660 --> 00:02:54,110 how it's useful. 48 00:02:54,110 --> 00:02:57,800 In the next videos,we'll get to see how this is all done in code. 49 00:02:57,800 --> 00:03:01,110 And hopefully things will become even more clear. 50 00:03:01,110 --> 00:03:05,880 The concept of objects in code can be a little difficult to understand at first. 51 00:03:05,880 --> 00:03:09,570 If after working through some code, things still aren't making sense. 52 00:03:09,570 --> 00:03:13,850 I suggest watching this video again while thinking about what we've done in code.