Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kaiosilveira/tdd-money-example
Implementation of "The money example", chapters 1 to 16 of the "Test-Driven Development by Example" book, by Kent Beck
https://github.com/kaiosilveira/tdd-money-example
javascript tdd
Last synced: about 2 months ago
JSON representation
Implementation of "The money example", chapters 1 to 16 of the "Test-Driven Development by Example" book, by Kent Beck
- Host: GitHub
- URL: https://github.com/kaiosilveira/tdd-money-example
- Owner: kaiosilveira
- Created: 2022-09-28T18:46:42.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-17T15:41:33.000Z (almost 2 years ago)
- Last Synced: 2024-05-01T19:32:48.249Z (9 months ago)
- Topics: javascript, tdd
- Language: TypeScript
- Homepage: https://github.com/kaiosilveira/test-driven-development
- Size: 105 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Continuous Integration](https://github.com/kaiosilveira/tdd-money-example/actions/workflows/ci.yml/badge.svg)](https://github.com/kaiosilveira/tdd-money-example/actions/workflows/ci.yml)
âšī¸ _This repository is part of my TDD series, please refer to [kaiosilveira/test-driven-development](https://github.com/kaiosilveira/test-driven-development) for the full picture_
# TDD by example - Part I: The Money Example
This repository contains a working implementation of "The money example" (chapters 1 to 16) of the "Test-Driven Development by Example" book, by Kent Beck.
## How to navigate this repo
The code path presented in the book was implemented here using pull requests. Each pull request contains the code for a full chapter, with multiple commits. Each chapter can be seen as an implementation checkpoint until we reach the main goal. There will be a link to the merged pull request for each chapter.
When viewing a pull request, go to the "Commits" tab to see the step-by-step code until the checkpoint is reached. Each commit will have the following pattern:
- The commit title
- The checklist for the implementation, containing all items we need to change/fix before considering ourselves doneThe uppermost commit is the first commit made against the pull request, and the last commit in the list is the last part of the code implemented. So, to keep the chronology of changes, I'd suggest going from top to bottom when looking at the commits. There are also two buttons, "< Prev | Next >", in the Commits tab to navigate between commits.
Here's an example:
```console
implement general case to satisfy multiplicationTask list:
- $5 + 10CHF = $10 if rate is 2:1 đ¯
- $5 * 2 = $10 â
- Make "amount" private
- Dollar side-effects?
- Money rounding?
```Some emojis were used to hint on what's being currently done in terms of code for that specific commit. The rules for using emojis are described below:
| Emoji | Usage |
| ----- | ------------------------------------------------- |
| đ¯ | identifies the list item containing the main goal |
| đđŧ | The list item we're currently working on |
| â | Items already finished |## Goal
The goal of this project is to make a system able to perform the following operation:
```
$5 + 10CHF = $10 if rate is 2:1
```### Implementation
| Chapter | Pull request |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| #1: Multi-currency money | [Add initial Dollar class with the capability of being multiplied by scalars](https://github.com/kaiosilveira/tdd-money-example/pull/1) |
| #2: Degenerate objects | [Fix dollar side effects](https://github.com/kaiosilveira/tdd-money-example/pull/2) |
| #3: Equality for all | [Add equality logic for Dollar](https://github.com/kaiosilveira/tdd-money-example/pull/3) |
| #4: Privacy | [Make dollar.amount private](https://github.com/kaiosilveira/tdd-money-example/pull/4) |
| #5: Franc-ly speaking | [Introduce Franc (CHF) class](https://github.com/kaiosilveira/tdd-money-example/pull/5) |
| #6: Equality for All, Redux | [Remove duplication between Dollar and Franc](https://github.com/kaiosilveira/tdd-money-example/pull/6) |
| #7: Apples and Oranges | [Fix Franc-Dollar comparison](https://github.com/kaiosilveira/tdd-money-example/pull/7) |
| #8: Makin' Objects | [Introduce factory methods Money.franc and Money.dollar](https://github.com/kaiosilveira/tdd-money-example/pull/8) |
| #9: Times We're Living in | [Introduce the concept of currency](https://github.com/kaiosilveira/tdd-money-example/pull/9) |
| #10: Interesting Times | [Pull up times method to Money](https://github.com/kaiosilveira/tdd-money-example/pull/10) |
| #11: The Root of All Evil | [Delete Franc and Dollar subclasses](https://github.com/kaiosilveira/tdd-money-example/pull/11) |
| #12: Addition, Finally | [Implement money addition](https://github.com/kaiosilveira/tdd-money-example/pull/12) |
| #13: Make It | [Implement real reduce operation for bank ](https://github.com/kaiosilveira/tdd-money-example/pull/13) |
| #14: Change | [Reduce mixed currency money](https://github.com/kaiosilveira/tdd-money-example/pull/14) |
| #15: Mixed currencies | [Add support to sum mixed currencies](https://github.com/kaiosilveira/tdd-money-example/pull/15) |
| #16: Abstraction, Finally | [Add .plus and .times to Expression interface](https://github.com/kaiosilveira/tdd-money-example/pull/16) |