SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Downloaden Sie, um offline zu lesen
Legacy Coderetreat
About
Coderetreat started in 2009, created by:
• Gary Bernhardt
• Patrick Welsh
• Nayan Hajratwala
• Corey Haines
Legacy code retreat created in 2012 by JB
Rainsberger
Me
Adrian Bolboaca
Technical and Organizational Trainer and Coach at Mozaic Works
Why
Practice
Experiment
Learn legacy code techniques
Extend your comfort zone
Learn through pair-programing
Have fun
How
1 Day of coding
Have an existing codebase
6 pairing partners
On average 135 minutes of coding
6 different legacy code techniques
A lot of fun!
Day structure
Introduction
3 sessions in the morning
Lunch 1h
3 sessions in the afternoon
Day retrospective 30 minutes
Principles
Language agnostic
Follow the constraints of the session
Delete the code changes after each session
Focus on practice
Experiment each session
Have fun!
Prerequisites
Computer
Coding environment
Testing environment
Local source control (git, etc)
The four elements of simple design
1. Passes its tests
2. Minimizes duplication
3. Maximizes clarity
4. Has fewer elements
Basic rules of refactoring
Steps
1. Duplicate implementation
2. Cover duplicated implementation with tests
(these are learning tests)
3. Reroute original code to new code
(make sure you have some initial tests)
4. Remove old implementation
5. Check tests pass
Git
cd /myroot/myfolder
git clone https://github.com/jbrains/trivia.git
git status -> check pending changes
git commit -am "non-empty message"
git reset --hard HEAD --> reset to last commit
git clean -f -d -x -> delete all untracked files
Codebase
You can find it at https://github.com/jbrains/trivia
Use git to clone the repository
Session 1: Code reading
Take 30 minutes to read the code
Try to understand it
Work in pairs
Session 2: From nothing to system
tests
1.Find an entry point into your system, a method at
the highest level possible, closest to external calls
or the user interface
2. Define a limit of your system that blocks you
from verifying resulting behavior
3. Find a way to fake this limit so that you can
catch the results
4. Write a system test that verifies one of your
assumptions about one specific behavior of that
method
5. Refactor
Session 3: Encapsulate external
dependencies
1. Look for a method that uses an external dependency (IO, framework,
hardware, etc)
2. Isolate the real call to the external dependency from the rest of the
method logic, so that this only uses the result/value of the external call
3. Extract the real call to the external dependency into a separate method
4. Extract the method to a new class
5. Create an abstraction for the class
6. Dependency inject the abstraction by:
a. Constructor
b. Property
c. Parameter
7. Rewrite your tests so that the external dependency is:
a. stubbed
b. mocked
Lunch
1 hour
Session 4: Reveal intent
Concepts
1. Find magic number/string within the code
2. Replace the number/string with a symbolic constant which encapsulated the
value and describes the meaning of the number/string
1. Find a variable/method/class with a non-descriptive name, like Foo
2. Change Foo variable/method/class to a meaningful explicit name which
might be too long to be useful but reveals intent
3. Iteratively improve* the variable/method/class name.
Improving means:
● Shortening towards a more comfortable length
● Keeping the explicit nature of the name intact
● Staying coherent with the domain
● Avoiding duplication of concepts, i.e. synonyms for the same concept
Session 5: Refactoring conditionals
(slide 1/2)
Concepts
● Guard Clauses [1]
Is a chunk of code at the top of a function that serves
a similar purpose to a Precondition. It typically does
one (or any or all) of the following:
a. Returns an error when invalid input parameters.
b. Bails out when function call is inappropriate.
c. Handle trivial cases quickly.
● Explaining Variable [2]
Transform an expression into a temporary variable
that explains the purpose of the logical expression
Session 5: Refactoring conditionals
(slide 2/2)
Concepts
● Decompose Conditional [4]
1. Find a method that contains a conditional expression and a chunk of
functionality within this conditional
2. Use extract method to move the real functionality into a separate method
● Consolidate Conditional Expression [5]
1. Find a method that contains multiple conditional expressions or a
composite conditional
2. Use extract method to move all of the conditional logic into a separate
method so that it combines all the conditional logic
3. Give the new method a descriptive name that you can use in the
original method (like an explaining variable)
Session 6: Extract pure functions
A pure function always evaluates the same result value given the same argument
value(s). Its result cannot depend on any hidden information or state that may change
as program execution proceeds or between different executions of the program. *
Steps
1. Find an atomic piece of code that can be moved into a separate public function
by using Extract method
2. Replace all external dependencies within this function with independent or primitive
parameters
a. Constants
b. Class variables
c. Global variables
d. Method variables outside of the extracted code
3. Returns an object instantiated inside the function
4. Add tests for the method
a. At least one test for each parameter
b. One test for each value range of each parameter
5. Refactor
Closing circle
1)How did you feel
2)What did you learn
3)What would you apply Monday?
Contact me
Remote pair-programming
Unit testing workshop
Test driven development workshop
Refactoring workshop
Working FAST and safe with existing code workshop
Code retreat workshop
http://mozaicworks.com
adrian.bolboaca@mozaicworks.com
@adibolb
blog.adrianbolboaca.ro

Weitere ähnliche Inhalte

Was ist angesagt?

Refactoring: Improve the design of existing code
Refactoring: Improve the design of existing codeRefactoring: Improve the design of existing code
Refactoring: Improve the design of existing codeValerio Maggio
 
Dynamic analysis in Software Testing
Dynamic analysis in Software TestingDynamic analysis in Software Testing
Dynamic analysis in Software TestingSagar Pednekar
 
Bad Code Smells
Bad Code SmellsBad Code Smells
Bad Code Smellskim.mens
 
Boundary and equivalnce systematic test design
Boundary and equivalnce   systematic test designBoundary and equivalnce   systematic test design
Boundary and equivalnce systematic test designIan McDonald
 
Whitebox testing
Whitebox testingWhitebox testing
Whitebox testingOana Feidi
 
Input Space Partitioning
Input Space PartitioningInput Space Partitioning
Input Space PartitioningRiyad Parvez
 
Magic Literals In Pharo
 Magic Literals In Pharo Magic Literals In Pharo
Magic Literals In PharoESUG
 
Class 4: Making Procedures
Class 4: Making ProceduresClass 4: Making Procedures
Class 4: Making ProceduresDavid Evans
 
White Box Testing
White Box TestingWhite Box Testing
White Box TestingAlisha Roy
 
SE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and JunitSE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and JunitAmr E. Mohamed
 
Software Testing Techniques
Software Testing TechniquesSoftware Testing Techniques
Software Testing TechniquesKiran Kumar
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseUTC Fire & Security
 
White Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhWhite Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhPankaj Thakur
 
Testing Fundamentals
Testing FundamentalsTesting Fundamentals
Testing FundamentalsKiran Kumar
 
Coding and testing In Software Engineering
Coding and testing In Software EngineeringCoding and testing In Software Engineering
Coding and testing In Software EngineeringSatya Bhushan Verma
 
Mutation Testing and MuJava
Mutation Testing and MuJavaMutation Testing and MuJava
Mutation Testing and MuJavaKrunal Parmar
 

Was ist angesagt? (20)

Refactoring: Improve the design of existing code
Refactoring: Improve the design of existing codeRefactoring: Improve the design of existing code
Refactoring: Improve the design of existing code
 
Dynamic analysis in Software Testing
Dynamic analysis in Software TestingDynamic analysis in Software Testing
Dynamic analysis in Software Testing
 
Bad Code Smells
Bad Code SmellsBad Code Smells
Bad Code Smells
 
Boundary and equivalnce systematic test design
Boundary and equivalnce   systematic test designBoundary and equivalnce   systematic test design
Boundary and equivalnce systematic test design
 
Whitebox testing
Whitebox testingWhitebox testing
Whitebox testing
 
Input Space Partitioning
Input Space PartitioningInput Space Partitioning
Input Space Partitioning
 
Magic Literals In Pharo
 Magic Literals In Pharo Magic Literals In Pharo
Magic Literals In Pharo
 
Class 4: Making Procedures
Class 4: Making ProceduresClass 4: Making Procedures
Class 4: Making Procedures
 
White Box Testing
White Box TestingWhite Box Testing
White Box Testing
 
SE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and JunitSE2_Lec 21_ TDD and Junit
SE2_Lec 21_ TDD and Junit
 
Whitebox
WhiteboxWhitebox
Whitebox
 
Software Testing Techniques
Software Testing TechniquesSoftware Testing Techniques
Software Testing Techniques
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + Eclipse
 
Black Box Testing
Black Box TestingBlack Box Testing
Black Box Testing
 
White Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhWhite Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR Chandigarh
 
Testing Fundamentals
Testing FundamentalsTesting Fundamentals
Testing Fundamentals
 
Coding and testing In Software Engineering
Coding and testing In Software EngineeringCoding and testing In Software Engineering
Coding and testing In Software Engineering
 
Sta unit 4(abimanyu)
Sta unit 4(abimanyu)Sta unit 4(abimanyu)
Sta unit 4(abimanyu)
 
White box testing
White box testingWhite box testing
White box testing
 
Mutation Testing and MuJava
Mutation Testing and MuJavaMutation Testing and MuJava
Mutation Testing and MuJava
 

Ähnlich wie Legacy Coderetreat @Budapest 2013 02 16

Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)Kaunas Java User Group
 
Agile korea 2013 유석문
Agile korea 2013 유석문Agile korea 2013 유석문
Agile korea 2013 유석문Sangcheol Hwang
 
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...DevDay.org
 
Testing the untestable
Testing the untestableTesting the untestable
Testing the untestableRoyKlein
 
Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Abdul Hannan
 
The programming philosophy of jrql
The programming philosophy of jrqlThe programming philosophy of jrql
The programming philosophy of jrqlmsg systems ag
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@Alex Borsuk
 
Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023Scott Keck-Warren
 
Mca2030 object oriented programming – c++
Mca2030  object oriented programming – c++Mca2030  object oriented programming – c++
Mca2030 object oriented programming – c++smumbahelp
 
The Ring programming language version 1.8 book - Part 81 of 202
The Ring programming language version 1.8 book - Part 81 of 202The Ring programming language version 1.8 book - Part 81 of 202
The Ring programming language version 1.8 book - Part 81 of 202Mahmoud Samir Fayed
 
Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Myeongseok Baek
 
types of testing with descriptions and examples
types of testing with descriptions and examplestypes of testing with descriptions and examples
types of testing with descriptions and examplesMani Deepak Choudhry
 
Refactoring_Rosenheim_2008_Workshop
Refactoring_Rosenheim_2008_WorkshopRefactoring_Rosenheim_2008_Workshop
Refactoring_Rosenheim_2008_WorkshopMax Kleiner
 
Refactoring Techniques
Refactoring TechniquesRefactoring Techniques
Refactoring TechniquesMayada Ghanem
 
Hadoop testing workshop - july 2013
Hadoop testing workshop - july 2013Hadoop testing workshop - july 2013
Hadoop testing workshop - july 2013Ophir Cohen
 
Testing, a pragmatic approach
Testing, a pragmatic approachTesting, a pragmatic approach
Testing, a pragmatic approachEnrico Da Ros
 
Java căn bản - Chapter7
Java căn bản - Chapter7Java căn bản - Chapter7
Java căn bản - Chapter7Vince Vo
 

Ähnlich wie Legacy Coderetreat @Budapest 2013 02 16 (20)

Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
Bye Bye Cowboy Coder Days! (Legacy Code & TDD)
 
Agile korea 2013 유석문
Agile korea 2013 유석문Agile korea 2013 유석문
Agile korea 2013 유석문
 
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
 
OOPSCA1.pptx
OOPSCA1.pptxOOPSCA1.pptx
OOPSCA1.pptx
 
Testing the untestable
Testing the untestableTesting the untestable
Testing the untestable
 
Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual
 
The programming philosophy of jrql
The programming philosophy of jrqlThe programming philosophy of jrql
The programming philosophy of jrql
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@
 
Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023
 
Mca2030 object oriented programming – c++
Mca2030  object oriented programming – c++Mca2030  object oriented programming – c++
Mca2030 object oriented programming – c++
 
The Ring programming language version 1.8 book - Part 81 of 202
The Ring programming language version 1.8 book - Part 81 of 202The Ring programming language version 1.8 book - Part 81 of 202
The Ring programming language version 1.8 book - Part 81 of 202
 
Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
types of testing with descriptions and examples
types of testing with descriptions and examplestypes of testing with descriptions and examples
types of testing with descriptions and examples
 
Refactoring_Rosenheim_2008_Workshop
Refactoring_Rosenheim_2008_WorkshopRefactoring_Rosenheim_2008_Workshop
Refactoring_Rosenheim_2008_Workshop
 
Bad Smell In Codes 1
Bad Smell In Codes 1Bad Smell In Codes 1
Bad Smell In Codes 1
 
Refactoring Techniques
Refactoring TechniquesRefactoring Techniques
Refactoring Techniques
 
Hadoop testing workshop - july 2013
Hadoop testing workshop - july 2013Hadoop testing workshop - july 2013
Hadoop testing workshop - july 2013
 
Testing, a pragmatic approach
Testing, a pragmatic approachTesting, a pragmatic approach
Testing, a pragmatic approach
 
Java căn bản - Chapter7
Java căn bản - Chapter7Java căn bản - Chapter7
Java căn bản - Chapter7
 

Mehr von Adi Bolboaca

Evolutionary Design - NewCrafts Paris 18 May 2018
Evolutionary Design - NewCrafts Paris 18 May 2018Evolutionary Design - NewCrafts Paris 18 May 2018
Evolutionary Design - NewCrafts Paris 18 May 2018Adi Bolboaca
 
Stop Task Switching
Stop Task SwitchingStop Task Switching
Stop Task SwitchingAdi Bolboaca
 
Evolutionary Design: Take Only One Decision at a Time
Evolutionary Design: Take Only One Decision at a TimeEvolutionary Design: Take Only One Decision at a Time
Evolutionary Design: Take Only One Decision at a TimeAdi Bolboaca
 
Evolutionary Design - Refactoring Heuristics
Evolutionary Design - Refactoring HeuristicsEvolutionary Design - Refactoring Heuristics
Evolutionary Design - Refactoring HeuristicsAdi Bolboaca
 
Behind Agile Practices
Behind Agile PracticesBehind Agile Practices
Behind Agile PracticesAdi Bolboaca
 
Architecture for Disaster Resistant Systems @I TAKE Unconference 29 05 2015
Architecture for Disaster Resistant Systems @I TAKE Unconference 29 05 2015Architecture for Disaster Resistant Systems @I TAKE Unconference 29 05 2015
Architecture for Disaster Resistant Systems @I TAKE Unconference 29 05 2015Adi Bolboaca
 
Coderetreat @AgileFinland Turku 2014 11 15
 Coderetreat @AgileFinland Turku 2014 11 15 Coderetreat @AgileFinland Turku 2014 11 15
Coderetreat @AgileFinland Turku 2014 11 15Adi Bolboaca
 
Coderetreat @AgileFinland Helsinki 2014 11 13
Coderetreat @AgileFinland Helsinki 2014 11 13Coderetreat @AgileFinland Helsinki 2014 11 13
Coderetreat @AgileFinland Helsinki 2014 11 13Adi Bolboaca
 
Coderetreat @AgileFinland Tampere 2014 11 12
Coderetreat @AgileFinland Tampere 2014 11 12Coderetreat @AgileFinland Tampere 2014 11 12
Coderetreat @AgileFinland Tampere 2014 11 12Adi Bolboaca
 
Refactoring Dojo @AgileWorks Bucharest 21 May 2014
Refactoring Dojo @AgileWorks Bucharest 21 May 2014Refactoring Dojo @AgileWorks Bucharest 21 May 2014
Refactoring Dojo @AgileWorks Bucharest 21 May 2014Adi Bolboaca
 
Sherlock Holmes and Pairing @Romanian Testing Conference 2014 05 15
Sherlock Holmes and Pairing @Romanian Testing Conference 2014 05 15Sherlock Holmes and Pairing @Romanian Testing Conference 2014 05 15
Sherlock Holmes and Pairing @Romanian Testing Conference 2014 05 15Adi Bolboaca
 
TDD Mini Workshop @ Bucharest JUG 2014 04 24
TDD Mini Workshop @ Bucharest JUG 2014 04 24TDD Mini Workshop @ Bucharest JUG 2014 04 24
TDD Mini Workshop @ Bucharest JUG 2014 04 24Adi Bolboaca
 
Coderetreat Slides on the Global Day of Coderetreat, Bucharest, December 2013
Coderetreat Slides on the Global Day of Coderetreat, Bucharest, December 2013Coderetreat Slides on the Global Day of Coderetreat, Bucharest, December 2013
Coderetreat Slides on the Global Day of Coderetreat, Bucharest, December 2013Adi Bolboaca
 
Sherlock Holmes and Pairing @Bucharest JUG 2013 11 21
Sherlock Holmes and Pairing @Bucharest JUG 2013 11 21Sherlock Holmes and Pairing @Bucharest JUG 2013 11 21
Sherlock Holmes and Pairing @Bucharest JUG 2013 11 21Adi Bolboaca
 
Sherlock Holmes and Pairing @Wlidcard Conference 2013 09 13
Sherlock Holmes and Pairing @Wlidcard Conference 2013 09 13Sherlock Holmes and Pairing @Wlidcard Conference 2013 09 13
Sherlock Holmes and Pairing @Wlidcard Conference 2013 09 13Adi Bolboaca
 
Code retreat @AgileWorks Bucharest 7 September 2013
Code retreat @AgileWorks Bucharest 7 September 2013Code retreat @AgileWorks Bucharest 7 September 2013
Code retreat @AgileWorks Bucharest 7 September 2013Adi Bolboaca
 
Coderetreat @AgileWorks Bucharest 2012 07 06
Coderetreat @AgileWorks Bucharest 2012 07 06 Coderetreat @AgileWorks Bucharest 2012 07 06
Coderetreat @AgileWorks Bucharest 2012 07 06 Adi Bolboaca
 
Coderetreat @Sofia 2012 10 27
Coderetreat @Sofia 2012 10 27Coderetreat @Sofia 2012 10 27
Coderetreat @Sofia 2012 10 27Adi Bolboaca
 
Coderetreat @Turku 2012 10 20
Coderetreat @Turku 2012 10 20 Coderetreat @Turku 2012 10 20
Coderetreat @Turku 2012 10 20 Adi Bolboaca
 
Coderetreat @Sibiu 2012 08 18
Coderetreat @Sibiu 2012 08 18Coderetreat @Sibiu 2012 08 18
Coderetreat @Sibiu 2012 08 18Adi Bolboaca
 

Mehr von Adi Bolboaca (20)

Evolutionary Design - NewCrafts Paris 18 May 2018
Evolutionary Design - NewCrafts Paris 18 May 2018Evolutionary Design - NewCrafts Paris 18 May 2018
Evolutionary Design - NewCrafts Paris 18 May 2018
 
Stop Task Switching
Stop Task SwitchingStop Task Switching
Stop Task Switching
 
Evolutionary Design: Take Only One Decision at a Time
Evolutionary Design: Take Only One Decision at a TimeEvolutionary Design: Take Only One Decision at a Time
Evolutionary Design: Take Only One Decision at a Time
 
Evolutionary Design - Refactoring Heuristics
Evolutionary Design - Refactoring HeuristicsEvolutionary Design - Refactoring Heuristics
Evolutionary Design - Refactoring Heuristics
 
Behind Agile Practices
Behind Agile PracticesBehind Agile Practices
Behind Agile Practices
 
Architecture for Disaster Resistant Systems @I TAKE Unconference 29 05 2015
Architecture for Disaster Resistant Systems @I TAKE Unconference 29 05 2015Architecture for Disaster Resistant Systems @I TAKE Unconference 29 05 2015
Architecture for Disaster Resistant Systems @I TAKE Unconference 29 05 2015
 
Coderetreat @AgileFinland Turku 2014 11 15
 Coderetreat @AgileFinland Turku 2014 11 15 Coderetreat @AgileFinland Turku 2014 11 15
Coderetreat @AgileFinland Turku 2014 11 15
 
Coderetreat @AgileFinland Helsinki 2014 11 13
Coderetreat @AgileFinland Helsinki 2014 11 13Coderetreat @AgileFinland Helsinki 2014 11 13
Coderetreat @AgileFinland Helsinki 2014 11 13
 
Coderetreat @AgileFinland Tampere 2014 11 12
Coderetreat @AgileFinland Tampere 2014 11 12Coderetreat @AgileFinland Tampere 2014 11 12
Coderetreat @AgileFinland Tampere 2014 11 12
 
Refactoring Dojo @AgileWorks Bucharest 21 May 2014
Refactoring Dojo @AgileWorks Bucharest 21 May 2014Refactoring Dojo @AgileWorks Bucharest 21 May 2014
Refactoring Dojo @AgileWorks Bucharest 21 May 2014
 
Sherlock Holmes and Pairing @Romanian Testing Conference 2014 05 15
Sherlock Holmes and Pairing @Romanian Testing Conference 2014 05 15Sherlock Holmes and Pairing @Romanian Testing Conference 2014 05 15
Sherlock Holmes and Pairing @Romanian Testing Conference 2014 05 15
 
TDD Mini Workshop @ Bucharest JUG 2014 04 24
TDD Mini Workshop @ Bucharest JUG 2014 04 24TDD Mini Workshop @ Bucharest JUG 2014 04 24
TDD Mini Workshop @ Bucharest JUG 2014 04 24
 
Coderetreat Slides on the Global Day of Coderetreat, Bucharest, December 2013
Coderetreat Slides on the Global Day of Coderetreat, Bucharest, December 2013Coderetreat Slides on the Global Day of Coderetreat, Bucharest, December 2013
Coderetreat Slides on the Global Day of Coderetreat, Bucharest, December 2013
 
Sherlock Holmes and Pairing @Bucharest JUG 2013 11 21
Sherlock Holmes and Pairing @Bucharest JUG 2013 11 21Sherlock Holmes and Pairing @Bucharest JUG 2013 11 21
Sherlock Holmes and Pairing @Bucharest JUG 2013 11 21
 
Sherlock Holmes and Pairing @Wlidcard Conference 2013 09 13
Sherlock Holmes and Pairing @Wlidcard Conference 2013 09 13Sherlock Holmes and Pairing @Wlidcard Conference 2013 09 13
Sherlock Holmes and Pairing @Wlidcard Conference 2013 09 13
 
Code retreat @AgileWorks Bucharest 7 September 2013
Code retreat @AgileWorks Bucharest 7 September 2013Code retreat @AgileWorks Bucharest 7 September 2013
Code retreat @AgileWorks Bucharest 7 September 2013
 
Coderetreat @AgileWorks Bucharest 2012 07 06
Coderetreat @AgileWorks Bucharest 2012 07 06 Coderetreat @AgileWorks Bucharest 2012 07 06
Coderetreat @AgileWorks Bucharest 2012 07 06
 
Coderetreat @Sofia 2012 10 27
Coderetreat @Sofia 2012 10 27Coderetreat @Sofia 2012 10 27
Coderetreat @Sofia 2012 10 27
 
Coderetreat @Turku 2012 10 20
Coderetreat @Turku 2012 10 20 Coderetreat @Turku 2012 10 20
Coderetreat @Turku 2012 10 20
 
Coderetreat @Sibiu 2012 08 18
Coderetreat @Sibiu 2012 08 18Coderetreat @Sibiu 2012 08 18
Coderetreat @Sibiu 2012 08 18
 

Kürzlich hochgeladen

Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
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
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Kürzlich hochgeladen (20)

Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
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
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Legacy Coderetreat @Budapest 2013 02 16

  • 2. About Coderetreat started in 2009, created by: • Gary Bernhardt • Patrick Welsh • Nayan Hajratwala • Corey Haines Legacy code retreat created in 2012 by JB Rainsberger
  • 3. Me Adrian Bolboaca Technical and Organizational Trainer and Coach at Mozaic Works
  • 4. Why Practice Experiment Learn legacy code techniques Extend your comfort zone Learn through pair-programing Have fun
  • 5. How 1 Day of coding Have an existing codebase 6 pairing partners On average 135 minutes of coding 6 different legacy code techniques A lot of fun!
  • 6. Day structure Introduction 3 sessions in the morning Lunch 1h 3 sessions in the afternoon Day retrospective 30 minutes
  • 7. Principles Language agnostic Follow the constraints of the session Delete the code changes after each session Focus on practice Experiment each session Have fun!
  • 9. The four elements of simple design 1. Passes its tests 2. Minimizes duplication 3. Maximizes clarity 4. Has fewer elements
  • 10. Basic rules of refactoring Steps 1. Duplicate implementation 2. Cover duplicated implementation with tests (these are learning tests) 3. Reroute original code to new code (make sure you have some initial tests) 4. Remove old implementation 5. Check tests pass
  • 11. Git cd /myroot/myfolder git clone https://github.com/jbrains/trivia.git git status -> check pending changes git commit -am "non-empty message" git reset --hard HEAD --> reset to last commit git clean -f -d -x -> delete all untracked files
  • 12. Codebase You can find it at https://github.com/jbrains/trivia Use git to clone the repository
  • 13. Session 1: Code reading Take 30 minutes to read the code Try to understand it Work in pairs
  • 14. Session 2: From nothing to system tests 1.Find an entry point into your system, a method at the highest level possible, closest to external calls or the user interface 2. Define a limit of your system that blocks you from verifying resulting behavior 3. Find a way to fake this limit so that you can catch the results 4. Write a system test that verifies one of your assumptions about one specific behavior of that method 5. Refactor
  • 15. Session 3: Encapsulate external dependencies 1. Look for a method that uses an external dependency (IO, framework, hardware, etc) 2. Isolate the real call to the external dependency from the rest of the method logic, so that this only uses the result/value of the external call 3. Extract the real call to the external dependency into a separate method 4. Extract the method to a new class 5. Create an abstraction for the class 6. Dependency inject the abstraction by: a. Constructor b. Property c. Parameter 7. Rewrite your tests so that the external dependency is: a. stubbed b. mocked
  • 17. Session 4: Reveal intent Concepts 1. Find magic number/string within the code 2. Replace the number/string with a symbolic constant which encapsulated the value and describes the meaning of the number/string 1. Find a variable/method/class with a non-descriptive name, like Foo 2. Change Foo variable/method/class to a meaningful explicit name which might be too long to be useful but reveals intent 3. Iteratively improve* the variable/method/class name. Improving means: ● Shortening towards a more comfortable length ● Keeping the explicit nature of the name intact ● Staying coherent with the domain ● Avoiding duplication of concepts, i.e. synonyms for the same concept
  • 18. Session 5: Refactoring conditionals (slide 1/2) Concepts ● Guard Clauses [1] Is a chunk of code at the top of a function that serves a similar purpose to a Precondition. It typically does one (or any or all) of the following: a. Returns an error when invalid input parameters. b. Bails out when function call is inappropriate. c. Handle trivial cases quickly. ● Explaining Variable [2] Transform an expression into a temporary variable that explains the purpose of the logical expression
  • 19. Session 5: Refactoring conditionals (slide 2/2) Concepts ● Decompose Conditional [4] 1. Find a method that contains a conditional expression and a chunk of functionality within this conditional 2. Use extract method to move the real functionality into a separate method ● Consolidate Conditional Expression [5] 1. Find a method that contains multiple conditional expressions or a composite conditional 2. Use extract method to move all of the conditional logic into a separate method so that it combines all the conditional logic 3. Give the new method a descriptive name that you can use in the original method (like an explaining variable)
  • 20. Session 6: Extract pure functions A pure function always evaluates the same result value given the same argument value(s). Its result cannot depend on any hidden information or state that may change as program execution proceeds or between different executions of the program. * Steps 1. Find an atomic piece of code that can be moved into a separate public function by using Extract method 2. Replace all external dependencies within this function with independent or primitive parameters a. Constants b. Class variables c. Global variables d. Method variables outside of the extracted code 3. Returns an object instantiated inside the function 4. Add tests for the method a. At least one test for each parameter b. One test for each value range of each parameter 5. Refactor
  • 21. Closing circle 1)How did you feel 2)What did you learn 3)What would you apply Monday?
  • 22. Contact me Remote pair-programming Unit testing workshop Test driven development workshop Refactoring workshop Working FAST and safe with existing code workshop Code retreat workshop http://mozaicworks.com adrian.bolboaca@mozaicworks.com @adibolb blog.adrianbolboaca.ro