Skip to content
aipatterns.dev

Category

Composing Methods

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

What these techniques solve

Most refactoring starts inside a single function. Long bodies, temporary variables that hold three different things, and parameters reassigned halfway down make code hard to read and hard to move. These techniques work at that level: they change how a method is cut into pieces without changing what it does.

Use them first. Clean method boundaries are what make every other refactoring possible.

Members

How to choose within this category

Watch performance claims: replacing a temp with a query repeats the computation. That rarely matters, but measure in hot loops.

See also

Original writing and examples. Topic coverage follows Refactoring.Guru, which explains this topic with its own illustrations.