AnemicDomainModel icon indicating copy to clipboard operation
AnemicDomainModel copied to clipboard

Dollars Value Object operators

Open alain27espina opened this issue 8 years ago • 1 comments

Hi,

I'm watching your course on pluralsight and it gave me a lot of good ideas on how to implement what you've done in your sample project that i can apply in my future projects. Good stuff...

I just have some questions on Dollars operators particularly the operator *. https://github.com/vkhorikov/AnemicDomainModel/blob/89f8abd2456589a45ee5b49a575ba9bf695ecfb8/After/src/Logic/Customers/Dollars.cs#L37. If i pass a negative multiplier, the Dollars class is now in invalid state because it is negative. Shouldn't the statement be a call to static Create so that it will still go the validation checks?

alain27espina avatar Jan 26 '18 05:01 alain27espina

It should, I've done a mistake here. Both operators (* and +) should call Create. There's also a potential issue with multiplying a e.g. $0.99 value with 0.75 discount. It results in a price that contains a fraction of a cent which is not allowed by Dollars. operator * must round such values to avoid the fractioning.

vkhorikov avatar Jan 26 '18 12:01 vkhorikov