In this video, I want to introduce one of the most important elements of the course. The How To Design Functions recipe, where we call it the HTDF Recipe for short. The HTDF Recipe systematizes the design of a function. What I mean by that, is it tells us what to do first, and second, and third, all the way through the design of a function. So it helps us know what to do, and it also helps us be sure that we end up with a high quality function. That really does what we need it to do, and that's been well-tested. Now, there's a funny thing about design recipes or design methods, as they're sometimes called, particularly effects when you learn them. What a design recipe does, is it makes hard problems easier. It lets us take a big, hard problem and break it down and work through it in a systematic fashion. The price we pay for that is that it actually makes easy problems more cumbersome. That's right, the HTDF Recipe is going to make hard functions easier to design, and easy functions a little harder to design. In fact, once you get good at designing functions, you won't use the HDTF recipe for really simple functions. But for now, we want you to use the HDTF recipe even for simple functions. That's because the way this is going to work, is that you're going to use simple functions to learn the recipe. And then you're going to use the recipe to do the hard functions. So what I need to ask for now is two kinds of patience. If you've never programmed before, it's going to seem like there's a lot going on, when we introduce this recipe. So, I'm going to need to ask, that you be patient, and go through it with me at the pace we're going through, and I promise you it will become familiar. If you have programmed before, this is going to seem like overkill. We're going to start with a very simple function, and by using the recipe it's going to take us quite a long time to do it. I need to ask you to be patient too. I promise you within a few weeks by using the recipe, we're going to be designing much harder functions than we can design otherwise. Here's how we're going to go through this material. There's going to be this video and the next one. In the first video, I'm going to go through the design of a function step by step, and I'm going to tell you what I'm doing at each step. But I'm going to describe it, as if you already knew the terminology of the design recipe. I know that sounds silly because you don't. But we've learned from teaching this to many, many students at UBC, that the right thing to do first is to kind of go through it at almost normal speed. Then in the next video, the next video is going to kind of be a slow motion version of this video. In that next video, as we go through it piece by piece, I'll elaborate on each piece we're doing and why we're doing it and how it works. So what we're going to ask you to do is watch this video once at speed, then watch the next video with Dr. Racket open following along. And then it'll probably help you to watch this video again at speed. Everything we do, the entire design recipe, you can find on the course webpage, under the Design Recipes link. That example, that's used on the website, is the one we're going to do here, so you'll be able to follow along. Again, be patient with the material, and be patient with yourself. There's a lot going on in the HTDF Recipe. You're not going to pick it up the first time through. You're not going to pick it up the second time through. But you'll be going through the recipe hundreds of times through the course. And I promise you, within a couple weeks, it's going to seem quite familiar. And you'll just be learning more nuances about it as we go forward. Okay, what I've done here is I've opened the double starter Dr Racket file that I got from the one webpage. I've opened it and I'm getting it tells me the problem we need to do. We need to design a function that consumes a number that produces twice that number. We're going to call the function double, and we need to follow the How To Design Funstion recipe, and show the stub and the template. And remember, I'm doing this at full speed, I'm not explaining every step of it. This video will take just a couple of minutes and then in the next video, we'll do it slower and I'll explain every bit of it. But whenever I follow the How To Design Functions recipe, I like to have an overview of the recipe in front of me. So what I've done is to go to the first website. And I went to the Design Recipes overview tab. And over here on the side is a sub, overview of the How To Design Functions recipe. And I've taken that and copied it in my video editor and set it right here, so that you could see it while I work. Okay, so step one is signature, purpose, and stub. So, this function is going to consume a number and it's going to produce a number, so that's my signature. It's purpose is going to be to produce two times the given number. Okay, and the stop, let's see, this function is called double and it consumes a single argument which is number. I'll call it n. And it produces a number, so for now we'll have it produce zero. And this is the stub. Okay? Now the next step I've gotta do is the examples wrapped in check-expect, and those are going to go right here actually. What I'm going to say is I'm going to say check-expect. Expect that if I call double with 3, I'll get 6. And I'll give another one, check-expect that if I call double, with 4.2, I'll get 8.4 like that. And then I'm going to run my check-expects and let's see, they're failing but both of them are running. So I'm quite happy they're both running. Now I'll come back up here and the stub has done its job, it let me run my check-expects. So I'm going to commend out the stub, and I'll go on the next step of the recipe is to write the templates, so I'll say define double of n. And the template for this function is dot dot dot n. That's the template. And actually, what I'm going to do is make a copy of the template. And I won't mark the template, the copy saying it is the copy. I'm going to copy out, comment out the actual template. The next to the last step of the recipe is to code the function body. So it might be useful to me at this point to be a little bit more clear for myself why that's 8.4. The reason that's 8.4 is that it's really times 2 of 4.2. Oh, and now I understand how this function works. It just multiplies whatever n is, [SOUND] by 2. Now I'll run it, and both tests pass. So that's a first pass through the HTDF Design Recipe. Again, I certainly don't expect you to have fully absorbed the HTDF Recipe from that quick pass through it. What I want you to do now is go to the next video. Which is going to be the slow motion version of this video, in which I'll talk about the different parts of the recipe in more detail.