-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
Privatize circle radius and add a constructor/getter #340
Conversation
Signed-off-by: Daniel Egger <[email protected]>
b71ba3d
to
3ff5f24
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the pull request, @therealprof!
What is the justification for making radius
private? In the absence of specific reasons, I think that public fields should be preferred, for the following reasons:
- It's less code/complexity.
- You can use destructuring assignment and pattern matching.
- You can use struct update syntax.
I previously merged similar pull requests for types in the math
module. I think those made sense, because those types benefited from validation on construction (which I believe has been implemented for them, since then). I don't think the same holds true for fj::Circle
and other types from fj
.
I believe that any validation of fj
types should happen on the kernel side. Primarily, because we might get parallel implementations of fj
in other languages at some point, and duplicated code should be kept to a minimum.
The reason (and this should be obvious from the other PRs) is that requiring to construct a specific object directly directly ties the model code to a specific version and requires to provide all information, even if it could/should be defaulted thus preventing further extension without breaking all existing models. The I was also thinking that in the future we might want to accept/use more specific types for some arguments which allow for validation (where it makes sense) and provide automatic type conversion so people don't have to use unwieldy fixed primitive data types like |
Closing in favor of #343, which contains the commit from this pull request. |
Signed-off-by: Daniel Egger [email protected]