Unit tests are important. They prevent regressions as you refactor code, serve as documentation, and save you hours of time not spent doing tedious manual testing. In short, tests enable change.
But how much attention to cleanliness do we give our tests? We refactor our app’s production code, give descriptive names to variables, extract methods for repeatable functionality, and make our code easy to reason about. But do we do the same for our tests?
Consider this quote from Robert C. Martin:
“Test code is just as important as production code. It is not a second-class citizen. It requires thought…
Nearly every software company uses different environments for various stages of their code — local, development, staging, review, and production, to name a few.
For example, you might use a staging environment to host the app you’re about to deploy to production as you do one last spot check or run your test suite against it. Or you might use review apps as part of your code review process so that reviewers can easily confirm the app is working properly with the changes contained in the pull request.
Staging and review environments differ from production environments in that they are…
“We didn’t write tests because we wanted to get our code out faster.”
Those words were uttered by a coworker during a handoff call in which my team would be assuming ownership of a code repo from their team. I cringed.
Not writing tests leaves you open to bugs, makes refactoring more difficult, and actually makes you move slower in the long run.
That’s it. That’s the post. We can end this article here if you want.
(For confidentiality purposes, we won’t go into where this happened or how long ago this happened.)
Digging in a little deeper, let’s look…
Social media apps are perfect candidates for using graph databases and GraphQL APIs. The combinations of complex data queries and relationships are endless.
Take Reddit, for example. The app consists of subreddits (or topics). Users can create posts in these subreddits, which means that there is a many-to-one relationship between posts and subreddits. Each post belongs to exactly one subreddit, and each subreddit can contain many posts. Users can comment on posts, leading to another many-to-one relationship between posts and comments. Each comment belongs to exactly one post, and each post can have many comments. There is also a many-to-one…
When is the last time you’ve looked through your repo’s git history? Go ahead and do it right now using
git log. What do you see? Meaningful commit messages? Or a tangled mess of unhelpful statements?
Code is read more frequently than it is written, and the same is true of commit messages. Engineers working on legacy code will rely on the commit messages from previous developers to gain much needed context on why the code was written the way it was.
Therefore, make your commit messages good.
In this article we’ll learn how to write good commit messages by…
Clean code is more than just working code. Clean code is easy to read, simple to understand, and neatly organized. In this article, we’ll look at eight ways we can write cleaner React code.
When going through these suggestions, it’s important to remember that’s exactly what they are: suggestions. If you disagree with any of them, that’s completely fine. However, these are practices that I’ve found helpful in writing my own React code.
Let’s dive in!
If you need to conditionally render something when a condition is
true and not render anything when a condition is
false, don’t use a…
If you’re not familiar with these terms, you may be asking yourself, “What’s the difference? Are these all just interchangeable words that mean the same thing?”
In this article, we’ll define these terms and clear the air of any surrounding confusion.
Where do you keep your dad jokes? In a dadabase of course! Let’s imagine that you are a site maintainer for the world’s best dad joke database. Your app communicates with the database using a REST API that allows you to retrieve jokes and post ratings for those jokes. Visitors to your site can rate each joke they see via a simple user interface.
Recently you heard of a fancy new technology called GraphQL that provides the flexibility to request only the data that you need using a single API endpoint. It sounds neat, and you’d like to start using…
Your frontend application needs a design system. If you want to provide a consistent user experience (UX), ship features faster, make re-branding changes more easily, and free up your time to focus on hard UX problems, this article is for you.
A design system is a tool that enables you to build your application. It provides all the building blocks and guidance your team needs to design and develop a product. In simple terms, you can think of a design system as a component library. At the “atomic” level, you might have components for a button, or an avatar, or…
I recently published an article comparing HTML-to-PDF export libraries. In it, I explored options like the native browser print functionality, open-source libraries jsPDF and pdfmake, and the paid service DocRaptor. Here’s a quick recap of my findings:
If you want the simplest solution and don’t need a professional-looking document, the native browser print functionality should be just fine. If you need more control over the PDF output, then you’ll want to use a library.
jsPDF shines when it comes to single-page content generated based on HTML shown in the UI. pdfmake works best when generating PDF content from data rather…