SlideShare a Scribd company logo
Balša Šarenac, Stéphane Ducasse, Guillermo Polito and Gordana Rakić
An Analysis of Inline Method
Refactoring
1
Evref
fervE
Introduction
‣ Refactoring
‣ Composition
‣ Inline Method
‣ Source method
‣ Inline method
2
Goals
‣ Enable users to de
fi
ne their own refactorings
‣ Redesign existing refactorings into modular de
fi
nitions
3
Inline method example
4
breakingChangePreconditions
^ { (RBCondition withBlock: [
self
fi
ndReceiverNode.
true ]) }
breakingChangePreconditions
^ { (RBCondition withBlock: [
| receiverNodes |
receiverNodes := statementNodes collect: [ :each | each receiver ].
receiverNodes asSet size = 1 ifFalse: [
self refactoringError: 'All statements must have the same receiver' ].
(receiverNodes
fi
rst isLiteralNode or: [ receiverNodes
fi
rst isVariable ]) ifFalse: [
self refactoringWarning: 'The receiver is an expression. Proceed with caution' ].
true ]) }
Contributions
‣ Analysis of the existing Inline Method refactoring monolithic implementation.
‣ Reuse and extension of the Inline Method refactoring modular logic to de
fi
ne
domain-speci
fi
c refactoring:
‣ Inline Method with Pragma refactoring for Slang (virtual machine generator).
5
Legacy implementation
Pros and cons of legacy implementation
‣ Pros:
‣ Mostly correct implementation
‣ Correct precondition logic
‣ Cons:
‣ Mixed calculations, precondition
checking and transformation setup
logic
‣ Mixed transformation logic and user
interaction
‣ Monolithic implementation
6
Analysis
Canonicalization
‣ Transforming the inline method’s source code into a state that is inlinable.
‣ Adding a return if it is not already explicitly de
fi
ned,
‣ Transforming guard clauses into if/else blocks (for example, ifTrue:ifFalse: in
the case of Pharo),
‣ Transform ifTrue: and ifFalse: into ifTrue:ifFalse:,
‣ Removing non-local returns.
7
Analysis
Canonicalization
8
Before canonization After canonization
ifNotEmpty:
Analysis
Cascades
• Right now handled using ifs
• Only supports inlining the last message from the cascade
• Makes the code very hard to change
9
New architecture
‣ Prepare for execution
‣ Precondition checking
‣ Transformation
10
11
Current flow
‣ Inline Method refactoring:
1. Check preconditions
2. Canonize the inline method,
3. Handle cascades and returns (+ more canonization),
4. Replace argument variables with values,
5. Substitute the message send with the inline method,
6. Remove dead code: empty and immediate blocks.
12
Preprocessing
Preconditions
Transformations
Can we make this composite?
‣ Inline Method refactoring:
1. Canonize the inline method,
2. Check preconditions
3. Handle cascades and returns
4. Rename con
fl
icting temporaries
5. Replace argument variables with values,
6. Substitute the message send with the inline method,
7. Remove dead code, empty and immediate blocks.
13
Preprocessing
Preconditions
Transformations
Specialization
Can we make this composite?
‣ Inline Method refactoring:
1. Canonize the method to be inlined,
2. Check preconditions
3. Rename con
fl
icting temporaries
4. Replace argument variables with values,
5. Substitute the message send with the inline method,
6. Remove dead code, empty and immediate blocks.
14
Preprocessing
Preconditions
Transformations
Transformation - Preprocessing
Transforming
Cleanup
Can we make this composite?
‣ Inline Method refactoring:
1. Canonize the method to be inlined (from transformation),
2. Check preconditions,
1. Inlining overridden methods,
2. Inlining bigger methods that will add statements before the target
message.
3. Inlining methods that send overridden super messages
3. Inline method transformation.
15
Preprocessing
Preconditions
Transformations
16
Comparison to Extract Method?
17
What do we do with method with Pragma
18
ExampleClass >> m
<var: ‘a’ declareC: ‘int’>
| a |
a := 1 + 3.
^ a * self calculation
ExampleClass >> m
| a |
a := self exampleMethod.
^ a * self calculation
ExampleClass >> exampleMethod
<var: ‘c’ declareC: ‘int’>
| c |
c := 1 + 3.
^ c
Inline with pragma composite
‣ Inline Method with pragma refactoring:
1. Canonize the method to be inlined,
2. Check preconditions,
3. Handle pragmas,
4. Inline method transformation.
19
Preprocessing
Preconditions
Transformations
Conclusion
• Challenges when implementing the Inline Method in Pharo
• Leverage Decorator and Specialization to simplify Inline Method
• Inline Method with Pragma domain speci
fi
c refactoring
20

More Related Content

PDF
Inside AOStA
PDF
Code Refactoring
PDF
Modular and Extensible Extract Method. Talk from ESUG 2024
PDF
C++ How to Program 10th Edition Deitel Solutions Manual
PPT
principles of object oriented class design
PPTX
Java script – basic auroskills (2)
PDF
C++ How to Program 10th Edition Deitel Solutions Manual
PPTX
JAVA in Artificial intelligent
Inside AOStA
Code Refactoring
Modular and Extensible Extract Method. Talk from ESUG 2024
C++ How to Program 10th Edition Deitel Solutions Manual
principles of object oriented class design
Java script – basic auroskills (2)
C++ How to Program 10th Edition Deitel Solutions Manual
JAVA in Artificial intelligent

Similar to An Analysis of Inline Method Refactoring (20)

PPTX
java in Aartificial intelligent by virat andodariya
PDF
C++ How to Program 10th Edition Deitel Solutions Manual
PDF
Building an API for EHR integration at scale
PPT
Control statements in Java Programming Language
PPT
presentationpower point _chapter_04.ppt
PPT
SFSDFSdfsdfsdhfhSDIUFBSDIUSDBFIUSHFDJFBSUIDdas
PPT
Pptchapter04
PPT
Ppt chapter04
ODP
Refactoring: Improving the design of existing code
PDF
The Art of Refactoring | Asmit Ghimire | Gurzu.pdf
PDF
Java 8 - A step closer to Parallelism
PDF
New York Kubernetes: CI/CD Patterns for Kubernetes
PPTX
JAVA programming language made easy.pptx
PDF
TDD with PhpSpec - Lone Star PHP 2016
PPT
9781305078444 ppt ch03
PPTX
Java basics-includes java classes, methods ,OOPs concepts
PPTX
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
PDF
Commonly used design patterns
java in Aartificial intelligent by virat andodariya
C++ How to Program 10th Edition Deitel Solutions Manual
Building an API for EHR integration at scale
Control statements in Java Programming Language
presentationpower point _chapter_04.ppt
SFSDFSdfsdfsdhfhSDIUFBSDIUSDBFIUSHFDJFBSUIDdas
Pptchapter04
Ppt chapter04
Refactoring: Improving the design of existing code
The Art of Refactoring | Asmit Ghimire | Gurzu.pdf
Java 8 - A step closer to Parallelism
New York Kubernetes: CI/CD Patterns for Kubernetes
JAVA programming language made easy.pptx
TDD with PhpSpec - Lone Star PHP 2016
9781305078444 ppt ch03
Java basics-includes java classes, methods ,OOPs concepts
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Commonly used design patterns
Ad

More from ESUG (20)

PDF
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
PDF
Micromaid: A simple Mermaid-like chart generator for Pharo
PDF
Directing Generative AI for Pharo Documentation
PDF
Even Lighter Than Lightweiht: Augmenting Type Inference with Primitive Heuris...
PDF
Composing and Performing Electronic Music on-the-Fly with Pharo and Coypu
PDF
Gamifying Agent-Based Models in Cormas: Towards the Playable Architecture for...
PDF
Analysing Python Machine Learning Notebooks with Moose
PDF
FASTTypeScript metamodel generation using FAST traits and TreeSitter project
PDF
Migrating Katalon Studio Tests to Playwright with Model Driven Engineering
PDF
Package-Aware Approach for Repository-Level Code Completion in Pharo
PDF
Evaluating Benchmark Quality: a Mutation-Testing- Based Methodology
PDF
Identification of unnecessary object allocations using static escape analysis
PDF
Control flow-sensitive optimizations In the Druid Meta-Compiler
PDF
Clean Blocks (IWST 2025, Gdansk, Poland)
PDF
Encoding for Objects Matters (IWST 2025)
PDF
Challenges of Transpiling Smalltalk to JavaScript
PDF
Immersive experiences: what Pharo users do!
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
PDF
Cavrois - an Organic Window Management (ESUG 2025)
PDF
Fluid Class Definitions in Pharo (ESUG 2025)
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
Micromaid: A simple Mermaid-like chart generator for Pharo
Directing Generative AI for Pharo Documentation
Even Lighter Than Lightweiht: Augmenting Type Inference with Primitive Heuris...
Composing and Performing Electronic Music on-the-Fly with Pharo and Coypu
Gamifying Agent-Based Models in Cormas: Towards the Playable Architecture for...
Analysing Python Machine Learning Notebooks with Moose
FASTTypeScript metamodel generation using FAST traits and TreeSitter project
Migrating Katalon Studio Tests to Playwright with Model Driven Engineering
Package-Aware Approach for Repository-Level Code Completion in Pharo
Evaluating Benchmark Quality: a Mutation-Testing- Based Methodology
Identification of unnecessary object allocations using static escape analysis
Control flow-sensitive optimizations In the Druid Meta-Compiler
Clean Blocks (IWST 2025, Gdansk, Poland)
Encoding for Objects Matters (IWST 2025)
Challenges of Transpiling Smalltalk to JavaScript
Immersive experiences: what Pharo users do!
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
Cavrois - an Organic Window Management (ESUG 2025)
Fluid Class Definitions in Pharo (ESUG 2025)
Ad

Recently uploaded (20)

PDF
bbec55_b34400a7914c42429908233dbd381773.pdf
PPTX
famous lake in india and its disturibution and importance
PPTX
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
PPTX
Comparative Structure of Integument in Vertebrates.pptx
PDF
An interstellar mission to test astrophysical black holes
PPTX
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
PDF
Mastering Bioreactors and Media Sterilization: A Complete Guide to Sterile Fe...
PPTX
TOTAL hIP ARTHROPLASTY Presentation.pptx
PPTX
ANEMIA WITH LEUKOPENIA MDS 07_25.pptx htggtftgt fredrctvg
PDF
Formation of Supersonic Turbulence in the Primordial Star-forming Cloud
PDF
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
PPT
protein biochemistry.ppt for university classes
PPTX
Taita Taveta Laboratory Technician Workshop Presentation.pptx
PDF
. Radiology Case Scenariosssssssssssssss
PPTX
Introduction to Fisheries Biotechnology_Lesson 1.pptx
PPTX
neck nodes and dissection types and lymph nodes levels
PDF
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
PDF
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
PPTX
2. Earth - The Living Planet Module 2ELS
PDF
AlphaEarth Foundations and the Satellite Embedding dataset
bbec55_b34400a7914c42429908233dbd381773.pdf
famous lake in india and its disturibution and importance
G5Q1W8 PPT SCIENCE.pptx 2025-2026 GRADE 5
Comparative Structure of Integument in Vertebrates.pptx
An interstellar mission to test astrophysical black holes
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
Mastering Bioreactors and Media Sterilization: A Complete Guide to Sterile Fe...
TOTAL hIP ARTHROPLASTY Presentation.pptx
ANEMIA WITH LEUKOPENIA MDS 07_25.pptx htggtftgt fredrctvg
Formation of Supersonic Turbulence in the Primordial Star-forming Cloud
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
protein biochemistry.ppt for university classes
Taita Taveta Laboratory Technician Workshop Presentation.pptx
. Radiology Case Scenariosssssssssssssss
Introduction to Fisheries Biotechnology_Lesson 1.pptx
neck nodes and dissection types and lymph nodes levels
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
2. Earth - The Living Planet Module 2ELS
AlphaEarth Foundations and the Satellite Embedding dataset

An Analysis of Inline Method Refactoring

  • 1. Balša Šarenac, Stéphane Ducasse, Guillermo Polito and Gordana Rakić An Analysis of Inline Method Refactoring 1 Evref fervE
  • 2. Introduction ‣ Refactoring ‣ Composition ‣ Inline Method ‣ Source method ‣ Inline method 2
  • 3. Goals ‣ Enable users to de fi ne their own refactorings ‣ Redesign existing refactorings into modular de fi nitions 3
  • 4. Inline method example 4 breakingChangePreconditions ^ { (RBCondition withBlock: [ self fi ndReceiverNode. true ]) } breakingChangePreconditions ^ { (RBCondition withBlock: [ | receiverNodes | receiverNodes := statementNodes collect: [ :each | each receiver ]. receiverNodes asSet size = 1 ifFalse: [ self refactoringError: 'All statements must have the same receiver' ]. (receiverNodes fi rst isLiteralNode or: [ receiverNodes fi rst isVariable ]) ifFalse: [ self refactoringWarning: 'The receiver is an expression. Proceed with caution' ]. true ]) }
  • 5. Contributions ‣ Analysis of the existing Inline Method refactoring monolithic implementation. ‣ Reuse and extension of the Inline Method refactoring modular logic to de fi ne domain-speci fi c refactoring: ‣ Inline Method with Pragma refactoring for Slang (virtual machine generator). 5
  • 6. Legacy implementation Pros and cons of legacy implementation ‣ Pros: ‣ Mostly correct implementation ‣ Correct precondition logic ‣ Cons: ‣ Mixed calculations, precondition checking and transformation setup logic ‣ Mixed transformation logic and user interaction ‣ Monolithic implementation 6
  • 7. Analysis Canonicalization ‣ Transforming the inline method’s source code into a state that is inlinable. ‣ Adding a return if it is not already explicitly de fi ned, ‣ Transforming guard clauses into if/else blocks (for example, ifTrue:ifFalse: in the case of Pharo), ‣ Transform ifTrue: and ifFalse: into ifTrue:ifFalse:, ‣ Removing non-local returns. 7
  • 9. Analysis Cascades • Right now handled using ifs • Only supports inlining the last message from the cascade • Makes the code very hard to change 9
  • 10. New architecture ‣ Prepare for execution ‣ Precondition checking ‣ Transformation 10
  • 11. 11
  • 12. Current flow ‣ Inline Method refactoring: 1. Check preconditions 2. Canonize the inline method, 3. Handle cascades and returns (+ more canonization), 4. Replace argument variables with values, 5. Substitute the message send with the inline method, 6. Remove dead code: empty and immediate blocks. 12 Preprocessing Preconditions Transformations
  • 13. Can we make this composite? ‣ Inline Method refactoring: 1. Canonize the inline method, 2. Check preconditions 3. Handle cascades and returns 4. Rename con fl icting temporaries 5. Replace argument variables with values, 6. Substitute the message send with the inline method, 7. Remove dead code, empty and immediate blocks. 13 Preprocessing Preconditions Transformations Specialization
  • 14. Can we make this composite? ‣ Inline Method refactoring: 1. Canonize the method to be inlined, 2. Check preconditions 3. Rename con fl icting temporaries 4. Replace argument variables with values, 5. Substitute the message send with the inline method, 6. Remove dead code, empty and immediate blocks. 14 Preprocessing Preconditions Transformations Transformation - Preprocessing Transforming Cleanup
  • 15. Can we make this composite? ‣ Inline Method refactoring: 1. Canonize the method to be inlined (from transformation), 2. Check preconditions, 1. Inlining overridden methods, 2. Inlining bigger methods that will add statements before the target message. 3. Inlining methods that send overridden super messages 3. Inline method transformation. 15 Preprocessing Preconditions Transformations
  • 16. 16
  • 17. Comparison to Extract Method? 17
  • 18. What do we do with method with Pragma 18 ExampleClass >> m <var: ‘a’ declareC: ‘int’> | a | a := 1 + 3. ^ a * self calculation ExampleClass >> m | a | a := self exampleMethod. ^ a * self calculation ExampleClass >> exampleMethod <var: ‘c’ declareC: ‘int’> | c | c := 1 + 3. ^ c
  • 19. Inline with pragma composite ‣ Inline Method with pragma refactoring: 1. Canonize the method to be inlined, 2. Check preconditions, 3. Handle pragmas, 4. Inline method transformation. 19 Preprocessing Preconditions Transformations
  • 20. Conclusion • Challenges when implementing the Inline Method in Pharo • Leverage Decorator and Specialization to simplify Inline Method • Inline Method with Pragma domain speci fi c refactoring 20