Jump to the navigation menu

Having less code than you started with

When running commands like git log or viewing pull requests, you can see the number of lines that have been added, edited or removed.

When adding new features, it's likely you'll be adding code.

If you're refactoring code, you may have less code than before.

I like commits like this.

It's not true that having fewer lines of code means the code is better, but having less code makes it easier to maintain and more secure.

You don't need to upgrade and maintain code that you aren't using, so why not remove it?

Why have old TODO comments, dd(), var_dump() or console.log() functions in the code?

If they're not used, they can be removed.

I recently read a post that suggested there were 5 to 10 bugs in each 1,000 lines of production code as a general rule, so the less code there is, the fewer places there are for bugs to hide.

In general, for production code, less is more.

- Oliver

Was this interesting?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an Acquia-certified Drupal Triple Expert with 18 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.