DEV Community

Cover image for Spend time to gain time
Thiago Mota dos Santos
Thiago Mota dos Santos

Posted on • Edited on

Spend time to gain time

The great magic of software development is that there's always the possibility to improve a process or automate it – in other words, to reduce active involvement in it. This frees up time to do other things, accelerating your development. However, to reach the stage of "time gain," you need to invest time in the first place.

Why automate?

Imagine that every day you need to spend 10 minutes updating your project's dependencies to ensure it's on the latest version. Doing some simple math: in 5 days, you've spent 50 minutes; 20 days -> 200 minutes; 1 year (20 * 12) -> 12 x 200 -> 2400 minutes, or putting it in hours: you've spent 40 hours on a task that could be automated.

Now, let's discuss the title, "Spend time to gain time." If creating a script to automate this task, so you don't spend 10 minutes daily, takes 4 hours to develop, it might seem like a significant time investment initially. However, in the long run, you'll save 36 hours using this small example.

Other Forms of Automation

  • Eslint:

The combination of Eslint + Prettier is an excellent form of automation; these technologies help us automatically format code simply by saving the project. Let's consider an example: imagine that you spend 1 to 2 seconds manually indenting each line of code. It might seem minor, but in the long run, this accumulates to a significant amount of "wasted" time.

  • Testing:

I used to be averse to testing myself, thinking, "I can test properly during development." This is a wrong notion. While it may seem expensive to spend a fair amount of time writing tests for your application, believe me, in the long run it makes a big difference. Again, let's use an example:

test('adds 2 + 2 to equal 4', () => {
  const result = sum(2, 2);
  expect(result).toBe(4);
});

function sum(a, b) {
  return a + b;
}
Enter fullscreen mode Exit fullscreen mode

This is another simple example, but consider a hypothetical situation. Imagine you've created a codebase, and much later, you need to revisit it because something went wrong, as indicated by the tests. In a very straightforward manner, you're directed to the problem if something is amiss. The amount of time needed tends to increase with the size of your codebase.

Moreover, tests ensure that managing your codebase becomes increasingly manageable as it grows.

When Should You Automate?

During development, many processes are often automatically automated by the tools themselves, so the cost might only be the configuration (in some cases), which is undoubtedly worthwhile.

A good time to create scripts to automate tasks is when you notice that you spend a reasonable amount of time on repetitive tasks that don't yield benefits when considering the long term.

In Conclusion

I believe the automation process goes hand in hand with optimization, being able to accomplish more and more in less time, and automating as many things as possible to achieve excellent results. Sometimes we think, "I've spent an hour setting this up, is it worth it?" We often don't look at things holistically, so I can say that, as time passes, it becomes more and more worthwhile.

Thumb by Lenny Kuhne on Unsplash

Top comments (0)