SlideShare une entreprise Scribd logo
1  sur  27
No fear refactoring in the DVCS age
ReSharper + SemanticMerge
pablo santos @psluaces
@semanticmerge
Agenda
• Introduce SemanticMerge
• Walk through different refactor and merge cases using ReSharper +
Semantic
• Q&A
What is
semanticmerge?
• It is refactor-aware and programming language-
aware.
• Handles merging at the structure level and not
textblock level.
• It means:
• It first parses the code – creates intermediate trees.
• Then calculates diff pairs: base-src, base-dst.
• Then looks for conflicts between pairs.
• Enabling eXtreme Refactoring was always the goal :-)
• It is a 3-way merge tool (handles src, dst and base).
I guess you all know by now ;-)
3-way merge - reminder
Theirs Yours
S
Source Destination
D
Base
Base
B
Result
R
0
main
1 3
4
task001
2 5 6
7
Base
Source
Destination
Can be used with any version control
• Git
• Mercurial
• Perforce
• TFS
• And Plastic SCM
(Free trial available and very affordable)
http://www.semanticmerge.com/index.html#documentation
Case0 – Add the same method twice
Case0 –What a conventional 3-way merge tool
does?
• No conflict!
• And two methods!!
Case0 –What will a conventional 3-way merge
tool do?
• No conflict!
• And two methods!!
• It simply finds two blocks of text being
added … Doesn’t care about the code
structure
Case0 –What SemanticMerge does
• It *knows* about the methods so…
Case 1 – Cleaned up code
• Typical case where an Open Source contributor “helps” rearranging a
class with ReSharper.
• While another contributor was making changes in the original file.
• Merge will be a nightmare… :-)
Case 1 – Cleaned up code (II)
Case 1 – Cleaned up code (III) – ReSharper settings
Case 2 - Split a class in subclasses
Case 2 - Splitting a class in subclasses (II)
• Refactor the file with ReSharper, two developers in parallel
Case 2 - Splitting a class in subclasses (III - merge)
Case 3 – Divergent move
Case 4 – Code format changes
Semantic is able to discard the changes made on source (method call in
multiple lines) and automatically accept the new param instead of raising
a conflict resolution
Case 5 – Move/delete conflict
• What happens if you move a method inside a class
• That is deleted on a different branch?
• How the merge deals with this scenario?
Detect conflicts that regular tools can’t
• What if the same method is modified concurrently at different lines?
• Semantic detects the case and can force the conflict resolution to be
manual – a regular text based merge tool can’t do that because it doesn’t have the context
How can
semanticmerge affect
development?
1) It helps simplifying the mergesTODAY
already.
2) But more importantly it enables new
scenarios that you’re not doing today: clean
up the code, move methods, split classes…
and just be able to merge it back.
Creating a tree-like view of the code
namespace Sample [4-26]
int Add(int a, int b) [8-12]
int Mul(int a, int b) [14-18]
int Subst(int a, int b) [20-24]
using System [1]
using System.Text [2]
class Math [6-25]
Process
base
base tree
source destination
Parser
source tree destination tree
Differ Differ
Merger
src-base diffs dst-base diffs
result
automatic conflicts
manual conflicts
source ops to apply
Some complex cases – cyclic move
namespace Testnamespace Test
namespace Test
class Socket
class Socket
class DNS
class DNS
class Socket
base
source destination
class Utils
class Utils
class DNSclass Utils
Evil twin namespace Test
class Socket
base
source
method Connect
namespace Test
class Socket
method Connect
namespace Test
class Socket
method Connect
destination
method Send method Send
Two methods with exactly the same
signature can’t be added on the same
location -> conflict
Multi-file
SemanticMerge
Refactoring merged code - ReSharper meets SemanticMerge

Contenu connexe

Tendances

Reflection in Pharo5
Reflection in Pharo5Reflection in Pharo5
Reflection in Pharo5Marcus Denker
 
Power shell basics day 9
Power shell basics day 9Power shell basics day 9
Power shell basics day 9Ashish Raj
 
Microsoft (Silverlight)
Microsoft (Silverlight)Microsoft (Silverlight)
Microsoft (Silverlight)Vinayak Hegde
 
Entity Framework Core 1.x/2.x Advanced
Entity Framework Core 1.x/2.x AdvancedEntity Framework Core 1.x/2.x Advanced
Entity Framework Core 1.x/2.x AdvancedChristian Nagel
 
A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5Steven Smith
 
Typescript for the programmers who like javascript
Typescript for the programmers who like javascriptTypescript for the programmers who like javascript
Typescript for the programmers who like javascriptAndrei Sebastian Cîmpean
 
Python Programming for ArcGIS: Part I
Python Programming for ArcGIS: Part IPython Programming for ArcGIS: Part I
Python Programming for ArcGIS: Part IDUSPviz
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakMarcus Denker
 
.NET and C# Introduction
.NET and C# Introduction.NET and C# Introduction
.NET and C# IntroductionSiraj Memon
 
ASP.NET Session 3
ASP.NET Session 3ASP.NET Session 3
ASP.NET Session 3Sisir Ghosh
 
18 .NET Objects in PowerShell
18 .NET Objects in PowerShell18 .NET Objects in PowerShell
18 .NET Objects in PowerShellAshish Raj
 
Git for Excel
Git for ExcelGit for Excel
Git for Excelxlwings
 
.NET Standard - Introduction
.NET Standard - Introduction.NET Standard - Introduction
.NET Standard - IntroductionImmo Landwerth
 
Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009John Clayton
 
TypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack DevelopersTypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack DevelopersRutenis Turcinas
 
Introduction to TypeScript by Winston Levi
Introduction to TypeScript by Winston LeviIntroduction to TypeScript by Winston Levi
Introduction to TypeScript by Winston LeviWinston Levi
 

Tendances (20)

Reflection in Pharo5
Reflection in Pharo5Reflection in Pharo5
Reflection in Pharo5
 
Power shell basics day 9
Power shell basics day 9Power shell basics day 9
Power shell basics day 9
 
Microsoft (Silverlight)
Microsoft (Silverlight)Microsoft (Silverlight)
Microsoft (Silverlight)
 
Variables in Pharo5
Variables in Pharo5Variables in Pharo5
Variables in Pharo5
 
Entity Framework Core 1.x/2.x Advanced
Entity Framework Core 1.x/2.x AdvancedEntity Framework Core 1.x/2.x Advanced
Entity Framework Core 1.x/2.x Advanced
 
Function in Python
Function in PythonFunction in Python
Function in Python
 
A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5
 
Typescript for the programmers who like javascript
Typescript for the programmers who like javascriptTypescript for the programmers who like javascript
Typescript for the programmers who like javascript
 
Python Programming for ArcGIS: Part I
Python Programming for ArcGIS: Part IPython Programming for ArcGIS: Part I
Python Programming for ArcGIS: Part I
 
Scripting robot
Scripting robotScripting robot
Scripting robot
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
 
.NET and C# Introduction
.NET and C# Introduction.NET and C# Introduction
.NET and C# Introduction
 
ASP.NET Session 3
ASP.NET Session 3ASP.NET Session 3
ASP.NET Session 3
 
18 .NET Objects in PowerShell
18 .NET Objects in PowerShell18 .NET Objects in PowerShell
18 .NET Objects in PowerShell
 
Git for Excel
Git for ExcelGit for Excel
Git for Excel
 
.NET Standard - Introduction
.NET Standard - Introduction.NET Standard - Introduction
.NET Standard - Introduction
 
TypeScript - An Introduction
TypeScript - An IntroductionTypeScript - An Introduction
TypeScript - An Introduction
 
Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009
 
TypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack DevelopersTypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack Developers
 
Introduction to TypeScript by Winston Levi
Introduction to TypeScript by Winston LeviIntroduction to TypeScript by Winston Levi
Introduction to TypeScript by Winston Levi
 

Similaire à Refactoring merged code - ReSharper meets SemanticMerge

Semantic Merge - No fear refactoring
Semantic Merge - No fear refactoringSemantic Merge - No fear refactoring
Semantic Merge - No fear refactoringpsluaces
 
How to do code review and use analysis tool in software development
How to do code review and use analysis tool in software developmentHow to do code review and use analysis tool in software development
How to do code review and use analysis tool in software developmentMitosis Technology
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural PatternsSameh Deabes
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Luis Valencia
 
136 latest dot net interview questions
136  latest dot net interview questions136  latest dot net interview questions
136 latest dot net interview questionssandi4204
 
Workshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfWorkshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfTobiasGoeschel
 
Semanticmerge
SemanticmergeSemanticmerge
Semanticmergepsluaces
 
Data Science Accelerator Program
Data Science Accelerator ProgramData Science Accelerator Program
Data Science Accelerator ProgramGoDataDriven
 
How To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex InfrastructureHow To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex Infrastructuremichael.labriola
 
Writing code for people
Writing code for peopleWriting code for people
Writing code for peopleAlexey Ivanov
 
7 latest-dot-net-interview-questions
7  latest-dot-net-interview-questions7  latest-dot-net-interview-questions
7 latest-dot-net-interview-questionssadiqkhanpathan
 
clean architecture uncle bob AnalysisAndDesign.el.en.pptx
clean architecture uncle bob AnalysisAndDesign.el.en.pptxclean architecture uncle bob AnalysisAndDesign.el.en.pptx
clean architecture uncle bob AnalysisAndDesign.el.en.pptxsaber tabatabaee
 
Static and dynamic polymorphism
Static and dynamic polymorphismStatic and dynamic polymorphism
Static and dynamic polymorphismsanjay joshi
 
Static and dynamic polymorphism
Static and dynamic polymorphismStatic and dynamic polymorphism
Static and dynamic polymorphismumesh patil
 

Similaire à Refactoring merged code - ReSharper meets SemanticMerge (20)

Semantic Merge - No fear refactoring
Semantic Merge - No fear refactoringSemantic Merge - No fear refactoring
Semantic Merge - No fear refactoring
 
How to do code review and use analysis tool in software development
How to do code review and use analysis tool in software developmentHow to do code review and use analysis tool in software development
How to do code review and use analysis tool in software development
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural Patterns
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
 
136 latest dot net interview questions
136  latest dot net interview questions136  latest dot net interview questions
136 latest dot net interview questions
 
Workshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfWorkshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdf
 
Semanticmerge
SemanticmergeSemanticmerge
Semanticmerge
 
Bad Smells in Code
Bad Smells in CodeBad Smells in Code
Bad Smells in Code
 
Data Science Accelerator Program
Data Science Accelerator ProgramData Science Accelerator Program
Data Science Accelerator Program
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Hadoop bank
Hadoop bankHadoop bank
Hadoop bank
 
L03 Design Patterns
L03 Design PatternsL03 Design Patterns
L03 Design Patterns
 
How To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex InfrastructureHow To Navigate And Extend The Flex Infrastructure
How To Navigate And Extend The Flex Infrastructure
 
Writing code for people
Writing code for peopleWriting code for people
Writing code for people
 
L05 Design Patterns
L05 Design PatternsL05 Design Patterns
L05 Design Patterns
 
7 latest-dot-net-interview-questions
7  latest-dot-net-interview-questions7  latest-dot-net-interview-questions
7 latest-dot-net-interview-questions
 
Vba Class Level 3
Vba Class Level 3Vba Class Level 3
Vba Class Level 3
 
clean architecture uncle bob AnalysisAndDesign.el.en.pptx
clean architecture uncle bob AnalysisAndDesign.el.en.pptxclean architecture uncle bob AnalysisAndDesign.el.en.pptx
clean architecture uncle bob AnalysisAndDesign.el.en.pptx
 
Static and dynamic polymorphism
Static and dynamic polymorphismStatic and dynamic polymorphism
Static and dynamic polymorphism
 
Static and dynamic polymorphism
Static and dynamic polymorphismStatic and dynamic polymorphism
Static and dynamic polymorphism
 

Dernier

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Dernier (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Refactoring merged code - ReSharper meets SemanticMerge

  • 1.
  • 2. No fear refactoring in the DVCS age ReSharper + SemanticMerge pablo santos @psluaces @semanticmerge
  • 3. Agenda • Introduce SemanticMerge • Walk through different refactor and merge cases using ReSharper + Semantic • Q&A
  • 4. What is semanticmerge? • It is refactor-aware and programming language- aware. • Handles merging at the structure level and not textblock level. • It means: • It first parses the code – creates intermediate trees. • Then calculates diff pairs: base-src, base-dst. • Then looks for conflicts between pairs. • Enabling eXtreme Refactoring was always the goal :-) • It is a 3-way merge tool (handles src, dst and base). I guess you all know by now ;-)
  • 5. 3-way merge - reminder Theirs Yours S Source Destination D Base Base B Result R 0 main 1 3 4 task001 2 5 6 7 Base Source Destination
  • 6. Can be used with any version control • Git • Mercurial • Perforce • TFS • And Plastic SCM (Free trial available and very affordable) http://www.semanticmerge.com/index.html#documentation
  • 7. Case0 – Add the same method twice
  • 8. Case0 –What a conventional 3-way merge tool does? • No conflict! • And two methods!!
  • 9. Case0 –What will a conventional 3-way merge tool do? • No conflict! • And two methods!! • It simply finds two blocks of text being added … Doesn’t care about the code structure
  • 10. Case0 –What SemanticMerge does • It *knows* about the methods so…
  • 11. Case 1 – Cleaned up code • Typical case where an Open Source contributor “helps” rearranging a class with ReSharper. • While another contributor was making changes in the original file. • Merge will be a nightmare… :-)
  • 12. Case 1 – Cleaned up code (II)
  • 13. Case 1 – Cleaned up code (III) – ReSharper settings
  • 14. Case 2 - Split a class in subclasses
  • 15. Case 2 - Splitting a class in subclasses (II) • Refactor the file with ReSharper, two developers in parallel
  • 16. Case 2 - Splitting a class in subclasses (III - merge)
  • 17. Case 3 – Divergent move
  • 18. Case 4 – Code format changes Semantic is able to discard the changes made on source (method call in multiple lines) and automatically accept the new param instead of raising a conflict resolution
  • 19. Case 5 – Move/delete conflict • What happens if you move a method inside a class • That is deleted on a different branch? • How the merge deals with this scenario?
  • 20. Detect conflicts that regular tools can’t • What if the same method is modified concurrently at different lines? • Semantic detects the case and can force the conflict resolution to be manual – a regular text based merge tool can’t do that because it doesn’t have the context
  • 21. How can semanticmerge affect development? 1) It helps simplifying the mergesTODAY already. 2) But more importantly it enables new scenarios that you’re not doing today: clean up the code, move methods, split classes… and just be able to merge it back.
  • 22. Creating a tree-like view of the code namespace Sample [4-26] int Add(int a, int b) [8-12] int Mul(int a, int b) [14-18] int Subst(int a, int b) [20-24] using System [1] using System.Text [2] class Math [6-25]
  • 23. Process base base tree source destination Parser source tree destination tree Differ Differ Merger src-base diffs dst-base diffs result automatic conflicts manual conflicts source ops to apply
  • 24. Some complex cases – cyclic move namespace Testnamespace Test namespace Test class Socket class Socket class DNS class DNS class Socket base source destination class Utils class Utils class DNSclass Utils
  • 25. Evil twin namespace Test class Socket base source method Connect namespace Test class Socket method Connect namespace Test class Socket method Connect destination method Send method Send Two methods with exactly the same signature can’t be added on the same location -> conflict

Notes de l'éditeur

  1. The case just shows how to developers added (in parallel) the same method in two different locations. SemanticMerge is able to detect the situation and include only one of the two, while a regular merge tool would incorrectly add the two.
  2. This is a typical cleanup scenario: you just go to ‘code cleanup’ in ReSharper and get some methods rearranged. Then later someone else, concurrently, modifies a methods on its ‘original’ location. Regular merge tools would have a really bad time merging this… But Semantic can merge automatically since it ‘understands’ the code structure.
  3. Splitting in subclasses is a rich scenario involving complex modifications. The scenario starts with a single ‘socket’ class that will be split into two: ClientSocket and ServerSocket plus the old ‘Socket’ being renamed to ‘DNS’. Understanding the scenario is not hard for a programmer, but a text-based mergetool will turn the merge into a real pain. ReSharper can easily perform the refactor in a few clicks. We will simulate two developes working in parallel, one creating the ClientSocket while the second creates the ServerSocket. Then the code will be merged by Semantic.
  4. Jump to demo mode and go step by step refactoring the code with ReSharper, showing how to developers make the changes in parallel (simulated). Note: need to decide the version control. Git would be fine. Plastic can do too.
  5. The goal is to show how Semantic can seamlessly merge the refactor created by ReSharper
  6. This case will continue where the ‘split class in subclasses’ left. What if now the developers move a method to two different subclasses and also modify it? Demo: Perform the refactor (move methods) with ReSharper Merge with Semantic