⚠️ LLM-generated content notice: Parts of this page may have been created or edited with the assistance of a large language model (LLM). The prompts that have been used might be on the page itself, the discussion page or in straight forward cases the prompt was just "Write a mediawiki page on X" with X being the page name. While the content has been reviewed it might still not be accurate or error-free.
Cleanliness is defined as:
Cleanliness = (Number of Valid Possible States) / (Total Possible States)
Higher cleanliness implies that the system design prevents invalid states by construction.
Cleanliness is defined as:
Cleanliness = (Number of Valid Possible States) / (Total Possible States)
Higher cleanliness implies that the system design prevents invalid states by construction.
enum OrderStatus { NEW, PROCESSING, SHIPPED, DELIVERED }
Workflow like: Draft → Submitted → Approved/Rejected.
Logger logger = new NullLogger(); // instead of null
public User(String email) {
if (!email.contains("@")) throw new IllegalArgumentException();
}
public class Account {
public double balance;
}
int status = 3; // 0 = new, 1 = processing, 2 = shipped
def update_profile(data): # "email must be present"
...
processFile(file, true, false, true);
| Example | Valid States | Total States | Cleanliness | Comment |
|---|---|---|---|---|
| Enum types | 4 | 4 | 1.0 | Clean |
| FSM | ~5 | ~5 | 1.0 | Clean |
| Null Object | 1 | 2 | 0.5 → 1.0 | Clean after pattern |
| Constructor checks | n | n | 1.0 | Clean |
| Mutable fields | ~100 | ∞ | ≪ 1 | Dirty |
| Int as enum | 3 | 2^32 | ≪ 1 | Dirty |
| Doc-only constraints | low | high | ≪ 1 | Dirty |
| Boolean flags | 3 | 8 | 0.375 | Dirty |
Traditional proof-based approaches assume:
In engineering terms:
Proof-based systems do not eliminate invalid runtime states:
| System | Total States | Valid States (in practice) | Cleanliness |
|---|---|---|---|
| Unbounded int stack | ∞ | bounded depth | ≈ 0 |
| Turing machine | ∞ | RAM-limited steps | ≈ 0 |
| Isabelle/HOL proofs | Symbolic | Execution-bounded | ≈ 0 |
The closer a system aligns its representational power to its runtime constraints, the cleaner it is. Proof-based systems optimize for expressiveness, inherently bloating the total possible state space and reducing cleanliness — by design.