There are any number of tools to analyse code for you, even write it for you. If reducing cognitive complexity, avoiding potential null reference exceptions, and ensuring 80% code coverage from unit tests is the priority, then peer review processes won't be the focus.
Reduce, re-use and re-write your code
Slowly but (hopefully) surely, the world seems to be waking up to the looming climate crisis. The recent IPCC climate change report has made it clear that decisive action is required to avoid the planet becoming a simmering hellscape in the not too distant future. Individuals are starting to think more about how they can help by reducing their emissions. What role can software engineering and related disciplines play in this global effort?
Don’t leave the lights on
The refrain you will most commonly hear parents saying to children is just as applicable to the infrastructure that powers modern digital platforms. The cloud makes it incredibly easy to spin up new infrastructure and services with a few lines of code or button clicks. It also conceptually separates your actions from the potential emissions they may be creating many hundreds or thousands of miles away in a data centre.
Happily, the cloud also makes it just as easy to turn all that stuff off again – reducing emissions, and potentially saving you money depending on the nature of your infrastructure. Some cloud services are designed to spin down automatically when not being used – but a bunch of them aren’t.
Use infrastructure-as-code technology to create your environments in the first place and you’ll find it’s very simple to spin them down again automatically outside of working hours. You can then fire them up again just before everyone starts work – automatically. Money potentially saved, emissions potentially reduced, and a whole class of business risks eliminated by avoiding hand-built environments that are all subtly and deviously different from one another.
Write efficient software
The code that you write can have an impact on emissions. Slow-running, inefficient code will take longer to run and potentially require more resources – indirectly bumping up those emissions.
Ensure your code is performance tested before being put into production. This will ensure that you understand how (or if) it scales and will help you catch issues before they start affecting customers. If you’re shipping code to production without understanding the impact it will have on performance, you need to think carefully about your ways of working.
There are many tools that will analyse your code for you to identify performance bottlenecks, and many tools that will help you automate performance and load tests as part of your pipelines so that you can spot this kind of stuff early. Again, this will potentially save you money in addition to being better for the planet – it’s a no brainer.
Respect the client
Inefficient client-side code – running in browsers and the like – can shorten battery life or demand more power from the grid, again leading to increased emissions. The impact from an individual perspective is tiny, but scaled out to all the machines across the world that are running code? It’s potentially huge.
The same principles as mentioned above apply – understand the performance profile of your code before you ship it. Respect the client – avoid doing lots of expensive computation on the main thread and prioritise user experience over everything else. You’ll find SEO benefits to that approach in addition to the planetary benefits.
Block the noise
As a user, a very simple way of protecting your computer from running swathes of unnecessary, invasive code on your machine is to use an ad blocker. Most modern websites are stuffed to the gills with tracking pixels, third party services and all kinds of other horrors. You’ll find that using an ad blocker not only makes your browsing experience noticeably faster, it also means your computer isn’t working so hard.
Good for you, good for the planet.
Not so good for marketers, but maybe the onus should be on them to find a better way of monetising things.