SlideShare a Scribd company logo
Refactoring Games
15 things to do after Extract Method
VictorRentea.ro VictorRentea
Victor
Victor Rentea
Clean Code Evangelist
VictorRentea.ro
30+ talks, 12 meetups
.NET
Lead Architect
Tech Team Lead and Consultant
Software Craftsman
XP: Pair Programming, Refactoring, TDD
Java Champion
VictorRentea.ro @victorrentea victor.rentea@gmail.com
Independent
Technical Trainer & Coach
HibernateSpring Java 8
Architecture, DDDDesign Patterns
Clean Code Unit Testing, TDD
Java Performance more…Scala
200+ days1500 devs6 years
VictorRentea.rovictor.rentea@gmail.com
30 companies
Posting daily on
AlsoLive-Trainingon
➢ Largest 4 Java Meetups in Bucharest
Yearly, in Q2, at Bucharest Java User Group
➢ Meetups everywhere I travel to teach
Monthly 3-hours sessions, afterhours, throughout Europe: victorrentea.ro/#meetup
➢
Join for free: victorrentea.ro/community
125
Refactoring Games - 15 things to do after Extract Method
When you cannot find a satisfying name for a variable or a method,
choose a Welsh one.
You won't forget to change it later
- Mario Fusco
Rename
&
Extract Method
VictorRentea.ro
Extract Method
Selection
to Extract
variable
expression
Extract Variables
to generify/reuse
… then extract method
…then inline var back
Expand Selection
for less parameters
VictorRentea.ro
3. Ctrl-
2. Revert
1. Reader
Powers in Universe
Do you love switches?
VictorRentea.ro
A Clean Switch:
is the only instruction in a method
default: throw new
One-line per case
: return func();
: func(); break;
return switch
JEP 325: Switch Expressions
In Java 13… soon…
VictorRentea.ro
if (αααααα && βββββββ || γγγγγγγγ || ! δδδδδδδ)
Encapsulate Conditionals
if (α(..) && β(..) || γ(..) || ! δ(..))
if (αβ(..) || γδ(..))
Refactoring Games - 15 things to do after Extract Method
VictorRentea.ro
Feature Envy
method(α, …)
α.method(…)
“Move” refactor
“Keep Behavior next to State”[OOP]
VictorRentea.ro
Discover Value Objects
privateMethod(α, β)
SomeUtil.publicHelper(α, β)
VO vo = new VO(α, β);
vo.method();
General-purpose? Never mocked?
Always Strive To
Deepen
your Domain Language
VictorRentea.ro
How to refactor God Methods
of 500 lines ?
Extract Method Object refactor
138
Hint
A class should have less
than 200-300 lines
You make it a class
VictorRentea.ro
No side effects
Prefer returning over changing
Pure Functions
139
Same result for same inputs
no externals, time or Random
convertUser(user):UserDto
Refactoring Games - 15 things to do after Extract Method
VictorRentea.ro
bigScaryFunc(α, β) {
…😱…
}
Wrap Call
bigScaryFunc(α, β) {
stuffBefore();
bigScaryFunc__(α, β);
stuffAfter();
}
bigScaryFunc__(α, β) {
…😱…
}
VictorRentea.ro
No Boulean Parameters
VictorRentea.ro
1. Rename
2. Inline
3. Reorder Params
4. Remove Params by extracting more (with Ctrl-Z)
5. Distill switch expressions to Clean Switch Rules
6. Early return errors
7. Add parameters for reuse by extract/inline variable at call site (Ctrl-Z)
8. Move method to object (vs Feature Envy)
9. Encapsulate conditionals
10. Extract static Util functions
11. Spawn Value Objects to host extracted logic
12. Extract again - boolean vs SRP
13. Wrap call to “safely” add more code (Open-Closed Principle)
14. Extract Method Object for heavy logic
15. Extract Pure Functions
I'm available
a statement of seniority
I use both hemispheres
Tough meetings?
Abused estimates?
Purpose of code:--Uncle Bob
1. Maintainable
2. Does its job!
Functional Party
Activist
Stay into
The Light
Trainings, talks, goodies, Good stuff daily on:
Clean Code
needs strength
and determination
Thank You!
+
Join my community
Code: https://github.com/victorrentea/refactoring

More Related Content

PDF
Refactoring blockers and code smells @jNation 2021
PPTX
Functional Patterns with Java8 at Devoxx UK - Slides
PDF
The Proxy Fairy, and The Magic of Spring Framework
PDF
Clean pragmatic architecture @ devflix
PDF
Clean architecture - Protecting the Domain
PDF
Pure Functions and Immutable Objects
PDF
Hibernate and Spring - Unleash the Magic
PDF
Clean Lambdas & Streams in Java8
Refactoring blockers and code smells @jNation 2021
Functional Patterns with Java8 at Devoxx UK - Slides
The Proxy Fairy, and The Magic of Spring Framework
Clean pragmatic architecture @ devflix
Clean architecture - Protecting the Domain
Pure Functions and Immutable Objects
Hibernate and Spring - Unleash the Magic
Clean Lambdas & Streams in Java8

What's hot (20)

PPTX
Clean Code with Java 8 - Functional Patterns and Best Practices
PPTX
The Art of Clean code
PDF
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
PDF
Evolving a Clean, Pragmatic Architecture - A Craftsman's Guide
PDF
The Art of Unit Testing - Towards a Testable Design
PPTX
Clean Pragmatic Architecture - Avoiding a Monolith
PPTX
Clean Code
PDF
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
PPTX
Functional Patterns with Java8 @Bucharest Java User Group
PDF
Unit Testing like a Pro - The Circle of Purity
PDF
Don't Be Mocked by your Mocks - Best Practices using Mocks
PDF
Definitive Guide to Working With Exceptions in Java
PDF
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
PDF
Pure functions and immutable objects @dev nexus 2021
PDF
Integration testing with spring @snow one
PDF
Integration testing with spring @JAX Mainz
PDF
Pharo Optimising JIT Internals
PDF
FregeFX - JavaFX with Frege, a Haskell for the JVM
PDF
關於測試,我說的其實是......
PPT
Working Effectively With Legacy Code
Clean Code with Java 8 - Functional Patterns and Best Practices
The Art of Clean code
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
Evolving a Clean, Pragmatic Architecture - A Craftsman's Guide
The Art of Unit Testing - Towards a Testable Design
Clean Pragmatic Architecture - Avoiding a Monolith
Clean Code
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
Functional Patterns with Java8 @Bucharest Java User Group
Unit Testing like a Pro - The Circle of Purity
Don't Be Mocked by your Mocks - Best Practices using Mocks
Definitive Guide to Working With Exceptions in Java
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Pure functions and immutable objects @dev nexus 2021
Integration testing with spring @snow one
Integration testing with spring @JAX Mainz
Pharo Optimising JIT Internals
FregeFX - JavaFX with Frege, a Haskell for the JVM
關於測試,我說的其實是......
Working Effectively With Legacy Code
Ad

Similar to Refactoring Games - 15 things to do after Extract Method (16)

PPTX
Clean Code - The Next Chapter
PDF
Clean Code @Voxxed Days Cluj 2023 - opening Keynote
PDF
Refactoring
PPTX
Functional Programming Patterns with Java 8 (at Devoxx BE)
PPTX
Refactoring
PPT
Refactoring Tips by Martin Fowler
PDF
Modular and Extensible Extract Method. Talk from ESUG 2024
PDF
Legacy Coderetreat @Budapest 2013 02 16
PPTX
Vertical Slicing Architectures
PPTX
31 days Refactoring
PPTX
Refactoring
PDF
Martin Fowler's Refactoring Techniques Quick Reference
PPT
Refactoring - improving the smell of your code
PDF
TDD As If You Meant It
PDF
Bade Smells in Code
PDF
Refactoring
Clean Code - The Next Chapter
Clean Code @Voxxed Days Cluj 2023 - opening Keynote
Refactoring
Functional Programming Patterns with Java 8 (at Devoxx BE)
Refactoring
Refactoring Tips by Martin Fowler
Modular and Extensible Extract Method. Talk from ESUG 2024
Legacy Coderetreat @Budapest 2013 02 16
Vertical Slicing Architectures
31 days Refactoring
Refactoring
Martin Fowler's Refactoring Techniques Quick Reference
Refactoring - improving the smell of your code
TDD As If You Meant It
Bade Smells in Code
Refactoring
Ad

More from Victor Rentea (16)

PDF
Top REST API Desgin Pitfalls @ Devoxx 2024
PDF
The Joy of Testing - Deep Dive @ Devoxx Belgium 2024
PDF
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
PDF
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
PDF
Microservice Resilience Patterns @VoxxedCern'24
PDF
Distributed Consistency.pdf
PDF
Testing Microservices @DevoxxBE 23.pdf
PPTX
From Web to Flux @DevoxxBE 2023.pptx
PPTX
Test-Driven Design Insights@DevoxxBE 2023.pptx
PDF
Profiling your Java Application
PPTX
OAuth in the Wild
PPTX
The tests are trying to tell you something@VoxxedBucharest.pptx
PDF
Software Craftsmanship @Code Camp Festival 2022.pdf
PDF
Unit testing - 9 design hints
PPTX
Extreme Professionalism - Software Craftsmanship
PDF
TDD Mantra
Top REST API Desgin Pitfalls @ Devoxx 2024
The Joy of Testing - Deep Dive @ Devoxx Belgium 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Microservice Resilience Patterns @VoxxedCern'24
Distributed Consistency.pdf
Testing Microservices @DevoxxBE 23.pdf
From Web to Flux @DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptx
Profiling your Java Application
OAuth in the Wild
The tests are trying to tell you something@VoxxedBucharest.pptx
Software Craftsmanship @Code Camp Festival 2022.pdf
Unit testing - 9 design hints
Extreme Professionalism - Software Craftsmanship
TDD Mantra

Recently uploaded (20)

PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Essential Infomation Tech presentation.pptx
PPTX
L1 - Introduction to python Backend.pptx
PDF
medical staffing services at VALiNTRY
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
AI in Product Development-omnex systems
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
System and Network Administration Chapter 2
PDF
Nekopoi APK 2025 free lastest update
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Introduction to Artificial Intelligence
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
wealthsignaloriginal-com-DS-text-... (1).pdf
Essential Infomation Tech presentation.pptx
L1 - Introduction to python Backend.pptx
medical staffing services at VALiNTRY
2025 Textile ERP Trends: SAP, Odoo & Oracle
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
CHAPTER 2 - PM Management and IT Context
AI in Product Development-omnex systems
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
System and Network Administration Chapter 2
Nekopoi APK 2025 free lastest update
Operating system designcfffgfgggggggvggggggggg
Odoo POS Development Services by CandidRoot Solutions
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PTS Company Brochure 2025 (1).pdf.......
Introduction to Artificial Intelligence
Reimagine Home Health with the Power of Agentic AI​
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...

Refactoring Games - 15 things to do after Extract Method