Category: Refactoring

Refactor Code in Your Lunch Break: Getting Started with Codemods

Maintaining a codebase can be a frustrating experience for any developer, especially a JavaScript codebase. With ever-changing standards, syntax, and third party package breaking changes, it can be hard to keep up. In recent years, the JavaScript landscape has changed beyond recognition. Advancements in the core JavaSc...

Jumping from PHP to Go: Blasphemy, Bravado or Common Sense?

Earlier this year, I made an arguably bad business decision. I decided to rewrite the Laravel application powering Boxzilla in Go. No regrets though. Just a few weeks later I was deploying the Go application. Building it was the most fun I had in months, I learned a ton, and the end result is a huge improvement over...

What Tutorials Don’t Tell You: How to Approach Projects

I often hear that people who follow tutorials find themselves unable to approach JavaScript projects on their own. One reason this happens is that tutorials give you a neat set of steps rather than the actual process of figuring out those steps on your own. Another reason people struggle with projects is that they co...

Saved from Callback Hell

Callback hell is real. Often developers see callbacks as pure evil, even to the point of avoiding them. JavaScriptʼs flexibility does not help at all with this. From the surface, it seems callbacks are the perfect foot gun, so it is best to replace them. The good news is there are simple steps to get saved from callba...

JavaScript Refactoring Techniques: Specific to Generic Code

In a recent thread on SitePoint’s forums, some code was given to let one dropdown box control when another dropdown box is visible. Even though the code worked just fine, I realized that it left much to be desired. It was brittle and incapable of withstanding even small changes to the accompanying HTML. Here is t...

Cleaning up Code: Is Refactoring for Aesthetics worth It?

Most development teams want to get their codebase into a better, more maintainable state. But what definition of better should be chosen? In many cases, it is not necessary to dig deep into Domain Driven Design (DDD) to achieve this goal. Sometimes, it's even counter productive. But one of the most basic collection...

15 Ways to Write Self-documenting JavaScript

Isn’t it fun to find a comment in code that’s completely out of place and useless? It’s an easy mistake to make: you change some code, and forget to remove or update the comment. A bad comment won’t break your code, but imagine what would happen when debugging. You read the comment. It says one...

Untangling Spaghetti Code: How to Write Maintainable JavaScript

Almost every developer has had the experience of maintaining or taking over a legacy project. Or, maybe it’s an old project which got picked up again. Common first thoughts are to throw away the code base, and start from scratch. The code can be messy, undocumented and it can take days to fully understand everyth...

Upgrade Your App to Angular 1.5 Components and Beyond!

With each new release of AngularJS, the development team is trying to bridge the gap between AngularJS 1.x and 2. With the release of AngularJS 1.5, developers will be able to write applications structurally similar to AngularJS 2.0. In this tutorial, we’re going to create a grid directive in AngularJS 1.4. We...

Technical Debt: Rescuing Legacy Code through Refactoring

How can you get a legacy codebase under control and bring it to a new level of maturity? In this post, Jeroen summarizes the lessons learned from years of working on a large legacy web application. This article was originally published by intracto. Legacy Code Can Be Saved by Refactoring I have good news for you! Squi...