What problem does it solve?
Data organization problems, code smells, and repetitive data-handling patterns are transformed into structured, maintainable patterns using RefactoringGuru techniques.
Core Features & Use Cases
- Replace Magic Number with Constant: convert unexplained literals to named constants for clarity and maintainability.
- Encapsulate Collection: protect internal collections by returning copies or read-only views and provide mutator methods.
- Replace Type Code with Class / with State/Strategy: replace primitive codes with proper types or strategy/state objects to enable behavior polymorphism.
- Self Encapsulate Field / Encapsulate Field: enforce validation and invariants by routing field access through getters/setters.
- Replace Data Value with Object / Replace Array with Object: wrap primitive or grouped data into rich objects with behavior.
- Change Value to Reference / Change Reference to Value: switch between value and reference semantics to control identity and sharing.
- Replace Subclass with Fields: simplify class hierarchies by using data fields instead of subclass variations.
Quick Start
Apply the Replace Magic Number with Constant technique to replace hard-coded literals with named constants in a sample module.