The Hard Parts of Functional JavaScript

Higher-Order Functions Pair Programming

Will Sentance

Will Sentance

Codesmith
The Hard Parts of Functional JavaScript

Check out a free preview of the full The Hard Parts of Functional JavaScript course

The "Higher-Order Functions Pair Programming" Lesson is part of the full, The Hard Parts of Functional JavaScript course featured in this preview video. Here's what you'd learn in this lesson:

Will describes the pair programming set of challenges that the audience is encouraged to work through.

Preview
Close

Transcript from the "Higher-Order Functions Pair Programming" Lesson

[00:00:00]
>> Will Sentance: All right folks, so at this point, we're gonna take a break for pair programming to come, many more higher order functions, linking them up the absolute core part five, the absolute core of functional programming, function composition, then later we're gonna go into closure function decoration. And all to come, the most advanced pieces POS application and carrying, but for now, we're gonna work through a series of pair program coding challenges, on higher order functions.

[00:00:38]
And I think I'm gonna pair you up honestly by who you're sitting next to as a relatively shared level of experience. So, folk on line will hopefully be able to take these challenges, but I have a pair programming set of challenges. I'm gonna write it on the whiteboard here, I don't know if I'm allowed to do this, but here it is, CS bin, and I'm gonna tell you about how to pair program the second, and I think it's called functional.

[00:01:07]
Have a look at that, maybe Mark's gonna look for that, I think it's called functional, and it's a series of challenges, which we're gonna work through today, and it's here that you're going to actually grow as an engineer, watching me talk is a quarter of the story. It's when you actually test it out yourself, when you actually hit a block and have to use the underlying mental model you've hopefully built, hopefully you've built an underlying mental model here.

[00:01:29]
And that should enable you that is the point of hard parts to build an underlying mental model, to enable you to tackle any new challenge yourself. Here is the problem, you work solo, a couple things happen, one, when you hit a block, we're very tempted to step away and do anything else, it's amazing.

[00:01:50]
It is amazing, cuz I've done it a few times where I've not stepped away, I try to force myself through in that moment. Cuz I know that it's the one I most wanna step away, that I had the biggest breakthrough in the next few seconds, literally the next few minutes usually.

[00:02:01]
It's kind of insane like when I'm preparing talks, and wrestling how to and I wanna step away, I want anything else, I want my phone, thrown on the other side of the room of course, my Internets turned off sort of stuff, but still I wanna step away. When you go to pair programming partner, you can't step away, you've gotta partner in crime so you can do the hard challenges, and that's where you grow.

[00:02:23]
What else is so great about pair programming? Technical communication, with a pair, what we actually have to do suppose we had Jasmine and Seth, I presume that sort of, so Jasmine and Seth, let's suppose Jasmine is our navigator. So there's two roles, the navigation and the driver, Jasmine is going to give Seth an overall strategy, to approach each challenge, so she's gonna say things like okay, Seth, let's start off here by declaring a function, we'll call it map.

[00:02:51]
Let's have it, it says it's gonna take a parameter of an array, take a parameter of an array, and say Seth, let's take a function of callback, okay? Let's go check what we know, a callback is always a function definition, okay let's have a take a function definition.

[00:03:04]
Let's test it out before we start invoking it by actually calling that with those two arguments, and see what the return value is, and it's undefined of course okay, and now Seth's job is to turn her virtualization in more pseudo code terms, into actual code with the keyboard.

[00:03:20]
Her technical communication better be on point because Jasmine is not allowed to say, Seth what I meant was this, get your hands on the keyboard and start typing it out for him. Her job is that what ever happens it's her responsibility to be able to communicate with such precision, that Seth can't fail but to convert it into code.

[00:03:41]
And by the way, Seth, so your technical communication goes up immensely. That's why I put so much pressure on you all to say things like yes, the one on the right hand side, we were gonna invoke the function, and its returned value is gonna be assigned on the left hand side, as opposed to just saying multiply by 2.

[00:03:58]
No no, that's call multiply by two with the argument of three, right it's very precise and let's say I've actually converted into code. And Seth by the way even if he feels like Jasmine's navigating him down the wrong path, he doesn't correct her, because all the time she's actually right, and he learns a new approach to solving the problem, but half time yeah so maybe she's wrong, but you now wanna embrace getting the error.

[00:04:23]
You wanna press Run, Seth wants to press Run, Jasmine wants to press Run, see an error, and now Seth knows what the error is, and that feels pretty good because what a mean way, but [LAUGH] rather because now errors are no longer a mystery to him. Now that error that he gets a witness his partner puzzling over an error, and he knows ha got it, that error is a tool to help me debug this code.

[00:04:53]
Because I kind of know what it means, when it says unexpected token or function is undefined, he knows why, and now that error is no longer this black box, it's a black box but he's sitting inside of it, super powerful.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now