Skip to content
aipatterns.dev

Refactoring techniques

Small transformations that change structure, not behavior. Each one has before and after code, steps that keep tests green, and a note on when to leave it alone. Start from a code smell if you don't know which one you need.
View as Markdown

Techniques that split, merge and reshape method bodies so each method does one readable thing and local variables stop blocking change.

Techniques that relocate methods, fields and whole classes so each responsibility lives next to the data it uses.

Organizing Data

15 entries

Techniques that turn raw fields, magic values, arrays and type codes into objects and types that carry meaning and protect their own invariants.

Techniques that flatten, name, merge and replace conditionals so branching logic reads as a list of plain decisions.

Techniques that clean up method signatures, names, parameters and error signaling so interfaces are hard to call incorrectly.

Techniques that move members up and down class hierarchies, create or collapse hierarchies, and swap inheritance for delegation.