Some of these examples are real-world examples taken from a production code-base. Since they were shipped to production I would like to take this opportunity to help others understand the good and the bad when we write code.
As time passes the day to realize this becomes an important practice comes closer than ever. By not handling different…
Node.js is one of the most popular platforms to develop applications due to its blazing-fast ability to process I/O operations. But there are plenty of other good reasons for its popularity.
I think we’ve all been there — placing our calls to
console.log all over our functions during development. Debugging code can…
In modern programming, there is plenty of discussion about what is known as state, which most commonly revolves around user interactivity. The MutationObserver is a powerful API that can help us with this because we can use it to react to user interactivity. It is what replaced the legacy Mutation Events API from the DOM3 Events specification.
To create a
MutationObserver, we need to instantiate it with the
new keyword along with a callback like so:
onMutation callback receives two arguments (in order):
Mutations— A list of
MutationObserverthat was constructed. In…
Knowing design patterns is vital in the software industry, as they have been proven to solve real-life problems in business applications. For example, Publish/Subscribe is a common pattern that is extensively used in the DOM. The Command pattern is used in Redux, which boomed in a short period of time due to its unique, robust, and simple ability to manage app state that is also very scalable.
The interesting part about design patterns is that they aren’t one-size-fits-all solutions. …
Have you ever come across code where some function was suffixed with
The way the Adapter works is that you create a function (which can be a class, but it doesn’t have to be implemented as a class) that adapts its interface’s properties and methods into a new class seamlessly — as if the adapter…
Naming our files is seemingly a simple task. But just because it is simple to do doesn’t mean it wouldn’t become much of a problem. Just like naming our variables in code, it is a practice that can become a huge deal when you aren’t the only one writing the code for some project.
Recently, there was a colleague that maintained a package that I had to take over since he was no longer maintaining it.
In a perfect world, all code should be easy to maintain and easy to work with, but not everything in life goes in our…
It is important to keep in consideration the different scenarios in which errors could occur while writing your code. They play an integral part in your web application because you can avoid deadly scenarios (like your application crashing completely) that would otherwise not have been avoided if left unhandled.
It’s often useful to provide a more descriptive error inside your error handlers. And by this, I don’t just mean writing your error message clearer. What I’m referring to is to extend the
Since functions can be passed around anywhere, we can pass them into the arguments of functions.
We’ll be going over five critical tips to compose event handlers in React. This article won’t cover everything that’s possible, but it’ll cover important ways to compose event handlers that every React developer should know at a minimum.
If you’ve been a React developer for a while you might agree with me that working with state can easily be the biggest pain in your day.
So here’s a tip that might help keep you from introducing silent but catastrophic errors: Avoid closures referencing state values from their callback handlers.
If done right, you should have no problems dealing with state in callback handlers. But if at just one point you slip and introduce silent bugs that are hard to debug, that’s when the consequences begin to engulf time in your day that you wish you could take back.