Tech Tip #13: Clean code is greener code

Ordinary refactoring saves 10 to 30% energy, studies report.

Video created by explainapaper.com

The problem

Quality work is treated as a cost with no visible return. But the structures that make code hard to maintain, like repeated queries, recomputed values and stale dependencies, are often the ones that make it expensive to run.

The fix you can use today

  • Fund quality work (duplication, complexity, missing tests) as part of normal maintenance.
  • Track energy alongside quality metrics so the saving is visible.
  • Do quality first, then energy-specific optimisation.

Studies of code clean-ups report energy savings of 10 to 30%, before any energy work. GreenCode's climate case is built on this range.

Tools that help

  • GreenCode Constitution skill (GreenCode researchers): open-source energy principles and a catalogue of 37 energy anti-patterns that an AI coding agent can follow to find and fix waste like this
  • SonarQube: static analysis for code smells, bugs and security issues, with quality gates in CI
  • Green Metrics Tool: measures the energy of whole software scenarios run in containers, so runs can be repeated and compared

How GreenCode helps

GreenCode helps tackle this by checking a codebase for quality, security and green software patterns in one pass. Wasteful code comes out as a ranked defect, alongside the bugs and security findings. More on this.

Tags

#code-quality#refactoring#cost

Sources

Transcript

Ordinary code clean-ups save ten to thirty percent energy, studies report. Quality work often looks like a cost with nothing to show for it. But the things that make code hard to maintain also make it costly to run. Repeated queries. Values worked out again and again. Old, stale libraries. Messy code and wasteful code are often the same code. Here is the fix you can use today. Fund quality work as part of normal maintenance. Cut duplication and complexity, and add the missing tests. Track energy alongside your quality numbers, so the saving shows. Do the quality work first, then the energy-specific tuning. Studies of code clean-ups report energy savings of ten to thirty percent. That is before any energy work at all. GreenCode's climate case is built on this range. To find the waste, use tools like GreenCode's Constitution skill and SonarQube. Then the Green Metrics Tool measures the energy of whole software scenarios. GreenCode helps tackle this by checking quality, security and green patterns in one pass. Wasteful code comes out as a ranked defect, beside the bugs. That was GreenCode Tech Tip number thirteen. Follow for the next tip, and find more on greencode.ai/tech-tips.

All GreenCode Tech Tips · All GreenCode videos

  • Tip #13
  • For CTOs and technical leads
  • Length 1:19
  • Category Testing, CI and code quality
GreenCode

Want this checked on your own system? Talk to the GreenCode team.

Get in touch