- Jun 2023
-
stackoverflow.com stackoverflow.com
-
Conversely, I've never in 16+ years of professional development regretted marking a method protected instead of private for reasons related to API safety
-
I just wanted to tweak Java's BufferedReader to handle custom line delimiters. Thanks to private fields I have to clone the entire class rather than simply extending it and overriding readLine().
-
I'm not saying never mark methods private. I'm saying the better rule of thumb is to "make methods protected unless there's a good reason not to".
-
Marking methods protected by default is a mitigation for one of the major issues in modern SW development: failure of imagination.
-
Been disappointed, surprised or hurt by a library etc. that was overly permissive in it's extensibility? I have not.
-
The old wisdom "mark it private unless you have a good reason not to" made sense in days when it was written, before open source dominated the developer library space and VCS/dependency mgmt. became hyper collaborative thanks to Github, Maven, etc. Back then there was also money to be made by constraining the way(s) in which a library could be utilized. I spent probably the first 8 or 9 years of my career strictly adhering to this "best practice". Today, I believe it to be bad advice. Sometimes there's a reasonable argument to mark a method private, or a class final but it's exceedingly rare, and even then it's probably not improving anything.
Tags
- learned from real-world experience
- good point
- failure of imagination
- software development
- bad advice
- disappointing
- member visibility: make it protected unless you have a good reason not to
- annotation meta: may need new tag
- not:
- surprising
- please elaborate
- reasonable defaults
- member visibility: protected vs. private
- you can't know for sure
- rule of thumb
- member visibility: make it private unless you have a good reason not to
- never say never
- what does this actually mean?
- member visibility: make it public/protected by default so others can override/extend as needed
- extensibility
- can't predict the future
- member visibility
Annotators
URL
-
-
stackoverflow.com stackoverflow.com
-
Are protected members/fields really that bad? No. They are way, way worse. As soon as a member is more accessible than private, you are making guarantees to other classes about how that member will behave. Since a field is totally uncontrolled, putting it "out in the wild" opens your class and classes that inherit from or interact with your class to higher bug risk. There is no way to know when a field changes, no way to control who or what changes it. If now, or at some point in the future, any of your code ever depends on a field some certain value, you now have to add validity checks and fallback logic in case it's not the expected value - every place you use it. That's a huge amount of wasted effort when you could've just made it a damn property instead ;) The best way to share information with deriving classes is the read-only property: protected object MyProperty { get; } If you absolutely have to make it read/write, don't. If you really, really have to make it read-write, rethink your design. If you still need it to be read-write, apologize to your colleagues and don't do it again :) A lot of developers believe - and will tell you - that this is overly strict. And it's true that you can get by just fine without being this strict. But taking this approach will help you go from just getting by to remarkably robust software. You'll spend far less time fixing bugs.
In other words, make the member variable itself private, but can be abstracted (and access provided) via public methods/properties
-
As soon as you make a member not-private, you are stuck with it, forever and ever. It's your public interface now.
-
-
www.typescriptlang.org www.typescriptlang.org
-
Derived classes need to follow their base class contracts, but may choose to expose a subtype of base class with more capabilities. This includes making protected members public:
-
Member Visibility
-
- Apr 2022
-
oer.pressbooks.pub oer.pressbooks.pub
-
Member States
Perhaps this should be addressed not just to Members States, but, more explicitly to educational stakeholders. In many cases, for example the UK (2022), the "Member State" does not really have the means or the disposition to take seriously any of these recommendations. It is down to institutions and professionals within the territory of the Member State to take the lead, and therefore they are the ones to whom this recommendation should be addressed to.
-
-
www.irrodl.org www.irrodl.org
-
participants in the study reported feeling frustrated by the presence of an expert and dominant member who impeded the development of shared understanding and effort.
-
- Dec 2021
-
twitter.com twitter.com
-
Sam Coates Sky. (2021, December 16). For posterity this is what the Joy Morrissey now deleted tweet said: Https://t.co/IZHX2tZrGs [Tweet]. @SamCoatesSky. https://twitter.com/SamCoatesSky/status/1471428868573732876
-
- Oct 2021
-
twitter.com twitter.com
-
Professor Lucy Easthope. (2021, October 20). WFH really is only for a very privileged few now. Not sure how that can stay a “thing” as an NPI. Too many harms being done by a fractured society where people are thriving by getting other people to bring them stuff/ make them things/ look after their family members for them [Tweet]. @LucyGoBag. https://twitter.com/LucyGoBag/status/1450842213613772802
-
- Jul 2021
-
-
Four million additional doses of BioNTech-Pfizer vaccine. (n.d.). [Text]. European Commission - European Commission. Retrieved 29 July 2021, from https://ec.europa.eu/commission/presscorner/detail/en/ip_21_1101
-
- Feb 2021
-
psyarxiv.com psyarxiv.com
-
Rockowitz, S., Stevens, L., Colloff, M., Smith, L., Rockey, J., Ritchie, J., Kanja, W., Cotton, J., & Flowe, H. D. (2020). Patterns of Violence Against Adults and Children During the COVID-19 Pandemic in Kenya. PsyArXiv. https://doi.org/10.31234/osf.io/265nq
-
- May 2020
-
jamanetwork.com jamanetwork.com
-
Gostin, L. O. (2020). COVID-19 Reveals Urgent Need to Strengthen the World Health Organization. JAMA Health Forum, 1(4), e200559–e200559. https://doi.org/10.1001/jamahealthforum.2020.0559
-
- Sep 2018
-
www-tandfonline-com.ezproxy.simmons.edu www-tandfonline-com.ezproxy.simmons.edu
-
ducators being conscious of power dynamicsin the classroom, as well as the importance of seeing oneself as group mem-ber and a group leader, just as a bass player contributes to the foundationof the music and plays a role as a one of the musicians
See glossary of group member roles from week one reading.
-
- Oct 2016
-
www.etymonline.com www.etymonline.com
-
member (n.)
constituent part of a complex structure
Tags
Annotators
URL
-