Submit Search
Upload
Refactoring
ā¢
3 likes
ā¢
1,008 views
Marcus Denker
Follow
Lecture: "Refactoring", Hasso Plattner Institute, Potsdam / Germany, 20.11.2007
Read less
Read more
Technology
Report
Share
Report
Share
1 of 40
Download now
Download to read offline
Recommended
Reactive Microservices with JRuby and Docker
Reactive Microservices with JRuby and Docker
John Scattergood
Ā
Fighting Spam With A Perimeter Mail System 20071108 Sasag
Fighting Spam With A Perimeter Mail System 20071108 Sasag
garrett honeycutt
Ā
Dynomite at Erlang Factory
Dynomite at Erlang Factory
moonpolysoft
Ā
Lab3 advanced port scanning 30 oct 21
Lab3 advanced port scanning 30 oct 21
Hussain111321
Ā
2013 london advanced-replication
2013 london advanced-replication
Marc Schwering
Ā
×צ××Ŗ ×××× ××Ŗ
×צ××Ŗ ×××× ××Ŗ
pisga
Ā
Laura Seeger Portfolio
Laura Seeger Portfolio
Laura Seeger
Ā
××Øׄ ×ש×Ø××
××Øׄ ×ש×Ø××
safa brura
Ā
Recommended
Reactive Microservices with JRuby and Docker
Reactive Microservices with JRuby and Docker
John Scattergood
Ā
Fighting Spam With A Perimeter Mail System 20071108 Sasag
Fighting Spam With A Perimeter Mail System 20071108 Sasag
garrett honeycutt
Ā
Dynomite at Erlang Factory
Dynomite at Erlang Factory
moonpolysoft
Ā
Lab3 advanced port scanning 30 oct 21
Lab3 advanced port scanning 30 oct 21
Hussain111321
Ā
2013 london advanced-replication
2013 london advanced-replication
Marc Schwering
Ā
×צ××Ŗ ×××× ××Ŗ
×צ××Ŗ ×××× ××Ŗ
pisga
Ā
Laura Seeger Portfolio
Laura Seeger Portfolio
Laura Seeger
Ā
××Øׄ ×ש×Ø××
××Øׄ ×ש×Ø××
safa brura
Ā
Some thoughts on success
Some thoughts on success
Rajit Desai
Ā
×§× ×צ×פ××Ø
×§× ×צ×פ××Ø
Hadas Shamir
Ā
Talk: An Instrument whose Music is Ideas
Talk: An Instrument whose Music is Ideas
Marcus Denker
Ā
Pharo3 at Fosdem
Pharo3 at Fosdem
Marcus Denker
Ā
Pharo: Syntax in a Nutshell
Pharo: Syntax in a Nutshell
Marcus Denker
Ā
Lecture: Reflection
Lecture: Reflection
Marcus Denker
Ā
×צ××Ŗ ×ש××Ø× ×צ××××Ø
×צ××Ŗ ×ש××Ø× ×צ××××Ø
moshfeu
Ā
Reflection
Reflection
Marcus Denker
Ā
Lecture: Reflection
Lecture: Reflection
Marcus Denker
Ā
Beyond Text - Methods as Objects
Beyond Text - Methods as Objects
Marcus Denker
Ā
Reflectivity Demo
Reflectivity Demo
Marcus Denker
Ā
Reflection and Context
Reflection and Context
Marcus Denker
Ā
Unanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral Reflection
ESUG
Ā
Lecture: Refactoring
Lecture: Refactoring
Marcus Denker
Ā
08 refactoring
08 refactoring
The World of Smalltalk
Ā
Unanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral Reflection
Marcus Denker
Ā
Stoop 305-reflective programming5
Stoop 305-reflective programming5
The World of Smalltalk
Ā
Sub-Method Reflection
Sub-Method Reflection
Marcus Denker
Ā
Demo: Reflectivity
Demo: Reflectivity
Marcus Denker
Ā
The Reflectivity
The Reflectivity
ESUG
Ā
Code Refactoring
Code Refactoring
kim.mens
Ā
Sub-method Structural and Behavioral Reflection
Sub-method Structural and Behavioral Reflection
Marcus Denker
Ā
More Related Content
Viewers also liked
Some thoughts on success
Some thoughts on success
Rajit Desai
Ā
×§× ×צ×פ××Ø
×§× ×צ×פ××Ø
Hadas Shamir
Ā
Talk: An Instrument whose Music is Ideas
Talk: An Instrument whose Music is Ideas
Marcus Denker
Ā
Pharo3 at Fosdem
Pharo3 at Fosdem
Marcus Denker
Ā
Pharo: Syntax in a Nutshell
Pharo: Syntax in a Nutshell
Marcus Denker
Ā
Lecture: Reflection
Lecture: Reflection
Marcus Denker
Ā
×צ××Ŗ ×ש××Ø× ×צ××××Ø
×צ××Ŗ ×ש××Ø× ×צ××××Ø
moshfeu
Ā
Viewers also liked
(7)
Some thoughts on success
Some thoughts on success
Ā
×§× ×צ×פ××Ø
×§× ×צ×פ××Ø
Ā
Talk: An Instrument whose Music is Ideas
Talk: An Instrument whose Music is Ideas
Ā
Pharo3 at Fosdem
Pharo3 at Fosdem
Ā
Pharo: Syntax in a Nutshell
Pharo: Syntax in a Nutshell
Ā
Lecture: Reflection
Lecture: Reflection
Ā
×צ××Ŗ ×ש××Ø× ×צ××××Ø
×צ××Ŗ ×ש××Ø× ×צ××××Ø
Ā
Similar to Refactoring
Reflection
Reflection
Marcus Denker
Ā
Lecture: Reflection
Lecture: Reflection
Marcus Denker
Ā
Beyond Text - Methods as Objects
Beyond Text - Methods as Objects
Marcus Denker
Ā
Reflectivity Demo
Reflectivity Demo
Marcus Denker
Ā
Reflection and Context
Reflection and Context
Marcus Denker
Ā
Unanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral Reflection
ESUG
Ā
Lecture: Refactoring
Lecture: Refactoring
Marcus Denker
Ā
08 refactoring
08 refactoring
The World of Smalltalk
Ā
Unanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral Reflection
Marcus Denker
Ā
Stoop 305-reflective programming5
Stoop 305-reflective programming5
The World of Smalltalk
Ā
Sub-Method Reflection
Sub-Method Reflection
Marcus Denker
Ā
Demo: Reflectivity
Demo: Reflectivity
Marcus Denker
Ā
The Reflectivity
The Reflectivity
ESUG
Ā
Code Refactoring
Code Refactoring
kim.mens
Ā
Sub-method Structural and Behavioral Reflection
Sub-method Structural and Behavioral Reflection
Marcus Denker
Ā
Webinar: Migrating from RDBMS to MongoDB (June 2015)
Webinar: Migrating from RDBMS to MongoDB (June 2015)
MongoDB
Ā
Talk: Practical, Pluggable Types
Talk: Practical, Pluggable Types
Marcus Denker
Ā
Presentation about my Research
Presentation about my Research
Marcus Denker
Ā
Unstuck
Unstuck
Marcus Denker
Ā
Behavioral Reflection
Behavioral Reflection
Marcus Denker
Ā
Similar to Refactoring
(20)
Reflection
Reflection
Ā
Lecture: Reflection
Lecture: Reflection
Ā
Beyond Text - Methods as Objects
Beyond Text - Methods as Objects
Ā
Reflectivity Demo
Reflectivity Demo
Ā
Reflection and Context
Reflection and Context
Ā
Unanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral Reflection
Ā
Lecture: Refactoring
Lecture: Refactoring
Ā
08 refactoring
08 refactoring
Ā
Unanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral Reflection
Ā
Stoop 305-reflective programming5
Stoop 305-reflective programming5
Ā
Sub-Method Reflection
Sub-Method Reflection
Ā
Demo: Reflectivity
Demo: Reflectivity
Ā
The Reflectivity
The Reflectivity
Ā
Code Refactoring
Code Refactoring
Ā
Sub-method Structural and Behavioral Reflection
Sub-method Structural and Behavioral Reflection
Ā
Webinar: Migrating from RDBMS to MongoDB (June 2015)
Webinar: Migrating from RDBMS to MongoDB (June 2015)
Ā
Talk: Practical, Pluggable Types
Talk: Practical, Pluggable Types
Ā
Presentation about my Research
Presentation about my Research
Ā
Unstuck
Unstuck
Ā
Behavioral Reflection
Behavioral Reflection
Ā
More from Marcus Denker
Soil And Pharo
Soil And Pharo
Marcus Denker
Ā
ConstantBlocks in Pharo11
ConstantBlocks in Pharo11
Marcus Denker
Ā
Demo: Improved DoIt
Demo: Improved DoIt
Marcus Denker
Ā
First Class Variables as AST Annotations
First Class Variables as AST Annotations
Marcus Denker
Ā
Supporting Pharo / Getting Pharo Support
Supporting Pharo / Getting Pharo Support
Marcus Denker
Ā
Lecture: "Advanced Reflection: MetaLinks"
Lecture: "Advanced Reflection: MetaLinks"
Marcus Denker
Ā
thisContext in the Debugger
thisContext in the Debugger
Marcus Denker
Ā
Variables in Pharo
Variables in Pharo
Marcus Denker
Ā
Lecture. Advanced Reflection: MetaLinks
Lecture. Advanced Reflection: MetaLinks
Marcus Denker
Ā
Improving code completion for Pharo
Improving code completion for Pharo
Marcus Denker
Ā
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
Marcus Denker
Ā
Slot Composition
Slot Composition
Marcus Denker
Ā
Lecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinks
Marcus Denker
Ā
PHARO IOT
PHARO IOT
Marcus Denker
Ā
Open-Source: An Infinite Game
Open-Source: An Infinite Game
Marcus Denker
Ā
Lecture: MetaLinks
Lecture: MetaLinks
Marcus Denker
Ā
PharoTechTalk: Contributing to Pharo
PharoTechTalk: Contributing to Pharo
Marcus Denker
Ā
Feedback Loops in Practice
Feedback Loops in Practice
Marcus Denker
Ā
Pharo6 - ESUG17
Pharo6 - ESUG17
Marcus Denker
Ā
Pharo6
Pharo6
Marcus Denker
Ā
More from Marcus Denker
(20)
Soil And Pharo
Soil And Pharo
Ā
ConstantBlocks in Pharo11
ConstantBlocks in Pharo11
Ā
Demo: Improved DoIt
Demo: Improved DoIt
Ā
First Class Variables as AST Annotations
First Class Variables as AST Annotations
Ā
Supporting Pharo / Getting Pharo Support
Supporting Pharo / Getting Pharo Support
Ā
Lecture: "Advanced Reflection: MetaLinks"
Lecture: "Advanced Reflection: MetaLinks"
Ā
thisContext in the Debugger
thisContext in the Debugger
Ā
Variables in Pharo
Variables in Pharo
Ā
Lecture. Advanced Reflection: MetaLinks
Lecture. Advanced Reflection: MetaLinks
Ā
Improving code completion for Pharo
Improving code completion for Pharo
Ā
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
Ā
Slot Composition
Slot Composition
Ā
Lecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinks
Ā
PHARO IOT
PHARO IOT
Ā
Open-Source: An Infinite Game
Open-Source: An Infinite Game
Ā
Lecture: MetaLinks
Lecture: MetaLinks
Ā
PharoTechTalk: Contributing to Pharo
PharoTechTalk: Contributing to Pharo
Ā
Feedback Loops in Practice
Feedback Loops in Practice
Ā
Pharo6 - ESUG17
Pharo6 - ESUG17
Ā
Pharo6
Pharo6
Ā
Recently uploaded
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Anna Loughnan Colquhoun
Ā
š¬ The future of MySQL is Postgres š
š¬ The future of MySQL is Postgres š
RTylerCroy
Ā
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
HampshireHUG
Ā
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
sudhanshuwaghmare1
Ā
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
The Digital Insurer
Ā
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
naman860154
Ā
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Drew Madelung
Ā
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
The Digital Insurer
Ā
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
Ā
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc
Ā
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
Ā
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
Delhi Call girls
Ā
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
debabhi2
Ā
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Igalia
Ā
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
ThousandEyes
Ā
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
wesley chun
Ā
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
Antenna Manufacturer Coco
Ā
Scaling API-first ā The story of a global engineering organization
Scaling API-first ā The story of a global engineering organization
Radu Cotescu
Ā
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Principled Technologies
Ā
How to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
naman860154
Ā
Recently uploaded
(20)
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Ā
š¬ The future of MySQL is Postgres š
š¬ The future of MySQL is Postgres š
Ā
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
Ā
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
Ā
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
Ā
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
Ā
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Ā
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Ā
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Ā
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
Ā
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Ā
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
Ā
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
Ā
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Ā
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Ā
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
Ā
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
Ā
Scaling API-first ā The story of a global engineering organization
Scaling API-first ā The story of a global engineering organization
Ā
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Ā
How to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
Ā
Refactoring
1.
Refactoring and Reļ¬ection
Marcus Denker denker@iam.unibe.ch UniversitƤt Bern Ā© Marcus Denker
2.
Roadmap >
First lecture: Refactoring ā Squeak as an example > Second Lecture: Reļ¬ection ā About current research Ā© Marcus Denker
3.
Part I: Refactoring
Marcus Denker denker@iam.unibe.ch UniversitƤt Bern Ā© Marcus Denker
4.
Overview > Refactoring: Basics >
Refactoring in Squeak: Browser + Tools > Refactoring Engine: Implementation > Discussion: Reļ¬ection? Ā© Marcus Denker
5.
Roadmap > Refactoring: Basics >
Refactoring in Squeak: Browser + Tools > Refactoring Engine: Implementation > Discussion: Reļ¬ection? Ā© Marcus Denker
6.
What is Refactoring? >
The process of changing a software system in such a way that it does not alter the external behaviour of the code, yet improves its internal structure. ā Fowler, et al., Refactoring, 1999. Ā© Marcus Denker
7.
Typical Refactorings Class
Method Attribute add (sub)class to add method to class add variable to class hierarchy rename class rename method rename variable remove class remove method remove variable push method down push variable down push method up pull variable up add parameter to method create accessors move method to abstract variable component extract code in new method Ā© Marcus Denker
8.
Why Refactor? āGrow, donāt
build softwareā ā Fred Brooks > The reality: ā Extremely difļ¬cult to get the design ārightā the ļ¬rst time ā Hard to fully understand the problem domain ā Hard to understand user requirements, even if the user does! ā Hard to know how the system will evolve in ļ¬ve years ā Original design is often inadequate ā System becomes brittle over time, and more difļ¬cult to change > Refactoring helps you to ā Manipulate code in a safe environment (behavior preserving) ā Recreate a situation where evolution is possible ā Understand existing code Ā© Marcus Denker
9.
Rename Method āĀ manual
steps > Do it yourself approach: ā Check that no method with the new name already exists in any subclass or superclass. ā Browse all the implementers (method deļ¬nitions) ā Browse all the senders (method invocations) ā Edit and rename all implementers ā Edit and rename all senders ā Remove all implementers ā Test > Automated refactoring is better ! Ā© Marcus Denker
10.
Rename Method > Rename
Method (method, new name) > Preconditions ā No method with the new name already exists in any subclass or superclass. ā No methods with same signature as method outside the inheritance hierarchy of method > PostConditions ā method has new name ā relevant methods in the inheritance hierarchy have new name ā invocations of changed method are updated to new name > Other Considerations ā Typed/Dynamically Typed Languages => Scope of the renaming Ā© Marcus Denker
11.
Refactoring and Metaprograming >
Automated Refactoring is metaprograming ā We use a program to edit programs > Does not need to use Reļ¬ection ā Pure source-to-source transformation (e.g. Java) > Uses reļ¬ective facilities in Smalltalk ā Butā¦ letŹ¼s discuss that at the end Ā© Marcus Denker
12.
Roadmap > Refactoring: Basics >
Refactoring in Squeak: Browser + Tools > Refactoring Engine: Implementation > Discussion: Reļ¬ection? Ā© Marcus Denker
13.
Refactoring in Squeak >
No support in standard IDE ā Example: Try to rename a method > Refactoring Browser ā First Refactoring Browser (for any language) ā Now over 10 years old > Installation ā Get Squeak 3.9 (older version for 3.8, too) ā Install Package AST ā Install Package Refactoring Engine Ā© Marcus Denker
14.
Refactoring Browser >
Browser with menus for e.g ā rename ā Push up/down ā Inlining ā Add parameter ā Extraction Ā© Marcus Denker
15.
SmallLint >
Checks for common mistakes Ā© Marcus Denker
16.
SmallLint Checks >
Possible Bugs ā Variable read before written ā Deļ¬nes #= but not #hash ā Modiļ¬es Collection while iterating over it > Bugs ā Uses True/False instead of true/false ā Variable used but not deļ¬ned > Squeak Bugs > Unnecessary Code > Intention Revealing Ā© Marcus Denker
17.
SmallLint > Very useful! >
Especially valuable for beginners > Has been integrated with SUnit ā Call SmallLint automatically as a test > Tag methods where SmallLint is wrong ā Uses Squeak 3.9 Method Pragmas Ā© Marcus Denker
18.
RewriteTool >
Pattern driven automatic editor Ā© Marcus Denker
19.
RewriteTool >
Access to full power of Refactoring Engine > Custom refactorings: ā generic rewrites that the RB does not currently provide ā bulk transformations: your project needs to change a project- speciļ¬c pattern to a new form ā changing layers: e.g. build a new DB layer, ļ¬nd and change 17,000 references to old layer ā migrations: e.g. between Smalltalk dialects > Powerful but not trivial to use > Examples: Later Ā© Marcus Denker
20.
Roadmap > Refactoring: Basics >
Refactoring in Squeak: Browser + Tools > Refactoring Engine: Implementation > Discussion: Reļ¬ection? [Main Source] Don Roberts, John Brant, and Ralph Johnson. A Refactoring Tool for Smalltalk. Theory and Practice of Object Systems, vol. 3, issue 4 Ā© Marcus Denker
21.
Implementation Overview >
Goal: Transformation on the Source > Idea: Transform into a higher level tree representation Ā© Marcus Denker
22.
The RB Abstract
Syntax Tree RBProgramNode > AST: Abstract Syntax Tree RBDoItNode ā Encodes the Syntax as a Tree RBMethodNode RBReturnNode ā Features: RBSequenceNode ā Visitors RBValueNode ā Backward pointers in ParseNodes RBArrayNode RBAssignmentNode ā Encodes formatting RBBlockNode ā Transformation (replace/add/ RBCascadeNode delete) RBLiteralNode ā Pattern-directed TreeRewriter RBMessageNode RBOptimizedNode ā PrettyPrinter RBVariableNode Ā© Marcus Denker
23.
A Simple AST RBParser
parseExpression: '3+4' explore it Ā© Marcus Denker
24.
A Simple Visitor
RBProgramNodeVisitor new visitNode: tree Does nothing except walk through the tree Ā© Marcus Denker
25.
More Complete Visitor RBProgramNodeVisitor
subclass: #TestVisitor instanceVariableNames: 'literals' classVariableNames: '' poolDictionaries: '' category: 'Compiler-AST-Visitors' TestVisitor>>acceptLiteralNode: aLiteralNode literals add: aLiteralNode value. TestVisitor>>initialize literals := Set new. TestVisitor>>literals ^literals tree := RBParser parseExpression: '3 + 4'. (TestVisitor new visitNode: tree) literals a Set(3 4) Ā© Marcus Denker
26.
Tree Matcher >
Implementing all Refactorings with visitors ā Too much work ā Too low level > Needed: High level speciļ¬cation of transformations > Rewrite Engine: Core of Refactoring Engine > No only useful for Refactoring! Ā© Marcus Denker
27.
Tree Matcher >
Describe transformation by using patterns > Syntax: Smalltalk + Meta Variables > Example: | `@Temps | ``@.Statements. ``@Boolean ifTrue: [^false]. ^true Ā© Marcus Denker
28.
Meta Variables
All Meta Variables begin with ` Character Type Example ` recurse into ``@object foo @ list | `@Temps | `@.statements . statement `.Statement # literal `#literal Ā© Marcus Denker
29.
Example 1 >
Search for: ``@object not ifTrue: ``@block ā¢ Replace with: ``@object ifFalse: ``@block ā¢ Explanation: ā Eliminate an unnecesary not message Ā© Marcus Denker
30.
Example 2
| `@Temps | ``@.Statements. > Search for: ``@Boolean ifTrue: [^false]. ^true ā¢ Replace with: | `@Temps | ``@.Statements. ^``@Boolean not ā¢ Explanation: ā Return the value of the boolean negated instead of using a conditional Ā© Marcus Denker
31.
Implementation: Model and Environment >
Model Code transformed but not installed ā We need to be able to see refactored code without changing the system. ā RBNameSpace > Model Classes + Methods ā Framework duplicates SmalltalkŹ»s structural Reļ¬ection ā RBClass, RBMethod > Model Scope to which Refactorings apply ā RBEnvironment Ā© Marcus Denker
32.
Back to Code:
Pretty Printer > Visitor: Walks the AST > Prints out text for each node > Problem: How to preserve formatting? ā AST saves formatting (whitespace, parenthesis) ā Pretty Printer can use saved formatting information Ā© Marcus Denker
33.
Contributions needed >
Improved UI > Integrated Parser with Squeak NewCompiler ā Scanner/Parser done with tool (SmaCC) ā Easier to change / experiment > Integrated RoelTyper ā Heuristical type inference > Better PrettyPrinter ā Conļ¬gurability ā Better Layout Ā© Marcus Denker
34.
Roadmap > Refactoring: Basics >
Refactoring in Squeak: Browser + Tools > Refactoring Engine: Implementation > Discussion: Reļ¬ection? Ā© Marcus Denker
35.
Reļ¬ection? >
We change the system using itself ā So itŹ»s Reļ¬ection, on some level > But: LetŹ»s look again at the deļ¬nition ā Model of itself ā Causally connected > We Build our own abstraction layer ā AST + Environment > This Model is not causally connected! Ā© Marcus Denker
36.
State Today Ā© Marcus
Denker
37.
Why not this? Ā©
Marcus Denker
38.
We have seen... >
Refactoring: Basics > Refatoring in Squeak: Browser + Tools > Refactoring Engine: Implementation > Discussion: Reļ¬ection? Ā© Marcus Denker
39.
Questions? > Refactoring: Basics >
Refatoring in Squeak: Browser + Tools > Refactoring Engine: Implementation > Discussion: Reļ¬ection? Questions? Ā© Marcus Denker
40.
License >
http://creativecommons.org/licenses/by-sa/2.5/ Attribution-ShareAlike 2.5 You are free: ā¢ to copy, distribute, display, and perform the work ā¢ to make derivative works ā¢ to make commercial use of the work Under the following conditions: Attribution. You must attribute the work in the manner speciļ¬ed by the author or licensor. Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. ā¢ For any reuse or distribution, you must make clear to others the license terms of this work. ā¢ Any of these conditions can be waived if you get permission from the copyright holder. Your fair use and other rights are in no way affected by the above. Ā© Marcus Denker
Download now