Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
Add notes from "Clean Craftsmanship"
Browse files Browse the repository at this point in the history
  • Loading branch information
lealceldeiro committed Sep 6, 2023
1 parent 91946ce commit 4120eb2
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions CleanCraftsmanship/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ the system behaves as specified.
The essence of TDD entails the discipline to do the following:

- Create a test suite that enables refactoring and is trusted to the extent that passage implies deployability.
That is, if the test suite passes, the system can be deployed.
That is, if the test suite passes, the system can be deployed.
- Create production code that is decoupled enough to be testable and refactorable.
- Create an extremely short-cycle feedback loop that maintains the task of writing programs with a stable rhythm and
productivity.
productivity.
- Create tests and production code that are sufficiently decoupled from each other so as to allow convenient
maintenance of both, without the impediment of replicating changes between the two.
maintenance of both, without the impediment of replicating changes between the two.

### The Three Laws of TDD

1. The First Law: Write no production code until you have first written a test that fails due to the lack of that
production code.
production code.
2. The Second Law: Write no more of a test than is sufficient to fail or fail to compile. Resolve the failure by
writing some production code.
writing some production code.
3. The Third Law: Write no more production code than will resolve the currently failing test. Once the test passes,
write more test code.
write more test code.

Benefits of applying these three laws:

Expand All @@ -60,6 +60,26 @@ Benefits of applying these three laws:
- You will produce a test suite that will give you the confidence to deploy.
- You will create less-coupled designs.

### The fourth law

Refactoring: First you write a small amount of failing test code. Then you write a small amount of passing production
code. Then you clean up the mess you just made.

Rule 1: Write the test that forces you to write the code you already know you want to write.

Rule 2: Make it fail. Make it pass. Clean it up.

Rule 3: Don't go for the gold.

> When you go for the gold too early, you tend to miss all the details around the outside. Also, you tend to miss
> the simplifying opportunities that those ancillary details provide.
Rule 4: Write the simplest, most specific, the most *absurdly simple starting point* test that will fail.

Rule 5: Generalize where possible.

> As the tests get more specific, the code gets more generic.
## Part I: Standards

## Part I: Ethics

0 comments on commit 4120eb2

Please sign in to comment.