Skip to content

Conversation

BenMorel
Copy link
Member

@BenMorel BenMorel commented Jun 19, 2022

Fixes #55

@BenMorel BenMorel force-pushed the fix_allocate branch 3 times, most recently from d914788 to 75bc1e3 Compare June 19, 2022 22:05
@BenMorel
Copy link
Member Author

@artfulrobot @NCatalani would you mind reviewing this?

Do you think we should change the implementation of allocate() as well?

@bendavies
Copy link
Contributor

bendavies commented Jul 28, 2022

just a FYI, i ran this testcase through moneyphp/money Money::allocate(...), and it returns 2 cents and 1 cents, while brick/money will return 3/0.

@BenMorel
Copy link
Member Author

Thank you @bendavies, I don't think returning 2 & 1 cents makes any sense, and I do believe now that the behaviour described by @artfulrobot, implemented here, is the correct one.

I'm not sure what to do with allocate() now, I feel like this algorithm (distributing the remainder over the first monies) is rarely, if ever, what you really need. What do you think about deprecating/removing this method, @bendavies @artfulrobot @NCatalani?

IMO, allocateWithRemainder() is the only sensible method. What you do with the remainder is very application-specific, and I don't think that the library should offer options here.

@artfulrobot
Copy link

artfulrobot commented Jul 29, 2022

I agree with all that @BenMorel said there; the tests pass; looks good!

To clarify: yes, I'd suggest deprecating allocate().

@bendavies
Copy link
Contributor

bendavies commented Jul 29, 2022

Thank you @bendavies, I don't think returning 2 & 1 cents makes any sense, and I do believe now that the behaviour described by @artfulrobot, implemented here, is the correct one.

yes, i agree - i was just highlighting the difference.

I'm not sure what to do with allocate() now, I feel like this algorithm (distributing the remainder over the first monies) is rarely, if ever, what you really need. What do you think about deprecating/removing this method, @bendavies @artfulrobot @NCatalani?

well, allocate is part of fowlers money pattern, so that would be an argument for keeping it?

@BenMorel
Copy link
Member Author

BenMorel commented Aug 1, 2022

@bendavies

well, allocate is part of fowlers money pattern, so that would be an argument for keeping it?

Sure, but I'd be curious what @martinfowler thinks today, I guess the algorithm he presented in his PoEAA book was just an example of what was possible, but I'm not sure which real-life application it has or if it was actually useful to someone as is.

Moving forward, I'll merge the allocateWithRemainder() method, and let's keep the allocate() method as it is for now. We can always discuss either deprecating it, or renaming it so that it is explicitly tells what it really does later on!

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.

3 participants