I use this repository to practice applying TDD (test driven development) to solving LeetCode algorithm problems.
There are certain problems, that after having solved them the first time, I'll occasionally revisit to use in a code kata or teaching example. The practice helps me to retain a certain level of proficiency with various languages, development environments and techniques.
A code kata is an exercise in programming which helps programmers hone their skills through practice and repetition. The idea is to take a problem you've already solved, repeat the process of solving, and to reflect upon your technique each time. The concept is used heavily in the martial arts.
LeetCode is a website containing 1000s of algorithm coding practice problems.
The problems on the LeetCode website are representative of the types of algorithm problems that are used in technical interviews by companies like Google and Yelp.
Test Driven Development is a coding discipline where tests are written before the production code.
Robert Martin describes TDD, in his article on the topic, as consisting of two coding cycles:
- micro-cycle
- nano-cycle
- Create a unit tests that fails
- Write production code that makes that test pass.
- Clean up the mess you just made.
-
You must write a failing test before you write any production code.
-
You must not write more of a test than is sufficient to fail, or fail to compile.
-
You must not write more production code than is sufficient to make the currently failing test pass.
The discipline of cleaning up code without changing its behavior is called refactoring. Some of the more common coding problems, that are cleaned up during refactoring sessions, are called code smells.
The website Refactoring Guru describes some of the more common code smells, and the refactorings often used to address them.
The Trnasformation Priority Premise is an advanced concept in TDD for how to evolved code as new test cases are added.
Whereas refactoring is the practice of cleaning up code without changing the code's behavior, code transformation is the practice of incrementally changing a piece of code's behavior by small changes to the code. As each new test is added the code is transformed in the most minimal way possible in order to make the test pass.
The Transformation Priority Premise is Uncle Bob's suggestion of the basic types of transformation that are applied during the TDD coding cycle and the priority in which to apply those transformations.