Skip to content

Hand-written boilerplate a language feature writes (an __init__ that only stores its parameters) ​

Code nobody needs: one of the ways AI coding agents bloat software, from lessloc's pattern catalog. lessloc catches it as simpler.

What makes hand-written boilerplate a language feature writes a bad practice? ​

The standard that calls it a bad practice: PEP 557 (dataclasses).

What does lessloc do about hand-written boilerplate a language feature writes? ​

lessloc catches it as simpler.

  • simpler (tier 2): Brute-force code with a shorter idiom: == True, an if/else that returns the condition, an index loop that only reads xs[i], .filter(...).length > 0, a catch that only rethrows, a flag loop that is any(), a hand-built counter, an __init__ that @dataclass writes, a React Effect that only sets state. ruff and clippy add more.

Examples ​

Caught as simpler:

python
class Item:
    def __init__(self, name, price, qty):
        self.name = name
        self.price = price
        self.qty = qty

Written well:

python
from dataclasses import dataclass


@dataclass
class Item:
    name: str
    price: float
    qty: int

The other patterns in Code nobody needs:

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