-
Notifications
You must be signed in to change notification settings - Fork 138
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
All classes that have builders should lock down their constructors. #382
Comments
This is a great idea. I'm guilty of not making it official (that you can only build these things in the RightWay™). I'd vote for
This leads to very clean and readable code: |
A note on |
I thought `internal` methods were obfuscated in Java?
…On Thu, Apr 29, 2021 at 11:59 AM Adam Arold ***@***.***> wrote:
A note on internal: it won't hide the methods for Java consumers, for
that you need to use @JvmSynthetic, but it is not recommended by the
Kotlin guidelines so we might want to leave them internal.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#382 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAACTAJNNXXKZA67SJDTOGDTLGUANANCNFSM43XN3UHQ>
.
|
Unfortunately not :( They will be visible as |
Well, we'll do the best we can, plus it'll be documented. Kinda ugly but we could even mark the constructors as |
Let's keep the |
Right now classes like AppConfig and ShortcutsConfig have Builder classes that should be used exclusively for constructing instances of those classes, but this isn't guaranteed because the constructors are public, so users could actually use either. Some functionality, like that introduced in #381, assumes users will be using the Builders. Plus it'd be nice to have one Right Way to do things.
Potentially every class with a builder in our Builders package needs to be examined, but the builders themselves also need to be examined. AppConfigBuilder, for example, itself has a public constructor.
The end goal here is for there to be one way to build these things, for simplicity for the builder and to make things easier for the Zircon maintainers. Every public API class in Zircon should conform to one of the following patterns:
TheClass.newBuilder().build()
method.Phase 0
Phase 1
@Deprecated
annotation to all constructors/methods that are currently public, but shouldn't be.Phase 2 (next major version?)
@Deprecated
annotations added in Phase 1.The text was updated successfully, but these errors were encountered: