A structured, teaching-oriented catalog of refactoring techniques implemented in Java.
This repository is inspired by Martin Fowlerβs Refactoring: Improving the Design of Existing Code (2nd Edition) and reimplements selected refactoring examples in Java.
Each refactoring technique follows a consistent structure:
src/
βββ main/
β βββ java/
β βββ com/example/
β βββ refactoring_method/
β βββ before/
β βββ after/
β
βββ test/
βββ java/
βββ com/example/
βββ refactoring_method/
βββ before/
βββ after/
Examples include (growing over time):
- Extract Function
- Inline Function
- Extract Variable / Introduce Explaining Variable
- Inline Variable / Inline Temp
- Change Function Declaration
- Encapsulate Variable / Self-Encapsulation / Encapsulate Field
- Rename Variable
- Introduce Parameter Object
- Split Phase
- Encapsulate Collection
- Replace Primitive with Object / Replace Data Value with Object / Replace Type Code with Class
- Replace Temp with Query
- Extract Class
- Inline Class
- Hide Delegate
- Remove Middle Man
- Substitute Algorithm
- Move Function
- Move Field
- Move Statement Into Function
- Move Statements to Callers
- Replace Inline Code with Function Call
- Slide Statement formerly Consolidate Duplicate Conditional Fragments
- Split Loop
- Replace Loop With Pipeline
This repository may be useful for:
- Students learning refactoring
- Teaching assistants preparing lab material
- Developers practicing safe code transformation
- Interview preparation for software design discussions
Martin Fowler
Refactoring: Improving the Design of Existing Code
Second Edition
This repository is an educational reinterpretation and is not a reproduction of the book.