search
Get Started
search
Separate Query from Modifier - Jetbrains Native Refactoring
zoom_in Click to enlarge

Separate Query from Modifier

description Separate Query from Modifier Overview

Separate Query from Modifier is a refactoring based on the command-query separation principle. It applies when one method both returns information and changes program state, splitting those responsibilities into a query that supplies the value and a command that performs the modification. In JetBrains development environments, availability and exact behavior depend on the language, IDE, and code context.

help Separate Query from Modifier FAQ

What problem does Separate Query from Modifier solve?

It addresses a method that both returns information and changes program state. The refactoring splits that mixed responsibility into a query that supplies a value and a command that performs the change.

Which design principle is behind Separate Query from Modifier?

The refactoring is based on command-query separation. That principle keeps read operations separate from actions that modify program state.

What does the resulting query method do?

The query method returns the requested information without performing the state-changing action. The separate command method handles the modification, making each method's purpose easier to understand.

When should a developer use Separate Query from Modifier?

Use it when one method has surprising side effects because it changes state while also returning a result. Separating the two behaviors can make callers safer and tests easier to write.

Reviews & Comments

Write a Review

rate_review

Be the first to review

Share your thoughts with the community and help others make better decisions.

Save to your list

Save your favorites and follow how their scores change over time.

Save favorites
Track changes
Compare scores

Already have an account? Sign in

Compare Items

See how they stack up against each other

Comparing
VS
Select 1 more item to compare