Skip to content

Latest commit

 

History

History
18 lines (16 loc) · 549 Bytes

File metadata and controls

18 lines (16 loc) · 549 Bytes

Separate Query from Modifier

Why?

  • You have a method that returns a value but also changes something inside an object. This method implements Command and Query Responsibility Segregation. This principle tells us to separate code responsible for getting data from code that changes something inside an object.

Benefits:

  • The name is clear readable, understandable and easy to maintain.

What?

  • Change reference to value

How?

Sample

Before

After refactoring