Skip to content

Commit

Permalink
Updated comments and added instructions and agenda for the coding doj…
Browse files Browse the repository at this point in the history
…o facilitator.
  • Loading branch information
lucaminudel committed Nov 16, 2014
1 parent 65ee3ed commit b653eea
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 36 deletions.
56 changes: 24 additions & 32 deletions TDDMicroExercises.ProposedSolution/General comments.rtf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{\rtf1\ansi\ansicpg1252\cocoartf1187\cocoasubrtf400
{\rtf1\ansi\ansicpg1252\cocoartf1343\cocoasubrtf140
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid1\'01\uc0\u8259 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}
Expand All @@ -12,52 +12,46 @@
{\list\listtemplateid9\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid801\'01\uc0\u8259 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid9}
{\list\listtemplateid10\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid901\'01\uc0\u8259 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid10}
{\list\listtemplateid11\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid1001\'01\uc0\u8259 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid11}
{\list\listtemplateid12\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid1101\'01\uc0\u8259 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid12}
{\list\listtemplateid13\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid1201\'01\uc0\u8259 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid13}
{\list\listtemplateid14\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid1301\'01\uc0\u8259 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid14}
{\list\listtemplateid15\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid1401\'01\uc0\u8259 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid15}}
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}{\listoverride\listid3\listoverridecount0\ls3}{\listoverride\listid4\listoverridecount0\ls4}{\listoverride\listid5\listoverridecount0\ls5}{\listoverride\listid6\listoverridecount0\ls6}{\listoverride\listid7\listoverridecount0\ls7}{\listoverride\listid8\listoverridecount0\ls8}{\listoverride\listid9\listoverridecount0\ls9}{\listoverride\listid10\listoverridecount0\ls10}{\listoverride\listid11\listoverridecount0\ls11}{\listoverride\listid12\listoverridecount0\ls12}{\listoverride\listid13\listoverridecount0\ls13}{\listoverride\listid14\listoverridecount0\ls14}{\listoverride\listid15\listoverridecount0\ls15}}
\paperw11900\paperh16840\margl1440\margr1440\vieww28600\viewh16520\viewkind0
{\list\listtemplateid12\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{hyphen\}}{\leveltext\leveltemplateid1101\'01\uc0\u8259 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid12}}
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}{\listoverride\listid3\listoverridecount0\ls3}{\listoverride\listid4\listoverridecount0\ls4}{\listoverride\listid5\listoverridecount0\ls5}{\listoverride\listid6\listoverridecount0\ls6}{\listoverride\listid7\listoverridecount0\ls7}{\listoverride\listid8\listoverridecount0\ls8}{\listoverride\listid9\listoverridecount0\ls9}{\listoverride\listid10\listoverridecount0\ls10}{\listoverride\listid11\listoverridecount0\ls11}{\listoverride\listid12\listoverridecount0\ls12}}
\paperw11900\paperh16840\margl1440\margr1440\vieww28600\viewh16500\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural

\f0\fs48 \cf0 General comments
\fs36 \

\fs28 \
\
Questions for all the exercises
Questions valid for all the exercises
\fs24 \
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls1\ilvl0\cf0 {\listtext \uc0\u8259 }Have you started writing tests (how have you dealt with external dependencies) or refactoring CODE (how have you ensured not to change behavior/introduce a bug) ?\
\ls1\ilvl0\cf0 {\listtext \uc0\u8259 }What prevented you to write your first unit test?\
{\listtext \uc0\u8259 }How did you overcome that obstable?\
{\listtext \uc0\u8259 }Which unit-test did you write first?\
{\listtext \uc0\u8259 }Which was your first smallest refactoring in order to make the class more unit-testable?\
{\listtext \uc0\u8259 }How did you ensure that your refactoring didn\'92t add any bug?\
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls2\ilvl0\cf0 {\listtext \uc0\u8259 }What changes have you made in order to make the class unit-testable ?\
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls3\ilvl0\cf0 {\listtext \uc0\u8259 }What violations of SOLID principles have you noticed ?\
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls4\ilvl0\cf0 {\listtext \uc0\u8259 }Which unit tests did you write ?\
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls5\ilvl0\cf0 {\listtext \uc0\u8259 }Did you make small steps refactoring that do not break client code ?\
\ls2\ilvl0\cf0 {\listtext \uc0\u8259 }Have you spot any violation of SOLID principles in the initial code? Where? \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\cf0 \
\
\

\fs28 TirePressureMonitoringSystem, class Alarm\

\fs24 External dependency here is the Sensor that return random values.\
\fs24 The external dependency here is the Sensor that return random values.\
SOLID violations\
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls6\ilvl0\cf0 {\listtext \uc0\u8259 }The instantiation of Sensor in the constructor violate the OCP and the DIP\
\ls3\ilvl0\cf0 {\listtext \uc0\u8259 }The instantiation of Sensor in the constructor\'92s body violates the OCP and the DIP\
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls7\ilvl0\cf0 {\listtext \uc0\u8259 }What about the hi/low pressure thresholds? Having them as constant is a violation of the OCP\
\ls4\ilvl0\cf0 {\listtext \uc0\u8259 }What about the hi/low pressure thresholds? Having them as constant is a violation of the OCP\
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls8\ilvl0\cf0 {\listtext \uc0\u8259 }What about the expression that check if the pressure is inside the expected interval, is a violation of the OCP?
\ls5\ilvl0\cf0 {\listtext \uc0\u8259 }What about the expression that check if the pressure is inside the expected interval? It\'92s a violation of the OCP
\fs28 \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural

\fs24 \cf0 \
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls9\ilvl0\cf0 Look [1]\
\ls6\ilvl0\cf0 Look [1]\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\cf0 \
\
Expand All @@ -66,14 +60,12 @@ Questions for all the exercises
\fs28 UnicodeFileToHtmTextConverter, class UnicodeFileToHtmlTextConverter
\fs24 \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\ls10\ilvl0\cf0 External dependency here is the file from the file-system.\
\ls7\ilvl0\cf0 The external dependency here is the file from the file-system.\
SOLID violations \
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls10\ilvl0\cf0 {\listtext \uc0\u8259 }Access to the file system's Open method and to the file violate the OCP and DIP.\uc0\u8232 Note the use of static methods and the access to 3rd party libraries, those are smells for OCP and eventually DIP violations.\u8232 Note the access to the file-system or any other external system. That's a smell for OCP and eventually DIP violations.\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\cf0 Note the call to the static method of an external class library, that's an high coupling with the library.\
\ls7\ilvl0\cf0 {\listtext \uc0\u8259 }Access to the file system's Open method and to the file violate the OCP and DIP. That's a smell for OCP and eventually DIP violations.\
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls11\ilvl0\cf0 {\listtext \uc0\u8259 }When you call ConvertToHtml() multiple times after the refactoring does it still works?\
\ls8\ilvl0\cf0 {\listtext \uc0\u8259 }When you call ConvertToHtml() multiple times after the refactoring, does it still work or have you introduced a bug?\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\cf0 \
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
Expand All @@ -86,10 +78,10 @@ Questions for all the exercises
\fs28 TurnTicketDispenser, class TicketDispenser
\fs24 \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\ls12\ilvl0\cf0 External dependency here is the Turn Number sequence.\
\ls9\ilvl0\cf0 The external dependency here is the Turn Number sequence.\
SOLID violations \
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls12\ilvl0\cf0 {\listtext \uc0\u8259 }Access to the singleton TurnNumberSequence via the static method GetNextTurnNumber() violate the OCP and DIP.\uc0\u8232 Note the use of static methods to access a singleton, is a smells for violation of encapsulation and for OCP and eventually DIP violations.\
\ls9\ilvl0\cf0 {\listtext \uc0\u8259 }Access to the singleton TurnNumberSequence via the static method GetNextTurnNumber() violate the OCP and DIP.\uc0\u8232 Note the use of static methods to access a singleton, is a smells for violation of encapsulation and for OCP and eventually DIP violations.\
{\listtext \uc0\u8259 }How to access a singleton/static through an instance and keep the existing code working?\
{\listtext \uc0\u8259 }How to break the dependency to the concrete type TurnTicket and enable the instantiation of multiple objects?\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
Expand All @@ -104,13 +96,13 @@ Questions for all the exercises
\fs28 TelemetrySystem, class TelemetryDiagnosticControls
\fs24 \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\ls13\ilvl0\cf0 External dependency here is TelemetryClient with random connection failures.\
\ls10\ilvl0\cf0 The external dependency here is TelemetryClient with random connection failures.\
SOLID violations \
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls14\ilvl0\cf0 {\listtext \uc0\u8259 }Interesting, this time the most interesting violation is not in the class under test\'85 :\
\ls11\ilvl0\cf0 {\listtext \uc0\u8259 }Interesting, this time the most interesting violation is not in the class under test\'85 :\
Faking with a mock object the TelemetryClient reveal a violation of SRP from TelemetryClient\
\pard\tx220\tx720\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\li720\fi-720\pardirnatural
\ls15\ilvl0\cf0 {\listtext \uc0\u8259 }The instantiation in the constructor of the concrete class TelemetryClient that access an external system (the Telemetry server) is a violate the OCP and DIP.\
\ls12\ilvl0\cf0 {\listtext \uc0\u8259 }The instantiation in the constructor of the concrete class TelemetryClient that access an external system (the Telemetry server) is a violate the OCP and DIP.\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural
\cf0 \
Look [1] and [2]\
Expand Down
40 changes: 36 additions & 4 deletions TDDMicroExercises/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
# Refactoring legacy code driven by tests - Kata
# Refactoring legacy code driven by tests - Coding Dojo

In this repository you'll find source code for four distinct coding challenges in Java, C#, Ruby, JavaScript and Python. You also find the [slides with the instructions] (https://github.com/lucaminudel/TDDwithMockObjectsAndDesignPrinciples/blob/master/Slides/Refactoring-legacy-code-driven-by-tests-full.pdf?raw=true) you can use in a coding dojo.
## Facilitator Instructions and Coding-Dojo Agenda

## Instructions

- Provide attendees with [Quick Start instructions](https://github.com/lucaminudel/TDDwithMockObjectsAndDesignPrinciples/blob/master/Slides/Quick%20Start.pdf?raw=true) to setup the IDE and load the first exercise; for public events consider sending in advance the code via email or providing Usb keys

- List the languages supported and help the attendees to organize in pairs based on they favorite language and ensuring that attendees less familiar with the language, the IDE or the test framework will pair with someone more experienced

- Check that all pairs have successfully loaded the 1st exercise and succeeded to write and run a first sanity check or empty unit test. Provide help where required.

- Introduce the scope of the coding-dojo and provide basic guidelines about pair-programming and iterative gradual approach to refactoring and unit test writing.

- Present the instructions for the 1st exercise ([here are the slides](https://github.com/lucaminudel/TDDwithMockObjectsAndDesignPrinciples/blob/master/Slides/Refactoring-legacy-code-driven-by-tests-full.pdf?raw=true))

- Now it’s coding time, for at least 30 minutes

- Let attendees present their solutions and facilitate group discussions ([here are comments about the exercises for the facilitator](https://github.com/lucaminudel/TDDwithMockObjectsAndDesignPrinciples/blob/master/TDDMicroExercises.ProposedSolution/General%20comments.rtf))

- Show the proposed solution and discuss the design improvements and the refactoring steps

- Present the instructions for the following exercise and repeat as before; do it for all the exercises you want to cover during the dojo

- Discuss with the group general approaches to start unit testing and refactoring legacy code-bases

- Present and discuss with the group the slide about the relation between TDD and good design

- Ask for final comments, thanks attendees and end the coding-dojo.

#### Timing

You can count about 90 minutes per exercise: you can organize a 90 minutes dojo with just one exercise, a 90+90 minutes dojo with 2 exercises or a whole day coding dojo with 2 exercises in the morning (90+90 minutes) and 2 exercises in the afternoon (90+90 minutes).
The time required for the opening and the closing of the dojo is almost always the same, so for a 1-exercise version of the coding-dojo you could have to run a little faster.



## Develpers’ Instructions

This could be code you just inherited from a legacy code-base. Now you want to write unit tests for it, and that is harder than it needs to be.

Expand Down Expand Up @@ -46,7 +78,7 @@ Share your solutions [here] (https://github.com/lucaminudel/TDDwithMockObjectsAn

## Credits

Thanks to [Emily Bache] (https://github.com/emilybache) for the Python version of the exercises and for including this kata in [The Coding Dojo Handbook] (https://leanpub.com/codingdojohandbook) by Emily Bache with foreword by Robert C. Martin.
Thanks to [Emily Bache] (https://github.com/emilybache) for the Python version of the exercises, for the Scala and C++ versions of some of the exercises, and for including this kata in [The Coding Dojo Handbook] (https://leanpub.com/codingdojohandbook) by Emily Bache with foreword by Robert C. Martin.
Thanks to [Peter Rhys Thomas] (https://github.com/peterrhysthomas) for theporting to Java.
Thanks to [Sam Serpoosh] (https://github.com/Sam-Serpoosh) for the porting to Ruby.
Thanks to [Arthur Almeida] (https://github.com/arthuralmeidap) for the porting to PHP.
Expand Down

0 comments on commit b653eea

Please sign in to comment.