the order of simplification steps
When you tidy a room you do it in the right order: take everything out, sort it, then put back only what you keep — if you scrub the floor before clearing the furniture you just have to scrub again. Grammar cleanup is the same: the simplification steps must run in a particular sequence, because each step can create the very kind of garbage the previous steps removed.
The standard order is: (1) remove epsilon-productions, (2) remove unit productions, (3) remove useless symbols, and within step 3, first remove non-generating symbols and only then remove unreachable symbols. The reasons are concrete. Epsilon-removal must come before unit-removal because eliminating an epsilon-production can create a fresh unit production: A -> BC with B nullable spawns A -> C, which is variable-to-variable. Unit-removal must come before useless-symbol removal because copying rules around and deleting renames can leave some variables non-generating or unreachable. And within useless-symbol removal, non-generating first, then unreachable, because deleting a dead-end variable can orphan another variable that was previously reachable only through it.
Following the right order means each cleanup needs only one pass and the final grammar is fully simplified: no empty rules, no rename-only rules, no dead weight, same language. Doing the steps out of order does not make the grammar wrong, but it can leave residue that forces you to loop back and repeat earlier steps. This sequence is the front half of converting a grammar to Chomsky normal form, which then adds two more shaping steps (replacing terminals inside long rules, and breaking long rules into binary ones).
Wrong order bites you: in S -> AB, A -> epsilon, B -> b, if you removed units first there are none, but epsilon-removal then produces S -> B, a NEW unit production you would have to clean in a second pass. Doing epsilon first, then units, then useless symbols, clears everything in one sweep each.
Epsilon, then units, then useless (non-generating before unreachable): each step would otherwise re-create the last's garbage.
The memorable rule of thumb is epsilon, unit, useless — in that order — and inside 'useless', generating before reachable. Skipping the order does not change the language but can leave the grammar not fully simplified.