-
Notifications
You must be signed in to change notification settings - Fork 452
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
reduce public footprint of ev contrib #2888
Conversation
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.
Thanks! It looks good to me.
Some thoughts:
-
I think making things package-protected and final is good in general. From time to time though, we are asked to remove some of these restrictions from some classes, because there is no better alternative. So I hope/assume we will get a feedback if we break someone else's code without leaving a reasonable workaround.
-
I often use factory methods inside a specific class/interface or interface-specific util (e.g.
ElectricFleets
), so things are more local and we avoid having big util classes (but maybe sometimes it leads to too many small utils here and there).I also think there is this naming policy for util classes to suffix them with
s
(e.g.Collectors
,Arrays
,Collections
,Executors
,Files
orObjects
).However, I do not have strong opinions on these (
Utils
as a suffix is fine, having factory methods in utils is fine).
Regarding I mostly use the former, and I do not remember I've ever run into any issues with that. This is maybe related to the fact how I write tests:
I guess eager singletons may cause problems in "half-setup" scenarios ("medium complexity unit tests"). Or maybe there are some other cases where it also causes problems? Out of curiosity, do we have such issues mentioned/reported somewhere? Anyway, I do not see any reason against switching to latter type. I can do it also in the dvrp-related contribs. |
Discussion re guice singletons moved to here: https://docs.google.com/document/d/1CSvPcMKrPy-0j_RBvMEyCyqqDq_JH1snFkGUlTrLIKM/edit#bookmark=id.b0vhu3gcrbgc .
|
Discussion re constructors/factories moved to here: https://docs.google.com/document/d/1CSvPcMKrPy-0j_RBvMEyCyqqDq_JH1snFkGUlTrLIKM/edit#bookmark=id.nzodxwmhc9gb
|
@kainagel @michalmac I can prepare a PR for that |
Sounds good. |
bringing this closer to matsim standards (e.g. all static methods combined into one *Utils class; replace constructors by static factory methods in that *Utils class; then make implementing classes package-protected; make injected constructors non-public so that classes can only be instantiated through injection; ...).
can we still do this or is it too late (i.e. too many users)?
(If you prefer having the factory in the implementing class rather than in the *Utils class, that would be fine with me, and maybe even a bit more logical in the long run. Everywhere where it was like that I have left it like that, and we could also do it for the other implementing classes. It is just a little harder to audit, since one has to look into the class to make sure that it does not have a public constructor.)