Skip to content
This repository has been archived by the owner on Aug 5, 2019. It is now read-only.

Attributes : private to protected #435

Open
JulienOrain opened this issue Oct 11, 2013 · 3 comments
Open

Attributes : private to protected #435

JulienOrain opened this issue Oct 11, 2013 · 3 comments

Comments

@JulienOrain
Copy link
Contributor

Hi everyone,
I am wondering why all attributes are private.
Does it make sense for you to upgrade them to protected in order to use them in herited classes ?
Thanks !
Julien

@caarlos0
Copy link
Contributor

Which class, exactly?

@JulienOrain
Copy link
Contributor Author

Most of "*Base" classes possess private attributes.
Usually I can easily handle it with getters/setters, even if I found more logical to use protected attributes in heritable classes.
For my case, I am unable to use private fields from the DateTimeBoxBase class. (autoclose for example do not provide getter)
So I am unable to override the configure() method. An way to fix that is either to give accessors for all attributes or to upgrade attributes visibility.
Is that make sense for you ?

@reinert
Copy link
Contributor

reinert commented Oct 11, 2013

It's not a good practice use protected fields.

It's often better keep fields private and analyze whether they should be exposed using a protected or public getter.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants