liveBook · Manning

Hardcoding

As explained in Data-Oriented Programming in Java

Hard coding is embedding environment-specific values or infrastructure assumptions directly in application code.

Hardcoding embeds values or infrastructure assumptions directly in application or test code. In tests, shared helpers and fixed files hide inputs, create secret couplings, and make later changes brittle. section 11.4 section 12.2

Recognize hardcoding when:

  • A test depends on a file whose origin and meaningful values are unclear. section 12.2
  • An innocent update to shared data breaks many tests because their dependencies were never visible locally. section 11.4

Replace hidden fixtures with generated data

Instead of uploading a fixed CSV file, generate rows in the test, select the relevant subset, serialize the rows, and derive expected identifiers from that same data. This keeps inputs and assertions connected while allowing the test to scale from a few rows to millions.

How Data-Oriented Programming in Java covers it

How deep it goes
Diagnoses gradual coupling and demonstrates generation, parameterization, serialization, and randomization, stopping short of general application-configuration treatment.
Examples
Uses shared Account helpers, fixed CSV paths, generated rows, serialized files, and scalable Stream.generate datasets.
What you can do after
Diagnose brittle tests and replace hidden fixtures or files with parameterized, generated data whose assertions reflect explicit inputs.
How it connects
Connects hardcoding with test suites, test data, fixtures, integration testing, randomization, and data-oriented testing.

Also explained in

Compare how 2 books explain hardcoding →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming in Java. The section links point to the parts of the book it draws on.