Member-only story
React Hooks and functional programming for the lazy developer
Embrace your inner koala
“Let’s start with small things. Let’s finish our coffee,” says Mr. Columbo. If we followed his advice, we’d never get to the bottom of React Hooks and functional programming. So we’re going to start with big things.
“What’s the meaning of life?,” you may suggest. Hmm, great question, but maybe too big. Let’s narrow that down a bit. How about … the meaning of … software design patterns?
To answer your brilliant question, for which I take no credit: Code doesn’t stay put, frozen in time. It lives and breathes (well, hopefully it doesn’t breathe … that would be a problem). Software design patterns keep developers and users happy as code changes over time. They help the codebase scale better with complexity.
We want patterns that allow developers to be lazy. We want clean code that’s easy to read, test, and debug. Our brains create code in their own image, guided by the shining beacon of laziness.
This is why, my friends, React Hooks made such a splash. To quote Dan Abramov, “Hooks let us build components with less effort, and create better user experiences.” Hmm. Laziness. Exactly my point. Coincidence? I think not.
Sounds great. So how do I become lazy?
Start by realizing that tightly coupled objects work too hard. They depend on each other. They know too much about each other. They create more work for us when we want change, and invite spaghetti code with their noodly arms. It’s time to take that mess, roll it into a ball and toss it out the window. Excellent.
Whenever you get lost in heated discussions about paradigms and design patterns, ask yourself this: “How can I avoid unnecessary coupling?” Your life will soon begin to change in ways you never believed possible.
Okay, how does loose coupling relate to my JavaScript life?
Everyone deserves to have an identity crisis at some point, so why deny JavaScript this most…