Check out a free preview of the full The Hard Parts of Functional JavaScript course
The "Wrapping Up" 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 wraps up and reminds the viewers that this course's goal is to give engineers the core pieces of functional programming to allow them to expand their knowledge while having solid foundations.
Transcript from the "Wrapping Up" Lesson
[00:00:03]
>> Will Sentence: So functional programming is a paradigmatic shift to take us away from our code being a series of instructions with the computer that aren't really written for us to understand so clearly and where every one of them can affect every other line. Into a world where every single line is given a lovely human readable name.
[00:00:28]
And then we break down each of our lines into one of those individual functions. And then couple them back up, combine them back up into larger tasks. As we'll see in a moment, it produces code that is profoundly easier to debug, to interpret for others, and to add new features to.
[00:00:53]
We just take the pre-saved little blocks, these little tiny functions and join them back up.
>> Will Sentence: Now, we have to do some interesting feats to wrestle these individual mini tasks, these tiny functions, these units of code, back into larger tasks. We saw some of them today, higher order functions that has combined and make individual code more specific by combining functions together.
[00:01:23]
Compositional reduction of a series of functions allows us to pass data through, combine it with a function, pass it to the next function, return it so I'll open the next function in a super readable manner. We then have to use closure to enable partial application where our functions required multiple inputs.
[00:01:43]
And yet, if we're having them automatically run for us by just listing them out, they're expecting to only receive one input. And if we have multiple inputs, the whole system breaks down. But folk, there's even more, and the goal of today's tool was not to give you every one of those techniques.
[00:02:02]
It was instead to give you some of the core techniques, understand them under the hood. So you are in the best possible position to go and tackle, taking on all those further techniques out there to make your code capable of switching into this more functional style. There's libraries out there like Rounder, all of which had these elements, but go far beyond it as well.
[00:02:24]
You hopefully now have your under the hood understanding of some of these core pieces on which you can now build those ever more sophisticated models. But wow, if you can do it, we get code that looks like a to do list of tasks that I can pass to any fellow engineer.
[00:02:43]
And they can say, here we are taking in this player, we're taking in their name, we're then taking the first name. We're up a and or proper casing it. We're adding a label prepended to it saying user and then we're creating a template ready for our DOM, ready to render to the DOM.
[00:03:05]
Note by the way, here, we might've had to partially apply one of these functions. What if our user template depends on some other piece of data? We might have had to pre-fill that other piece of data to make this createUserTemplate ready to run. Adding user label, we may want to add a more general label and pre-fill it with a specific label we wanna add to that piece of data.
[00:03:28]
All of that's gonna use our partial application technique, all of which relies on closure. But if we can do it, folk, our code is now a set of independent self contained. This line, its only consequence is the next function. Get first name, we return out will, only consequence, pass into proper case.
[00:03:53]
Get will with uppercase W. We get it, these self contained steps we can then wield, recombine up to solve any problem of our choice. We can become true composers of our code. It's been a pleasure sharing with you all some of the foundations of functional programming. You've gone under the hood of a small number today.
[00:04:24]
Now, take these core concepts and apply them in your own code step by step. And then look to the many other concepts out there in functional programming. Use these foundational steps to take you through to understand those new concepts. Thank you so much, people. It's been a pleasure sharing with you this wonderful, ever more popular paradigm for writing our code at scale.
[00:04:53]
Thank you.
>> Audience: [APPLAUSE]
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops