Skip to content

If-chains on literal values ​

Code longer than it needs to be: one of the ways AI coding agents bloat software, from lessloc's pattern catalog. lessloc catches it as if-chain.

What makes if-chains on literal values a bad practice? ​

The standard that calls it a bad practice: Fowler: Repeated Switches.

What does lessloc do about if-chains on literal values? ​

lessloc catches it as if-chain.

  • if-chain (tier 2): Three or more if-branches on literal values of one variable, where a lookup table would do.

The other patterns in Code longer than it needs to be:

Released under the Apache-2.0 license. · llms.txt