Code Review Best Practices

Chapter 2 · Practice 3 of 6

Push back on code that is more complex than it needs to be

From What to look for in a review

Why it matters

Google's guide gives a useful definition: "too complex" usually means it cannot be understood quickly by code readers. It also means developers are likely to introduce bugs when they change it.

Watch for two kinds of complexity:

  • Hard to follow: long functions, deep nesting, clever one liners, unclear control flow
  • Over-engineering: code made more generic than it needs to be, or features added for problems the system does not have yet

The guide's advice on the second is direct: encourage developers to solve the problem they know needs solving now, not the problem they speculate might need solving later. Future problems can be solved when they arrive, with the information available then.

Do

  • Ask "what would be the simplest version of this that works?"

Avoid

  • Abstract base classes, plugin systems or options with a single user