-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
document conventions about public vs private API #7561
Comments
I don't think that the "fields are private, methods are public" convention is particularly universal. I generally don't like trivial setter/getter functions. Part of the decision for me is where the type sits on the inheritance hierarchy. If it's a concrete type and field access feels natural then I use the direct access. If it's an abstract type I'm much more likely to define a method so that subtypes are free to implement the access as they choose. If I'm subtyping and the supertype already has an access method as part of its API, then I'd use that method and consider the referenced field to be private. I do rather like the python convention of leading underscores for private fields (e.g. |
One of the things I like about the |
Wouldn't it be wildly confusing if |
I don't know, I think that would be fine – the |
close JuliaLang#12064 close JuliaLang#7561 Co-authored-by: Spencer Russell <spencer.f.russell@gmail.com>
Provides some guidelines, in addition to those added recently by JuliaLang#40533 to the style-guide, per JuliaLang#7561.
close JuliaLang#12064 close JuliaLang#7561 Co-authored-by: Spencer Russell <spencer.f.russell@gmail.com>
Provides some guidelines, in addition to those added recently by JuliaLang#40533 to the style-guide, per JuliaLang#7561.
close JuliaLang#12064 close JuliaLang#7561 Co-authored-by: Spencer Russell <spencer.f.russell@gmail.com>
Provides some guidelines, in addition to those added recently by JuliaLang#40533 to the style-guide, per JuliaLang#7561.
In the discussion of #1974 there seems to be an implicit consensus that accessing information via the
a.b
syntax is part of the "private" API, and the "public" API consists of calls likeb(a)
. The canonical example seems to be that ifa
is aFloatRange
objecta.step
is not a useful value for public purposes, wherestep(a)
is.Depending on how that issue is resolved the convention may change somewhat, but in either case there will be some preferred convention. That convention should be documented, and so far is not as far as I could tell. Perhaps the Types section of the manual makes sense?
The text was updated successfully, but these errors were encountered: