Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix franc dollar comparison #7

Merged
merged 2 commits into from
Sep 28, 2022

Conversation

kaiosilveira
Copy link
Owner

As we pulled up the equals method to the Moneyclass and resorted all the comparisons against Money object, we've created an unintended side effect: now Dollar and Franc objects are considered equal. This PR fixes this problem by comparing object.constructor.name to the current this.constructor.name, which is basically using a (dirty) resource from the programming language to fix a domain problem, that's why we've added "Currency?" to the bottom of the task list:

  • $5 + 10CHF = $10 if rate is 2:1 🎯
  • $5 * 2 = $10 ✅
  • Make "amount" private ✅
  • Dollar side-effects? ✅
  • Money rounding?
  • equals() ✅
  • Equal null
  • Equal object
  • 5 CHF * 2 = 10 CHF ✅
  • Dollar/Franc duplication
  • Common .equals
  • Common .times
  • Compare Francs with Dollars ✅
  • Currency?

Tasklist:
- $5 + 10CHF = $10 if rate is 2:1 🎯
- $5 * 2 = $10 ✅
- Make "amount" private ✅
- Dollar side-effects? ✅
- Money rounding?
- equals() ✅
- Equal null
- Equal object
- 5 CHF * 2 = 10 CHF ✅
- Dollar/Franc duplication
- Common `.equals` ✅
- Common `.times`
- Compare Francs with Dollars 👈🏼
Tasklist:
- $5 + 10CHF = $10 if rate is 2:1 🎯
- $5 * 2 = $10 ✅
- Make "amount" private ✅
- Dollar side-effects? ✅
- Money rounding?
- equals() ✅
- Equal null
- Equal object
- 5 CHF * 2 = 10 CHF ✅
- Dollar/Franc duplication
- Common `.equals` ✅
- Common `.times`
- Compare Francs with Dollars ✅
- Currency?
@kaiosilveira kaiosilveira merged commit f229981 into main Sep 28, 2022
@kaiosilveira kaiosilveira deleted the chapter7/fix-franc-dollar-comparison branch September 28, 2022 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant