The tag has no wiki summary.

learn more… | top users | synonyms

-2
votes
2answers
130 views

Why public access level method get overridden in java?

This question is raised with a clarification required to decide when to declare a method protected or public during class design of a package. My point is, if one needs to override a method of a ...
2
votes
1answer
192 views

Is this JS code a good way for defining class with private methods?

I was recently browsing a open source JavaScript project. The project is a straight port from another project in C language. It mostly use static methods, packed together in classes. Most classes are ...
2
votes
1answer
36 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
187 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, ...
9
votes
6answers
2k 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
115 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
481 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
3k 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 ...
3
votes
4answers
593 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 ...
5
votes
5answers
1k 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; } ...
21
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 ...
6
votes
6answers
867 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 ...
2
votes
3answers
345 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 ...
7
votes
3answers
3k 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 ...
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 ...