[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:00.36,0:00:02.75,Default,,0000,0000,0000,,When we write a program, \Nwe're figuring out a way to turn Dialogue: 0,0:00:02.75,0:00:06.20,Default,,0000,0000,0000,,the brilliant ideas in our head \Ninto actual code. Dialogue: 0,0:00:06.41,0:00:10.72,Default,,0000,0000,0000,,Here I want to talk about a technique \Nthat many programmers use to do that, Dialogue: 0,0:00:10.72,0:00:13.26,Default,,0000,0000,0000,,and it's what we call "pseudocode." Dialogue: 0,0:00:13.26,0:00:16.97,Default,,0000,0000,0000,,Now, "pseudocode" is probably a word\Nyou never heard before, Dialogue: 0,0:00:16.97,0:00:21.41,Default,,0000,0000,0000,,but basically it's code \Nthat looks a lot like English Dialogue: 0,0:00:21.41,0:00:24.60,Default,,0000,0000,0000,,or really whatever language \Nyou like to talk in. Dialogue: 0,0:00:25.22,0:00:28.93,Default,,0000,0000,0000,,Well, okay, that may not make sense, \Nso let's talk through an actual example. Dialogue: 0,0:00:29.57,0:00:33.57,Default,,0000,0000,0000,,So let's say that I want to draw \Na nice symmetrical face. Dialogue: 0,0:00:33.57,0:00:37.20,Default,,0000,0000,0000,,So I might start by looking at myself \Nin the mirror and maybe sketching it out Dialogue: 0,0:00:37.20,0:00:40.27,Default,,0000,0000,0000,,and seeing, okay, well I have this oval face.\N Dialogue: 0,0:00:40.27,0:00:43.91,Default,,0000,0000,0000,,I have two eyes, \Nand they're about at this level. Dialogue: 0,0:00:43.91,0:00:46.77,Default,,0000,0000,0000,,And this is what \Nthe center of the face is Dialogue: 0,0:00:46.77,0:00:51.27,Default,,0000,0000,0000,,and now I have an idea for what\NI want my face to look like. Dialogue: 0,0:00:51.27,0:00:54.28,Default,,0000,0000,0000,,So I'll start writing it in pseudocode. Dialogue: 0,0:00:55.88,0:00:59.28,Default,,0000,0000,0000,,So let's see, the first thing \Nwe'd want to do is draw the face, Dialogue: 0,0:00:59.28,0:01:01.00,Default,,0000,0000,0000,,which is an oval, in the center. Dialogue: 0,0:01:02.14,0:01:07.82,Default,,0000,0000,0000,,Then we'd want to draw the two eyes,\Nwhich are two ovals, Dialogue: 0,0:01:07.82,0:01:14.79,Default,,0000,0000,0000,,about two thirds up the face, \Nand one fifth the size of the face. Dialogue: 0,0:01:15.05,0:01:18.01,Default,,0000,0000,0000,,Not exact math there \Njust looking at my own face. Dialogue: 0,0:01:18.01,0:01:23.21,Default,,0000,0000,0000,,And then we draw the mouth, which is \Na line going halfway across the face, Dialogue: 0,0:01:24.12,0:01:27.80,Default,,0000,0000,0000,,and maybe one third of the way up. Dialogue: 0,0:01:28.82,0:01:32.59,Default,,0000,0000,0000,,So notice how I write \Nmy pseudocode as comments Dialogue: 0,0:01:32.59,0:01:35.51,Default,,0000,0000,0000,,by starting each line\Nwith the two slashes here. Dialogue: 0,0:01:36.20,0:01:40.02,Default,,0000,0000,0000,,That way I can write my pseudocode\Nin the program itself Dialogue: 0,0:01:40.02,0:01:43.10,Default,,0000,0000,0000,,and not have to worry about \Ngetting any syntax errors Dialogue: 0,0:01:43.10,0:01:45.61,Default,,0000,0000,0000,,because the program will ignore comments. Dialogue: 0,0:01:46.67,0:01:50.43,Default,,0000,0000,0000,,Now that I've written this in pseudocode, \NI can spend the time to turn Dialogue: 0,0:01:50.43,0:01:54.100,Default,,0000,0000,0000,,each of these lines of pseudocode \Ninto actual bits of code Dialogue: 0,0:01:54.100,0:01:58.38,Default,,0000,0000,0000,,Right? So let's see, for the face \NI need an oval in the center. Dialogue: 0,0:01:58.38,0:02:03.30,Default,,0000,0000,0000,,For that I'll use the ellipse function for,\Nand I'll, you know, figure out Dialogue: 0,0:02:03.30,0:02:07.54,Default,,0000,0000,0000,,the center of the screen here,\Nand figure out an eye size. Dialogue: 0,0:02:08.14,0:02:09.71,Default,,0000,0000,0000,,Okay?\NThat looks good. Dialogue: 0,0:02:09.71,0:02:12.45,Default,,0000,0000,0000,,For the eyes once again \Nthose are ellipses. Dialogue: 0,0:02:12.45,0:02:15.50,Default,,0000,0000,0000,,Everything on my face is an ellipse. \NI'm very round. Dialogue: 0,0:02:15.50,0:02:21.74,Default,,0000,0000,0000,,And it's going to be, let's see, \Nwe'll do some math here to get the eyes Dialogue: 0,0:02:21.74,0:02:26.84,Default,,0000,0000,0000,,at a nice place, and make them\Nabout a fifth the size. Dialogue: 0,0:02:26.84,0:02:29.12,Default,,0000,0000,0000,,Okay, that looks good for the first eye. Dialogue: 0,0:02:29.12,0:02:31.52,Default,,0000,0000,0000,,I'll just copy paste, make the next eye. Dialogue: 0,0:02:31.52,0:02:32.64,Default,,0000,0000,0000,,Great! Dialogue: 0,0:02:32.64,0:02:37.12,Default,,0000,0000,0000,,Now I can even leave my pseudocode \Nfor a friend to implement, Dialogue: 0,0:02:37.12,0:02:38.62,Default,,0000,0000,0000,,and they probably could, \Nbecause they can, you know, Dialogue: 0,0:02:38.62,0:02:40.80,Default,,0000,0000,0000,,I have given this really nice description. Dialogue: 0,0:02:40.80,0:02:44.71,Default,,0000,0000,0000,,So I'm going to do that here, \Nbecause, you know, we're friends, right? Dialogue: 0,0:02:45.73,0:02:48.57,Default,,0000,0000,0000,,So, you might think this is silly. Dialogue: 0,0:02:48.57,0:02:51.79,Default,,0000,0000,0000,,Why are we going through the effort\Nto write our program twice? Dialogue: 0,0:02:51.79,0:02:54.88,Default,,0000,0000,0000,,First in human language \Nand then in program language. Dialogue: 0,0:02:54.88,0:02:59.05,Default,,0000,0000,0000,,Well, this example was pretty simple, \Nbut pretty soon you'll be building Dialogue: 0,0:02:59.05,0:03:02.33,Default,,0000,0000,0000,,more complex programs, \Nand it may be hard for you to keep Dialogue: 0,0:03:02.33,0:03:05.46,Default,,0000,0000,0000,,the whole program in your head \Nbefore coding it. Dialogue: 0,0:03:05.46,0:03:09.30,Default,,0000,0000,0000,,So what I usually do is write the general\Nidea in pseudocode first, Dialogue: 0,0:03:10.19,0:03:15.12,Default,,0000,0000,0000,,and then I'll spend more time on\Nthe details of each part of that idea, Dialogue: 0,0:03:15.12,0:03:19.01,Default,,0000,0000,0000,,converting each line \Nof pseudocode into real code. Dialogue: 0,0:03:19.01,0:03:22.42,Default,,0000,0000,0000,,I think you'll find that once you start\Nusing pseudocode Dialogue: 0,0:03:22.42,0:03:24.30,Default,,0000,0000,0000,,you'll do it more and more. Dialogue: 0,0:03:24.30,0:03:26.50,Default,,0000,0000,0000,,Try it in your next program and see.