Urgent.News

What's breaking now, across thousands of outlets.

Tech

Pin the Fault Matrix Before You Refactor a Messy Module

Pin the Fault Matrix Before You Refactor a Messy Module Consider an illustrative composite scenario rather than one specific incident, because the shape repeats across review threads. A service module grows past nine hundred lines, a coding agent returns a four hundred line refactor diff, and the existing suite turns green on the first run. The diff merges, and days later a partner integration…

The article emphasizes the importance of addressing the error surface before refactoring a module. In a composite scenario, a service module grows to 900 lines, a refactor diff reaches 400 lines, and the test suite initially passes. However, later integration fails due to a change in validation handling. The article argues that the first thing to change in a refactor is usually not the happy path, but the error surface, which includes exception types, error codes, and validation order. The key points are:

1. The error surface changes first in a refactor, unlike the happy path.

2. Happy paths are easy to observe and assert, while error paths require deliberate fault injection and are less pleasant to demonstrate.

3. Three patterns cause drift in the error surface:

- Type flattening: specific errors collapse into ValueError or Exception

- Code loss: the class stops carrying the code attribute

- Ordering drift: validation runs in a new sequence

4. To address this, enumerate every raise site as data using Python's standard library, specifically `ast.unparse` for versions 3.9 or newer.

5. Create a fault matrix with one row per fault class, asserting on the code column and treating prose as a secondary signal.

6. Record which layer raises the exception, as this helps detect when a layer is moved during refactoring.

7. Keep the matrix in version control alongside tests to make behavior changes reviewable.

The author stresses that the diff from a baseline raise site count to the post-refactor count tells you exactly which raises moved, appeared, or disappeared during the change. This process ensures a systematic approach to refactoring while maintaining error handling stability.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

How to Reply When You Can't Tell If Someone Is Upset in a Text

You get a short message: "fine." or "ok, whatever works." And now you're staring at your phone trying to work out whether the person is annoyed, tired, or just typing fast.

  • Separate message from personal interpretations to avoid negative assumptions
  • Use neutral responses that apply to all possible emotions
  • Keep replies concise, focused, and avoid escalating the situation

V+ (Vit Plus): l’ambiente “tutto incluso” che mette ordine in linting, formatting, test e workflow

Un solo CLI, un solo file di configurazione, strumenti coerenti tra loro: meno colla, meno tool scollegati, più velocità e standard condivisi.

  • V+ simplifies front-end project setup, configuration, and management
  • Single CLI with unified commands for project creation, linting, formatting, testing, and building
  • Utilizes Oxlint and Oxformat for superior performance and simplicity over ESLint and Prettier

Model Line Changeover as a State Machine So the Next SKU Cannot Start Before Clearance

By Isaac Muthui, CEO, Tamalaki Business Network Ltd. Originally published at factoraerp.com . If you build production or MES/ERP software for food manufacturers, here is a failure mode worth designing…

  • Model each production line with a state machine to prevent overlapping orders.
  • States include RUNNING, CLOSEDOUT, CLEANED, and CLEARED to ensure proper line clearance.

Processing and Completeness Are Different Problems

One verdict for two aspects keeps a closed task open forever. 👋 Hi, I'm Anton - a software engineer working mostly in PHP/Symfony and Go, currently carving a live PHP monolith into Go services.

  • Processing solved with 76/76 match and zero discrepancies
  • Completeness still waiting for missing data
  • Separate solutions required for processing and completeness

More from Thursday 15 October →