The access-modifiers tag has no wiki summary.
2
votes
1answer
29 views
Object pointer with privileged access?
Let's say you have
class Car with Car->tune() and Car->drive()
class CarDriver
class CarMechanic
Each CarDriver and CarMechanic object has a reference/pointer to a Car object.
The CarDriver ...
0
votes
3answers
162 views
When to use default access modifier?
I want to understand, from design point of view, in what situations I should use default access modifier, and when I shouldn't.
I found this related question, that provides some basic explanations, ...
8
votes
6answers
1k views
Why did Java make package access default?
I'm asking this question because I believe they did it for a very good reason and that most people do not use it properly, well from my experience in industry so far anyway.
But if my theory is true ...
3
votes
1answer
108 views
Is avoiding the private access specifier in PHP justified?
I come from a Java background and I have been working with PHP for almost a year now. I have worked with WordPress, Zend and currently I'm using CakePHP. I was going through Cake's lib and I couldn't ...
1
vote
1answer
371 views
How can you denote the access modifiers “friend” and “protected friend” in UML?
The symbols for access modifiers that I know are relevant for many different languages:
public: +
private: -
...
10
votes
6answers
2k views
In Java, why were protected members made accessible to classes of the same package?
From the official documentation...
Modifier Class Package Subclass World
public Y Y Y Y
protected Y Y Y N
no modifier Y Y N ...
-4
votes
1answer
948 views
Java: Public, Private, Protected [duplicate]
When and why should I use and what's the difference between, public, private and protected variables inside a class?
Public
public static void main(String[] arguments) {
// ...
}
...
6
votes
6answers
725 views
Organizing Class Members in Regards to Access Modifier
If we look at typical implementation of a Class, we usually see the private members defined at the beginning and public( mostly functions and Accessors) defined towards the bottom. Now, is this a ...
5
votes
5answers
817 views
Using a SetProperty method to prevent accidental changes to a property
Is it good/bad practice to do the following:
public class MyClass {
public MyType MyProperty { get; private set; }
public void SetMyProperty(MyType myProperty) {
MyProperty = myProperty;
}
...
2
votes
3answers
319 views
Want to know performance issues of Class types & access modifiers
Someone suggested me to mark classes as SEALED that are not being inherited anywhere. I was using default style and was not concerned with the type of class. At present I don't have a benchmark tool ...
18
votes
3answers
3k views
Why aren't there explicit access modifiers in Python:
If 'explicit is better than implicit', why aren't there explicit access modifiers in Python: Public, Protected, Private, etc.?
I know that the idea is that the programmer should know what to do ...
7
votes
3answers
2k views
Should I use default access modifier or not — Coding practice?
Normally when creating new global variables I do not define its access modifier. So as per java it will adopt property default access modifier. When I'm need to access that variable in out of default ...
3
votes
4answers
531 views
How do you remember encapsulation types for effective use?
I've been attempting to learn C#.NET for the past month or so, and the array of ideas that seems to always trip me up is encapsulation. As this is one of the three pillars of OOP, I feel that I am ...
12
votes
6answers
2k views
Real-world scenarios for protected methods
Today I noticed that I basically never use protected methods in C++ code, because I rarely feel the need to call non-public methods of a parent. I do use protected in Java in the template method ...