coding kata
DESCRIPTION
The introductory presentation to the Coding Kata weekly exercises.TRANSCRIPT
Coding Kata
•How to improve your technical skills
through deliberate practice
•Cezar Coca, Silviu Eigel
•12/14/2011
2
Kata
• Kata (形, or more traditionally, 型) (literally: "form")
is a Japanese word describing detailed patterns of
movements practiced either solo or in pairs. Karate
Kata are executed as a specified series of a variety of
moves, with stepping and turning, while attempting
to maintain perfect form.
• A code kata is an exercise in programming which
helps a programmer hone their skills through
practice and repetition.
3
Deliberate Practice
•Done over a long period of time is at the heart of attaining expertise (10k hours)
•Different than experience gained while doing your job (pressure-free)
• Learning through Deliberate Practice requires:
• A state of discomfort
• A lot of self discipline
• Exposing your weaknesses
• Exposing yourself to other people’s tricks
• Seeking out experiences that stretch your skills and give you feedback
•Musicians do it through the practice of scales and arpeggios. So do martial arts experts
• I’ve been intending to sit down and do a kata for as long as I know of them
4
What we will practice – TDD
• Test-driven development (TDD) is a software development technique that relies on the
repetition of a very short development cycle
5
What we will practice – Pair Programming
• It's more fun and less expensive than it sounds: two programmers at one computer
•One drives; the other navigates. Switching roles fluidly, they constantly communicate.
Together, they accomplish better work more quickly than either could alone.
• The driver types
• He focuses on tactics--writing clean code that compiles and runs
• The navigator focuses on strategy
• How the code fits into the overall design
• Which tests will drive the code forward
• Which refactoring will improve the entire codebase
6
String Calculator Kata
• Create a simple String calculator with a method int Add(string numbers)
• 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
• Remember to solve things as simply as possible so that you force yourself to write tests you did not think about
• Remember to refactor after each passing test
• Allow the Add method to handle an unknown amount of numbers
• Allow the Add method to handle new lines between numbers (instead of commas).
• the following input is ok: “1\n2,3” (will equal 6)
• the following input is NOT ok: “1,\n” (not need to prove it - just clarifying)
• 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 ‘;’ .
• the first line is optional. all existing scenarios should still be supported
• Calling Add with a negative number will throw an exception “negatives not allowed” - and the negative that was
passed. If there are multiple negatives, show all of them in the exception message
7
thank you
Cezar Coca, Silviu EigelGeeks