· AI dev tools

Big List of Slop patterns, remedies for code that provides no value

A function that takes an integer and converts it to an i32, like let makei32 = |v| { v as i32 }; return optionalstring.map(|s| makei32(&s)), represents a pattern that can be considered "slop,"…


A function that takes an integer and converts it to an i32, like `let make_i32 = |v| { v as i32 }; return optional_string.map(|s| make_i32(&s))`, represents a pattern that can be considered "slop," though good code might employ it contextually. This tendency for LLMs to create and document constructs that are used only once mirrors a similar inclination in human development.

The concept of "slop"—code or writing that possesses statistical likelihood but imparts no genuine worth—is amplified today because large language models inherently produce a greater volume of this material than people do. Since I continue to examine source code, I have gathered examples of these substandard patterns encountered in real-world projects, along with suggested remedies for each. Given that this information resides on the internet, I have taken the liberty of assigning a ranking system to these examples. This scale assesses two dimensions: the degree of sloppiness, ranging from "maybe human" to "pure slop," and the severity of the issue, categorized as "meh, almost a nitpick," "hazardous," or "ticking time bomb."

Beginning with my preferred example, the MacGyver Class, this pattern resembles a modern evolution of the "Not Invented Here" syndrome blended with a god class. It elevates this concept by assembling common structural components into peculiar, low-level primitives that lack a discernible purpose and are exceedingly difficult to implement correctly or mold into something reusable. Consider this structure: `class LockableSocket: socket: socket.Socket lock: threading.Lock`. Regardless of the task at hand, the odds of someone needing to construct something reusable using merely a lock and a socket are practically nil. This is classified as slop, yet it often appears sufficiently polished to pass unnoticed if one is not specifically hunting for it. Furthermore, it risks generating challenging-to-detect bugs and can become permanently embedded within the codebase if others adopt it. The suggested remedy is this: while you might be developing services shaped like lockable-socket entities, if you are collaborating with others, it is far more probable that someone has already created such a component. If that is not the case, perhaps submit it under a different pull request? More frequently, these issues point toward a flaw in the overall design; address the design itself rather than documenting the lockable socket to assert its significance in microservice management.

Another example involves the inverse of parsing: failing to validate. The code performs preparatory work necessary for accuracy but neglects to embed the resulting state within the type system. For instance, imagine creating or reading a list that requires sorting. A typical sloppiness involves adding a check to confirm the list is indeed sorted: `def make_sorted_list(): return [1,2,4] +def validate_list_is_sorted(input): + assert sorted(input) == input data = make_sorted_list() +validate_list_is_sorted(data) bisect(data, 3)`. This is classic slop—it adds no inherent value, yet it is correct and would even catch faulty versions of `make_sorted_list`, which might explain why some test-driven development code appears this way. It is rated as "meh," meaning there are extra lines for readers to absorb and more tests to execute, and some edge cases might still slip through despite appearances. The recommended approach is to either eliminate the verification or employ a type that inherently guarantees the list's sorted nature, such as `struct SortedVec<T>(Vec<T>); fn make_sorted_list(...) -> SortedVec<u8> { ... } fn bisect(data: SortedVec<u8>, needle: u8) -> usize { ... }`. Similar instances include checking for an item's presence after inserting it into a dictionary, ensuring a list is not empty after adding an element, or trimming a string and subsequently verifying the new string possesses a specific length.

In earlier times, the Facade design pattern was notorious. Any procedure involving multiple steps could be wrapped within a Facade: `class Bar: ... class Foo: bar: Bar def make_bar() -> Bar: ... def make_foo(bar: Bar) -> Foo: ... # 'get_foo' is a facade. def get_foo() -> Foo: bar = make_bar() bar = bar.with_timeout(1) foo = make_foo(bar) foo.start() return foo`. Facades were almost always borderline-slop, but recent advancements in generating slop have pushed this boundary further. Consider the scenario where a refactoring means `Foo` no longer requires a `Bar`: `class Foo: - bar: Bar + baz: Baz`. The `make_bar` function becomes burdensome (🙄): it is referenced in tests, it remains part of `get_foo`, and `with_timeout` might introduce unforeseen side effects. The stance is often, "Best keep it." The test `def test_make_foo(): bar = make_bar() assert make_foo(bar) is not None` is rated as "meh," suggesting the unnecessary code hasn't caused major damage. The advisable action is to exfoliate; Facades are common, making them a frequent justification for retaining legacy code. Always verify if the component claiming to still require something is, itself, still necessary.

Testing practices also yield examples of slop. How does one determine which aspects warrant testing? While one can always devise an additional test to confirm the absence of an event, do these tests actually contribute value? For example, after defining `def sum(a, b): ...`, one might write `def test_sum(): with pytest.raises(ValueError, match="must be a number"): sum("1", None) assert sum(1, 2) != 5`. Even more extreme is testing for non-occurrences: `def validate_stuff() -> str: ... def test_validate_stuff(): assert "boogieman" not in validate_stuff()`. This pattern was popularized by LLMs, but since `Mock.assert_not_called` arrived in Python 3.5 (2014), pinpointing the originator of this trope is difficult. This is classified as "hazardous." The prescription here is that every test must yield tangible benefit; you are the stakeholder. Eliminate tests that fail to provide value. Pushing this paranoia further, one could test every single line of a function: `def do_request(): ... request_took_metric.observe(took_ms) logger.info("Request done.") def test_request(): do_request() assert request_took_metric.get_value() > 0 assert logger.called_with(level=INFO, message="Request done.")`. One might assume no sensible human or automated system would generate this, yet this represents an extreme form of Change-Detector Tests, treating TDD as if it were a Cold War scenario where Soviet agents are sabotaging the codebase. The treatment for this is identical to the previous point: discard it and move forward.

A subtle and more insidious variation on the established Dict Soup involves this: `# Party like it’s 2005. def foo(): return {"foo": 1} def foo_with_db(): return {"foo": 1, "db": ...}`. This has seen a resurgence, albeit in a less desirable form, acting as a side channel for anything too cumbersome to integrate into the "official" API: `# Party like it’s 2025. def foo_with_extra_stuff(idx: int, stuff: dict): return Foo(idx, db, stuff=stuff) def process_bar(bar: Bar) -> (int, dict): ... return 1, {"task_took_ms": now() - t0, "missed": ...}`. This is considered a severe issue, and there is a solid rationale for its decline. Avoid this construct at all costs; introducing it into production will lead to regret. The solution is simple: either proceed with it or omit it. If something holds importance, it ought to be typed, documented, and given due consideration; otherwise, it should be removed.

When seeking a word for two elements joined in the middle, a thesaurus or creative mind might suggest terms like Coupler, Junction, Nexus, or Conduit, all implying linkage, coupling, intertwining, intersection, unity, or attachment. However, `def connect(source, dest) -> Connection: ...` is likely the only truly appropriate term; consulting a thesaurus is unnecessary. What if the requirement demands a very specific connotation of "middle"? Then perhaps `def connect_mid(source, dest) -> MiddleConnection: ...`. Yet, frankly, unless there exists a non-middle connection as well, simply naming it Connection suffices. Brevity is preferable. This is rated as "hazardous" because it impedes human comprehension the most, thereby perpetuating a reliance on LLM-only edits. Similar to how older C programmers operated, newer LLM versions have been reinforced to use fewer tokens.

Consider the practice of shortening long identifiers, which has led to conventions like `import numpy as np # good, honorable, classy` versus `import json as j # evil, lazy, rowdy`. Unless an abbreviation is widely known and properly documented, always retain the complete name. Always. One cannot parse XML using a regular expression. Nevertheless, this failure to adhere to best practices has driven generations of beginners and LLMs to attempt it. Sometimes this involves simply extracting a value from a JSON string: `data = '{"name": "Bob"}' name = re.search(r'"name"\s*:\s*"([^"]*)"', data).group(1)`. More cunningly, it can involve ad hoc string escaping using `

Related coverage

Also worth reading

  1. next.js 16.6.0-canary.4 released, adding Go syntax highlighting and Node.js 24 unit tests
  2. TypeScript 7.1-rc released for developers to download on npm
  3. next.js 16.6.0-canary.2 released, adds file uploads, updates docs, and more
  4. next.js 16.6.0-canary.1 released with 405 for forbidden Route Handler methods
  5. Angular 21.2.27 released, fixes component template capture during compile