Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Coding dojo

No description
by

Tamas Tompa

on 3 December 2015

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Coding dojo

Coding dojo
What?
Rules
Most important:
One can't discuss a form without
code
,
and one can't show code without
tests
.

It is a design training place, where it is acknowledged that
"the code is the design"
and that code without tests simply doesn't exist.
Environment
Simple / Generic / Easy to reproduce
TDD
Test Driven Development
Demo Kata
Fizz Buzz
Coding Dojo
Meeting
where a bunch of coders
get together to work on a
programming challenge
Code Kata
A
kata
is an exercise in karate where you repeat a form many, many times, making
little improvements
in each.
Deliberate Practice
When you actually seek out experiences that will stretch your skills.
Feedback
not just about the code you produce

but your coding
technique
docker
Homebrew
The next step to take should always be
as small as possible
.
number is divisible by three
you instead say "Fizz"
number is divisible by five
you say "Buzz"
Sample output:
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
Randori Kata
Rules
The challenge is solved by a coding pair (driver and navigator).
Everyone present is invited to help.
Each pair has a small (5 minutes) timebox to advance (using TDD).
At the end of the timebox we shift / change driver and navigator.
Pair programming
Driver
= writes the code

Navigator
= reviews each line of code, "strategic" direction of the work
Code Kata
String Calculator

The method can take 0, 1 or 2 numbers, and will return their sum (for an empty string it will return 0) for example “” or “1” or “1,2”
Start with the simplest test case of an empty string and move to 1 and two numbers
Example with 2 numbers: "4,8" -> 12
Remember to refactor after each passing test
Handle an unknown amount of numbers
Handle new lines between numbers (instead of commas). Example: “1\n2,3” (will equal 6)
Support different delimiters
to change a delimiter, the beginning of the string will contain a separate line that looks like this: “//[delimiter]\n[numbers…]”
for example “//;\n1;2” should return three where the default delimiter is ‘;’
Randori Kata 2.
Number Complement
A complement of a number is defined as the inversion
(if the bit value = 0, change it to 1 and vice-versa) of all bits of the number starting from the leftmost bit that is set to 1.
For example, if N = 5, N is represented as 101 in binary. The complement of N is 010, which is 2 in decimal notation.
Similarly if N = 50, then the complement of N is 13. Complete the function
getIntegerComplement()
. This function accepts N as parameter. The function should return the complement of N.

Constraints :
0 ≤ N ≤ 100000.

Test cases: 50 -> 13, 100 -> 27
Randori Kata 3.
Merge 2 arrays
You are given a function
mergeArrays
which takes in 2 sorted arrays as parameters. The first array has 'M' elements in it, the second one also has 'M' elements, but it's capacity is 2*M. The function mergeArrays takes both the arrays as parameters along with M. Merge the first array into the second array such that the resulting array is sorted.

Sample Input:
1st array: {3,5,6,9,12,14,18,20,25,28}
2nd array: {30,32,34,36,38,40,42,44,46,48 }

Sample Output:
{3,5,6,9,12,14,18,20,25,28,30,32,34,36, 38,40,42,44,46,48}
Randori Kata 4.
Popular Rice Recipe
Did you know that there are over 40,000 varieties of Rice in the world? There are so many dishes that can be prepared with Rice too. A famous chef from Mumbai, Tid Gusto prepared a new dish and named it 'Tid Rice'. He posted the recipe in his newly designed blog for community voting, where a user can plus (+) or minus (-) the recipe. The final score is just the sum of all votes, where (+) and (-) are treated as +1 and -1 respectively. But, being just a chef, he forgot to take care of multiple votes by the same user.

A user might have voted multiple times and Tid is worried that the final score shown is not the correct one. Luckily, he found the user logs, which had all the N votes in the order they arrived. Remember that, if a user votes more than once, the user's previous vote is first nullified before the latest vote is counted. Given these records in order, calculate the correct final score.
Sample Input:
4
tilak +
tilak +
tilak -
tilak +
3
ratna +
shashi -
ratna -
3
bhavani -
bhavani +
bhavani -
Sample Output:
1
-2
-1
Randori Kata 5.
Magneto effect
A popular utility to help drawing is the
magneto
. In short, it means that small screen areas around "important points" are "magnetic". For example, if the mouse moves close enough to a vector endpoint and clicks to start drawing another vector, the new vector will begin in the magnetic endpoint. On the other hand, if the mouse click comes when the mouse cursor is in open space, the draw operation will begin at the cursor location.

Working from the description on the right >>, use TDD to implement a class named "MagnetoEffect" (or something that you find "right") to implement this behaviour.
Example one
If there is a magnetic point at coordinate (50,50) and the magneto effect radius is 5, when the mouse is moved to coordinate (49,50), the magneto effect comes into play and forces the "begin draw point" to be (50,50).

Example two
If there is a magnetic point at coordinate (50,50), when the mouse is moved to (0,0) no mangeto effect affects the begin draw point.

Example three
If there are magnetic points at coordinate (50,50) and (100,50), when the mouse is moved to (101,48), the magnetic effect is to move the begin draw point to (100,50).

Example four
If the magnetic point coordinates are (50,50) and (51,51) and the mouse is moved to (51,52), the magneto at (51,51) forces the begin draw point to be (51,51).
Code Kata 6.
File Lottery
Implement an application which follows the
iterator
design pattern.
This particular application receives a directory as argument, and at each consecutive call, it returns a file name from the directory that hasn’t been returned before, in a random order.
When the application reaches the end of the content of the directory, it shall start over, again returning the directory contents in a random order.
If the directory is empty, then every call shall return an empty string.
If the argument is not a directory but a file, then its name shall be returned on each consecutive call.

The random order makes testing the application quite complicated. In order to do proper testing - have an expected random number in each test case - the random generator shall be injected and mocked or faked.
Iterator by definition
Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Example Iterator in Javascript
http://www.dofactory.com/javascript/iterator-design-pattern
Sample Input:
"/var/files"

Sample Output:
1.txt
4.txt
2.txt
Code Kata 7.
Logger extension
Extend your
FileLottery
with
logging
abilities!

Add a new Logger class.
Every time you call Logger.add(string), the result will be logged somewhere.
But just use a mock for your tests.

Log all the following events within FileLottery:
Found a directory with N number of files
Randomized the content of the directory
Gave back a file for next() call
No files available (empty result)

When calling add() from FileLottery and the logger throws an exception, you should
notify a Webservice
that logging has failed with the message from the logger’s exception (you will need a mock and a stub).
Full transcript