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

Dollars Value Object operators #1

Open
alain27espina opened this issue Jan 26, 2018 · 1 comment
Open

Dollars Value Object operators #1

alain27espina opened this issue Jan 26, 2018 · 1 comment

Comments

@alain27espina
Copy link

alain27espina commented Jan 26, 2018

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 *.

public static Dollars operator *(Dollars dollars, decimal multiplier)
. 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?

@vkhorikov
Copy link
Owner

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.

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

No branches or pull requests

2 participants