A couple of years ago I was talking to a woman who was doing simultaneous Masters degrees from Carnegie Mellon University and running a brain study on chronic depression. When we were talking about her multiple degrees and her musical experience, all while she let me pick her brain about neurology, she said something that stuck with me, “All life is pattern-matching.” She explained the connections between her mathematical and scientific experience with her creative endeavors, and it made sense. Patterns are everywhere, and we learn through recognizing and seeing the patterns, internalizing them, applying them, and eventually understanding them.
This is the approach I try to turn to when I’m frustrated with myself when I don’t “understand” the code that I’m seeing on the page. And this is a perspective that I would’ve benefitted from when I was learning to code, but most recently now, it’s what I lean into when I’m frustrated with myself for not understanding new concepts.
But why is a pattern-matching perspective important to coding?
I don’t know about you, but I’ve let out some desperate cries to the universe to please just let me get this so I can move on!
And then one night, the magical neural-pathway fairy comes and sprinkles its coding dust onto my brain and I wake up, and suddenly it’s clicked. And I can’t remember why I couldn’t get it the day before.
But the perspective that coding is pattern-matching removes (at least some of) that frustration, tames those desperate cries to the universe, and empowers my progress rather than prohibits it.
But what does pattern-matching for coding even mean?
Sometimes you get hung up on “understanding” all of the concepts. And, of course, that’s important. But you shouldn’t be stuck on learning the same thing over and over in the attempt to really understand something. That will come later.
Pattern-matching perspective: Looking at the patterns in code and being able to replicate those patterns in other projects. You don’t have to know why the pieces work, just that they are the pieces, and how they match.
For example, let’s look at a JavaScript Object:
const person = {name: 'Leslie', job:'Parks and Recreation Deputy Director', favoriteFood:'waffles'}
Okay, so maybe we need to create another person object. We don’t need to know why there are curly braces here or why there are colons. We don’t need to know that there are keys and values. We need to recognize the pattern.
What we need to recognize is that there are general attribute indicators (name, job, favoriteFood), that are followed by colons and then specific information, wrapped in quotes. And all of this is wrapped in curly braces.
We’re just breaking down the pieces so we can apply this in our own situation.
One of the most important lessons I’ve learned is that the more I apply the code that I’ve learned in practical ways (real world projects), the more I’m able to understand it.
If someone would’ve told me that I needed to totally understand all of JavaScript before moving on to React, I would still be learning JavaScript.
We shouldn’t be waiting to fully understand. Tech changes so quickly that full mastery likely won’t ever happen.
As I’m moving into new projects, I’m taking this mindset with me. I’m looking for patterns and applying them. The next step is recognizing what we need in our coding projects by seeing the patterns in the code. And maybe that sparks an Aha! moment, like I could really use a useEffect here. Or using grid seems like a practical choice here. (But that Aha! moment deserves its own blog post.) And finally, those patterns click in our brains and we start to understand the hows and whys and whats of coding.
Top comments (5)
Big yes to this!
I spent almost 9 months with vanilla JS and didn't understand most of it.
But when I learned Node JS, everything started to click because I can see how they all work and the functionality in a project!
I'm one of those who opposed the quote "Understand and be good at the basic before moving on". Maybe it works for most people, but definitely not for me 😅
Thank you for sharing this "recognize the pattern", Bekah!
I need to train myself to do this as well 😊
I've heard of pattern-matching with coding before, but never really saw or understood how the two were connected. Thanks for sharing this, I'll definitely be re-reading and seeing how I can apply it to myself. I've been in the "frustrated with myself when I don’t “understand” the code that I’m seeing on the page" phase for a few weeks now and can't seem to get my head back in it.
I also needed to hear "We shouldn’t be waiting to fully understand" - I've been stuck on this too. Thanks for this great post and insight!
Thank you for sharing this it's really insightful ✨
Great insight! That feeling of when you've seen something before and can try to use your previous knowledge is awesome and helps build skills like nothing else.
It is a really helpful post. Pattern matching helps me learn new programming languages relatively easily.