SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Downloaden Sie, um offline zu lesen
CODE RETREAT
$

PROGRAMMERS HONING THEIR CRAFT TOGETHER
WHAT IT IS?
intensive practice event,
 focus on the fundamentals of software development
and design,
 focus on skill improvement.

WHY WE DO IT?
learn through pairing,
 extend your comfort zone,
 practice,
 experiment,
 learn new practices.

HOW WE DO IT?


Normally:
organized Saturdays,
 it takes a full day (6 sessions).




This code retreat:
organized Wednesday (October 23rd, 2013),
 it takes only 3 hours because of work constraints (2
sessions).

HOW WE DO IT?


introduction - 30 min

first session – 45 min
 retrospective for first session – 15 min




break – 15 min

second session – 45 min
 retrospective for second session – 15 min




final retrospective & closing
HOW WE DO IT?
only pair programming,
 switch pairs when session ends,
 use any language
(preferably C# or Java for this retreat),
 delete the code when session ends,
 do not try to finish the problem,
 focus on practice,
 enjoy!

WHY USE CONSTRAINTS?
learn new things,
 expand our comfort zone,
 improve the way we design software,
 learn communication through tests
(tests as a form of documentation).

WHAT CONSTRAINTS?
the four elements of simple design,
 no conditionals (if, while, etc),
 no primitives (int, boolean etc, just objects),
 four lines of code per methods,
 law of Demeter (use only one dot per line),
 no mouse/touchpad (keyboard only),
 no IDE (text editor only),
 taking baby steps,
 object calisthenics,
 immutable objects only.

WHAT? PAIR PROGRAMMING GAMES?


ping pong (one person writes the tests, the other
person writes the implementation code to make the
test pass),



mute pairing (no one talks, this improves the
readability of the code),



mute with find the loophole (AKA evil coder; the
implementation person purposely writes the wrong
algorithm that still makes the tests turn green. The
key is that they have to keep the code very clean all
the while. So, no big long if statements parsing on
the input parameters.)
WHAT ARE THE RULES FOR
PING PONG PAIR PROGRAMMING?

driver – the one coding at a given moment
 copilot – the other developer


1.

2.
3.

4.

the driver writes a test and then hands the
keyboard to the copilot,
the new driver makes the test pass,
they refactor together, passing the keyboard as
necessary,
they reverse roles and start over with a new test.
WHAT ENVIRONMENT?


C#
Visual Studio IDE (preferably with ReSharper)
 NUnit testing framework




Java
Eclipse or IntelliJ IDEA IDEs
 JUnit testing framework




git bash (or any other git client)
WHAT DO WE CODE?


traditionally the Conway's Game of Life,



can also be Tic-Tac-Toe, but this has a small
disadvantage: you might be able to finish it in a
session which is not so good.
WHAT ARE THE RULES?
having an infinite 2D orthogonal universe
 being given an initial generation called seed
 the following rules are applied simultaneously









live cells
live cells
live cells
dead cells
revived

with
with
with
with

< 2 live neighbors die
2 or 3 live neighbors live
> 3 live neighbors die
exactly 3 live neighbors will be

check this online simulation to understand better how it works.
FIRST SESSION
you have 5 minutes to get prepared,
 pick your pair,
 use ping pong pair programming,
 don’t use constraints,
 just get a feel for the problem domain,
 start coding (and the countdown timer)!

FIRST SESSION’S RETROSPECTIVE


do you find it easy to delete the code?



why do you think we should do that?



what would happen if you didn’t delete it?
15 MINUTES BREAK!!!
SECOND SESSION
you have 5 minutes to get prepared,
 pick your pair (different than in the first session),
 use ping pong pair programming,
 pick a constraint,
 start coding (and the countdown timer)!

SECOND SESSION’S RETROSPECTIVE
is an array the right way to store the cells?
(talk about the “primitive obsession” code smell),





what constraints did you choose and why?
FINAL RETROSPECTIVE & CLOSING


what, if anything, did you learn today?



what, if anything, surprised you today?



what, if anything, will you do differently in the
future?



what can be improved regarding the organization of
the code retreat?
WANT MORE?
Global Day of Code Retreat (#gdcr twitter hash
tag),
 This year on December 14th,




Legacy Code Retreat – practice writing tests,
refactoring, improving the design in existing code
(since many of us don’t have the privilege of
working on a greenfield project),



Coding Katas – programming exercises which help
the programmer to improve his/her skills through
practice and repetition.
RESOURCES
Links and books of interest
LINKS
video introduction to code retreats
 how others do it: The Orlando Code Retreat Video
 main site: coderetreat.org
 awesome site by Uncle Bob: cleancoders.com
 coding kata catalogue
 the software craftsmanship movement
 software craftsmanship community (contributor
there)

BOOKS
Clean Code
by Robert C. Martin

The Coding Dojo Handbook
by Emily Bache

Refactoring
by Martin Fowler

Working Effectively
with Legacy Code
by Michael Feathers
APPENDIX
Detailed descriptions for the constraints
THE FOUR ELEMENTS OF SIMPLE DESIGN


The code:
passes it’s tests (tests always on green),
 minimizes duplication (extract methods),
 maximizes clarity (better names, SRP, etc),
 has fewer elements (less code is better most of the
time).

NO CONDITIONAL STATEMENTS
no if/while/switch etc statements
 the conditional operator (?:) is permitted
 boolean expressions are also permitted
 you can also use maps instead of switches

NO PRIMITIVES
with this we’re trying to fix the “primitive
obsession” code smell,
 it basically means that you shouldn’t use primitive
data types (int, double, boolean, string) to
represent domain ideas,
 we introduce a Value Object in place of the
primitives, and other code spread around will be
moved in the Value Object,
 this is a way to minimize duplication.

FOUR LINES OF CODE PER METHOD
programmers have a way of being “comfortable”
with the code: instead of creating a new method for
something (too hard), they add code to an existing
method making it bigger and harder to test (that is if
they have tests at all),
 this constraint will force you to use SRP (the Single
Responsibility Principle),
 an easy way to do this is “extract till you drop”
(see Uncle’s Bob Clean Code book) which tells that
you should extract new methods from an existing
one till you don’t have anything else to extract.

LAW OF DEMETER – IN PLAIN ENGLISH
also called the principle of least knowledge,
 your method can call other methods in its class
directly,
 your method can call methods on its own fields
directly (but not on the fields' fields),
 when your method takes parameters, your method
can call methods on those parameters directly,
 when your method creates local objects, that
method can call methods on the local objects.

LAW OF DEMETER – FUNNY DEFINITION
you can play with yourself,
 you can play with your own toys (but you can't take
them apart),
 you can play with toys that were given to you,
 you can play with toys you've made yourself.




Real Life™ analogy: when one wants a dog to
walk, one does not command the dog's legs to walk
directly; instead one commands the dog which then
commands its own legs.
NO MOUSE/TOUCHPAD (KEYBOARD ONLY)
programmers who know keyboard shortcuts (to
build, to run tests, to execute) work faster and are
usually less distracted,
 you should learn the keyboard shortcut equivalents
for most of the operations you usually do on the
normal work day,
 you should know the Windows ones too:


Win + E  open new explorer window,
 Alt + D  go to address bar,
 etc.

NO IDE (TEXT EDITOR ONLY)
this is addressed to those that work the entire day
in an IDE (Visual Studio, Eclipse, IntelliJ IDEA,
others),
 do you know what the IDE does (what commands,
what parameters) for you when you
compile/build/deploy the code?
 can you manage to put the imports/usings by hand?
 can you work without syntax highlighting? Using
just Notepad (no Notepad++).

TAKING BABY STEPS


a small step is sure and steady, whereas when taking a large step you
could be in danger of breaking the tests.

Steps - credits to Adrian Bolboaca
1.
2.
3.

setup source control repository,
setup a timer for 2 minutes interval when you start,
write exactly one test:
A.
B.

4.
5.

restart timer (no discussions in between timers),
refactor
A.
B.

6.
7.
8.

if the timer rings and the test is red then revert and start over,
if the test is green before timer rings then commit.

if the timer rings and the refactoring is not complete then revert and
start over,
if the refactoring is complete before the timer rings then commit.

restart the timer (no discussions in between timers),
go to step 3,
when session time is up delete the code.
IMMUTABLE OBJECTS ONLY
no setters for object fields,
 easier to debug code when there’s nothing that can
mutate,
 extremely helpful when dealing with concurrency,
 applicable to value types.


Weitere ähnliche Inhalte

Was ist angesagt?

Debugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbDebugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbSenthilKumar Selvaraj
 
Webapp acceptance testing a case study
Webapp acceptance testing   a case studyWebapp acceptance testing   a case study
Webapp acceptance testing a case studyekantola
 
Database Refactoring
Database RefactoringDatabase Refactoring
Database RefactoringAnton Keks
 
Engine Terminology 1
Engine Terminology 1Engine Terminology 1
Engine Terminology 1copelandadam
 
eclipse
eclipseeclipse
eclipsetvhung
 
Test Driven Development (C#)
Test Driven Development (C#)Test Driven Development (C#)
Test Driven Development (C#)Alan Dean
 

Was ist angesagt? (6)

Debugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbDebugging Modern C++ Application with Gdb
Debugging Modern C++ Application with Gdb
 
Webapp acceptance testing a case study
Webapp acceptance testing   a case studyWebapp acceptance testing   a case study
Webapp acceptance testing a case study
 
Database Refactoring
Database RefactoringDatabase Refactoring
Database Refactoring
 
Engine Terminology 1
Engine Terminology 1Engine Terminology 1
Engine Terminology 1
 
eclipse
eclipseeclipse
eclipse
 
Test Driven Development (C#)
Test Driven Development (C#)Test Driven Development (C#)
Test Driven Development (C#)
 

Ähnlich wie Code Retreat

TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019Paulo Clavijo
 
TDD - Seriously, try it! - Opensouthcode
TDD - Seriously, try it! - OpensouthcodeTDD - Seriously, try it! - Opensouthcode
TDD - Seriously, try it! - OpensouthcodeNacho Cougil
 
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...Abdelkrim Boujraf
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In ActionJon Kruger
 
Pair Programming: overview and concepts
Pair Programming: overview and conceptsPair Programming: overview and concepts
Pair Programming: overview and conceptsLior Kirshner-Shalom
 
Training methdology testers to developers
Training methdology   testers to developersTraining methdology   testers to developers
Training methdology testers to developersGurumurthy Ramamurthy
 
The Art of Evolutionary Algorithms Programming
The Art of Evolutionary Algorithms ProgrammingThe Art of Evolutionary Algorithms Programming
The Art of Evolutionary Algorithms ProgrammingJuan J. Merelo
 
Interactive Development Environments
Interactive Development EnvironmentsInteractive Development Environments
Interactive Development EnvironmentsPhilip Johnson
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkPeter Kofler
 
An Introduction To Agile Development
An Introduction To Agile DevelopmentAn Introduction To Agile Development
An Introduction To Agile Developmentelliando dias
 
Testing & should i do it
Testing & should i do itTesting & should i do it
Testing & should i do itMartin Sykora
 
iOS Test-Driven Development
iOS Test-Driven DevelopmentiOS Test-Driven Development
iOS Test-Driven DevelopmentPablo Villar
 
Agile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin NakovAgile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin NakovSvetlin Nakov
 
Waterfallacies V1 1
Waterfallacies V1 1Waterfallacies V1 1
Waterfallacies V1 1Jorge Boria
 

Ähnlich wie Code Retreat (20)

TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019
 
Tdd
TddTdd
Tdd
 
Best pratice
Best praticeBest pratice
Best pratice
 
TDD - Seriously, try it! - Opensouthcode
TDD - Seriously, try it! - OpensouthcodeTDD - Seriously, try it! - Opensouthcode
TDD - Seriously, try it! - Opensouthcode
 
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
Test-Driven Developments are Inefficient; Behavior-Driven Developments are a ...
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In Action
 
Pair Programming: overview and concepts
Pair Programming: overview and conceptsPair Programming: overview and concepts
Pair Programming: overview and concepts
 
Tdd is not about testing
Tdd is not about testingTdd is not about testing
Tdd is not about testing
 
Preocupações Desenvolvedor Ágil
Preocupações Desenvolvedor ÁgilPreocupações Desenvolvedor Ágil
Preocupações Desenvolvedor Ágil
 
Training methdology testers to developers
Training methdology   testers to developersTraining methdology   testers to developers
Training methdology testers to developers
 
Put to the Test
Put to the TestPut to the Test
Put to the Test
 
The Art of Evolutionary Algorithms Programming
The Art of Evolutionary Algorithms ProgrammingThe Art of Evolutionary Algorithms Programming
The Art of Evolutionary Algorithms Programming
 
Interactive Development Environments
Interactive Development EnvironmentsInteractive Development Environments
Interactive Development Environments
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
 
An Introduction To Agile Development
An Introduction To Agile DevelopmentAn Introduction To Agile Development
An Introduction To Agile Development
 
From open source labs to ceo methods and advice by sysfera
From open source labs to ceo methods and advice by sysferaFrom open source labs to ceo methods and advice by sysfera
From open source labs to ceo methods and advice by sysfera
 
Testing & should i do it
Testing & should i do itTesting & should i do it
Testing & should i do it
 
iOS Test-Driven Development
iOS Test-Driven DevelopmentiOS Test-Driven Development
iOS Test-Driven Development
 
Agile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin NakovAgile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin Nakov
 
Waterfallacies V1 1
Waterfallacies V1 1Waterfallacies V1 1
Waterfallacies V1 1
 

Kürzlich hochgeladen

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Kürzlich hochgeladen (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Code Retreat

  • 1. CODE RETREAT $ PROGRAMMERS HONING THEIR CRAFT TOGETHER
  • 2. WHAT IT IS? intensive practice event,  focus on the fundamentals of software development and design,  focus on skill improvement. 
  • 3. WHY WE DO IT? learn through pairing,  extend your comfort zone,  practice,  experiment,  learn new practices. 
  • 4. HOW WE DO IT?  Normally: organized Saturdays,  it takes a full day (6 sessions).   This code retreat: organized Wednesday (October 23rd, 2013),  it takes only 3 hours because of work constraints (2 sessions). 
  • 5. HOW WE DO IT?  introduction - 30 min first session – 45 min  retrospective for first session – 15 min   break – 15 min second session – 45 min  retrospective for second session – 15 min   final retrospective & closing
  • 6. HOW WE DO IT? only pair programming,  switch pairs when session ends,  use any language (preferably C# or Java for this retreat),  delete the code when session ends,  do not try to finish the problem,  focus on practice,  enjoy! 
  • 7. WHY USE CONSTRAINTS? learn new things,  expand our comfort zone,  improve the way we design software,  learn communication through tests (tests as a form of documentation). 
  • 8. WHAT CONSTRAINTS? the four elements of simple design,  no conditionals (if, while, etc),  no primitives (int, boolean etc, just objects),  four lines of code per methods,  law of Demeter (use only one dot per line),  no mouse/touchpad (keyboard only),  no IDE (text editor only),  taking baby steps,  object calisthenics,  immutable objects only. 
  • 9. WHAT? PAIR PROGRAMMING GAMES?  ping pong (one person writes the tests, the other person writes the implementation code to make the test pass),  mute pairing (no one talks, this improves the readability of the code),  mute with find the loophole (AKA evil coder; the implementation person purposely writes the wrong algorithm that still makes the tests turn green. The key is that they have to keep the code very clean all the while. So, no big long if statements parsing on the input parameters.)
  • 10. WHAT ARE THE RULES FOR PING PONG PAIR PROGRAMMING? driver – the one coding at a given moment  copilot – the other developer  1. 2. 3. 4. the driver writes a test and then hands the keyboard to the copilot, the new driver makes the test pass, they refactor together, passing the keyboard as necessary, they reverse roles and start over with a new test.
  • 11. WHAT ENVIRONMENT?  C# Visual Studio IDE (preferably with ReSharper)  NUnit testing framework   Java Eclipse or IntelliJ IDEA IDEs  JUnit testing framework   git bash (or any other git client)
  • 12. WHAT DO WE CODE?  traditionally the Conway's Game of Life,  can also be Tic-Tac-Toe, but this has a small disadvantage: you might be able to finish it in a session which is not so good.
  • 13. WHAT ARE THE RULES? having an infinite 2D orthogonal universe  being given an initial generation called seed  the following rules are applied simultaneously       live cells live cells live cells dead cells revived with with with with < 2 live neighbors die 2 or 3 live neighbors live > 3 live neighbors die exactly 3 live neighbors will be check this online simulation to understand better how it works.
  • 14. FIRST SESSION you have 5 minutes to get prepared,  pick your pair,  use ping pong pair programming,  don’t use constraints,  just get a feel for the problem domain,  start coding (and the countdown timer)! 
  • 15. FIRST SESSION’S RETROSPECTIVE  do you find it easy to delete the code?  why do you think we should do that?  what would happen if you didn’t delete it?
  • 17. SECOND SESSION you have 5 minutes to get prepared,  pick your pair (different than in the first session),  use ping pong pair programming,  pick a constraint,  start coding (and the countdown timer)! 
  • 18. SECOND SESSION’S RETROSPECTIVE is an array the right way to store the cells? (talk about the “primitive obsession” code smell),   what constraints did you choose and why?
  • 19. FINAL RETROSPECTIVE & CLOSING  what, if anything, did you learn today?  what, if anything, surprised you today?  what, if anything, will you do differently in the future?  what can be improved regarding the organization of the code retreat?
  • 20. WANT MORE? Global Day of Code Retreat (#gdcr twitter hash tag),  This year on December 14th,   Legacy Code Retreat – practice writing tests, refactoring, improving the design in existing code (since many of us don’t have the privilege of working on a greenfield project),  Coding Katas – programming exercises which help the programmer to improve his/her skills through practice and repetition.
  • 22. LINKS video introduction to code retreats  how others do it: The Orlando Code Retreat Video  main site: coderetreat.org  awesome site by Uncle Bob: cleancoders.com  coding kata catalogue  the software craftsmanship movement  software craftsmanship community (contributor there) 
  • 23. BOOKS Clean Code by Robert C. Martin The Coding Dojo Handbook by Emily Bache Refactoring by Martin Fowler Working Effectively with Legacy Code by Michael Feathers
  • 25. THE FOUR ELEMENTS OF SIMPLE DESIGN  The code: passes it’s tests (tests always on green),  minimizes duplication (extract methods),  maximizes clarity (better names, SRP, etc),  has fewer elements (less code is better most of the time). 
  • 26. NO CONDITIONAL STATEMENTS no if/while/switch etc statements  the conditional operator (?:) is permitted  boolean expressions are also permitted  you can also use maps instead of switches 
  • 27. NO PRIMITIVES with this we’re trying to fix the “primitive obsession” code smell,  it basically means that you shouldn’t use primitive data types (int, double, boolean, string) to represent domain ideas,  we introduce a Value Object in place of the primitives, and other code spread around will be moved in the Value Object,  this is a way to minimize duplication. 
  • 28. FOUR LINES OF CODE PER METHOD programmers have a way of being “comfortable” with the code: instead of creating a new method for something (too hard), they add code to an existing method making it bigger and harder to test (that is if they have tests at all),  this constraint will force you to use SRP (the Single Responsibility Principle),  an easy way to do this is “extract till you drop” (see Uncle’s Bob Clean Code book) which tells that you should extract new methods from an existing one till you don’t have anything else to extract. 
  • 29. LAW OF DEMETER – IN PLAIN ENGLISH also called the principle of least knowledge,  your method can call other methods in its class directly,  your method can call methods on its own fields directly (but not on the fields' fields),  when your method takes parameters, your method can call methods on those parameters directly,  when your method creates local objects, that method can call methods on the local objects. 
  • 30. LAW OF DEMETER – FUNNY DEFINITION you can play with yourself,  you can play with your own toys (but you can't take them apart),  you can play with toys that were given to you,  you can play with toys you've made yourself.   Real Life™ analogy: when one wants a dog to walk, one does not command the dog's legs to walk directly; instead one commands the dog which then commands its own legs.
  • 31. NO MOUSE/TOUCHPAD (KEYBOARD ONLY) programmers who know keyboard shortcuts (to build, to run tests, to execute) work faster and are usually less distracted,  you should learn the keyboard shortcut equivalents for most of the operations you usually do on the normal work day,  you should know the Windows ones too:  Win + E  open new explorer window,  Alt + D  go to address bar,  etc. 
  • 32. NO IDE (TEXT EDITOR ONLY) this is addressed to those that work the entire day in an IDE (Visual Studio, Eclipse, IntelliJ IDEA, others),  do you know what the IDE does (what commands, what parameters) for you when you compile/build/deploy the code?  can you manage to put the imports/usings by hand?  can you work without syntax highlighting? Using just Notepad (no Notepad++). 
  • 33. TAKING BABY STEPS  a small step is sure and steady, whereas when taking a large step you could be in danger of breaking the tests. Steps - credits to Adrian Bolboaca 1. 2. 3. setup source control repository, setup a timer for 2 minutes interval when you start, write exactly one test: A. B. 4. 5. restart timer (no discussions in between timers), refactor A. B. 6. 7. 8. if the timer rings and the test is red then revert and start over, if the test is green before timer rings then commit. if the timer rings and the refactoring is not complete then revert and start over, if the refactoring is complete before the timer rings then commit. restart the timer (no discussions in between timers), go to step 3, when session time is up delete the code.
  • 34. IMMUTABLE OBJECTS ONLY no setters for object fields,  easier to debug code when there’s nothing that can mutate,  extremely helpful when dealing with concurrency,  applicable to value types. 