5 ms·
Martin Fowler's money pattern [0] solves this problem. Just make sure whenever you're dealing with currencies to use a value object for money, rather than float
by huseyinkeles 7y ago
Martin Fowler's money pattern [0] solves this problem. Just make sure whenever you're dealing with currencies to use a value object for money, rather than float. Lots of languages have libraries for this pattern. [1]
[0] - https://www.martinfowler.com/eaaCatalog/money.html https://www.martinfowler.com/eaaCatalog/money.html
[1] - https://github.com/topics/fowler-money-pattern https://github.com/topics/fowler-money-pattern
- war1025 7y agoOne thing I've always wondered is who the heck is Martin Fowler and why does he have such a following?
- jefft255 7y agoHe wrote influential software engineering textbooks on patterns, agile development, refactoring and the like. I'm not sure how relevant he is today, but in the 90s the ideas he presented were pretty groundbreaking.
- exdsq 7y agoI recommend his blog. He was, and I think might still be, ahead of the curve regarding software engineering patterns etc. There was an article shared on HN which hit #1 from a startups tech blog talking about their brand new architecture and someone pointed out MF wrote about an identical architecture pattern in 2004 or something.
- gnaritas 7y ago> One thing I've always wondered is who the heck is Martin Fowler and why does he have such a following? You don't know the history of your craft; study more, look into where agile came from, the extreme programming movement, and who was involved and how refactoring became a thing. Names like Ward Cunningham, Kent Beck, Martin Fowler, Ron Jeffries, Rob Martin, and Dave Thomas should be familiar to anyone who knows their craft.
- wruza 7y agoI think I’ve read some of them, but it would be nice to refill my bookshelf with classics. Could you please recommend a re-starter kit of these authors’ top books?
- gnaritas 7y agoThey're not all writers, some just invented things like the Wiki. The original wiki, the portland pattern repository, was a hotbed of discussion among those programmers about the practices that eventually became known as agile. It was an amazing place to hang out and debate patterns, languages, and architecture with other passionate developers. There's been nothing like it since. But from the writers: * Refactoring * Patterns of Enterprise Application Architecture * Smalltalk Best Practice Patterns * Agile Software Development, Principles, Patterns, and Practices * Domain-Driven Design * Structure and Interpretation of Computer Programs * The Pragmatic Programmer * Design Patterns * Analysis Patterns * Implementation Patterns Fowler is the most prolific writer of the bunch, but he was largely documenting and naming what he saw all of them doing.
- Scirra_Tom 7y agoIt looks like the amount is stored as an int, which could overflow when dealing with Bitcoin if you're using Satoshi's as a subunit.