I can’t remember when I first heard the phrase “work smarter, not harder”, but I’m always on the lookout for ways to improve my coding productivity and get the most out of my time, especially when writing code or managing projects. I recently discovered Plop, a micro-generator framework, and now I wonder how I ever managed without it!
Self-billed as a “micro-generator framework that makes it easy for an entire team to create files with a level of uniformity”, even as a single developer I have found Plop to be one of the most useful tools in my development arsenal, not just for saving time — it definitely does that — but also for improving productivity.
With roughly 170,000 weekly installs at the time of writing, Plop is hardly an unknown entity, but somehow it had still managed to avoid my radar until fairly recently. However, upon first use I was immediately impressed by both it’s sheer simplicity and it’s power to enhance my coding productivity and it has quickly become one of my go-to tools.
Put simply, Plop is a tool to generate new files using templates that you define. Once configured, it takes nothing more than a short console command to produce a file (or an entire folder worth of files) complete with customised boilerplate ready for you to start hacking away.
Of course, the magic is in the template files that you have created and these can be as simple or as complex as you’d like. They are written using handlebars and matched to the command line arguments using a config file written in JavaScript.
It really doesn’t get much simpler.
It’s worth pointing out that although Plop is configured using JavaScript, it is not limited to producing .js files. It can be used to generate literally any type of text based file, so whatever your programming language of choice may be, Plop can help.
Imagine you’re in full flow developing your React app. You’re properly in the zone, everything is just slotting into place. You are at one with the code, and…
Stop!
A new component needs to be introduced. Not a big job, takes maybe a minute to do from scratch. Easy, right? Well, yes. But a massive sap on productivity. Here’s why:
Every context switch takes you out of your flow state and reduces productivity for roughly 25 minutes. And that’s the problem; writing out non-value added boilerplate takes your focus away from the application you are writing i.e. the component logic. That 60 seconds of “fluff code” literally kills your productivity for the best part of half an hour! Not good.
That’s where I find Plop has an additional benefit. Yes, it generates consistent starter code for an entire team, and it saves time across multiple uses. But it also produces consistent starter code extremely quickly and with very little thought, meaning you can stay in the zone and keep all the productivity benefits you built up over the previous 30 minutes.
Multiplied out, every 10 or so components added to a project have the combined potential to take you out of the zone for 300 minutes. 5 hours! If your days involve anything that isn’t coding, then you could be losing an entire day or more of code productivity every week!
Clearly, this is very wasteful and can be, should be, improved. For me, Plop forms a part of the solution because one simple command can be executed almost as quickly as I think of it. And that means my focus stays on developing the application, not writing boilerplate.
Plop is a relatively well used tool with a headline benefit to save time and create uniformity across a team. I argue that it has an important additional benefit for sole developers as well as teams: Improved productivity.
Hopefully by now you are convinced of why Plop is a great tool, so in the next article, we’ll go through a simple use case for creating a React component comprising of several Typescript files.
(Previously published at - https://medium.com/@fgmonaghan/plop-a-tool-for-developer-productivity-33cfedd39b6)