Questions tagged [access-modifiers]

Access modifiers control where variables can be accessed. The common ones are public, protected, and private. Use this tag for access issues caused by access modifiers.

42 questions
2
votes
6 answers

When to sensibly use public variable in an OOP language?

After I learned to properly use private protected abstract sealed in a language like C# I found no reason to make a variable public ever again. An interface to the variable is usually a public method if it is an action/verb (e.g. Car.Move()), or if…
5argon
  • 129
1
vote
1 answer

How to motivate adaptive an shifting class access modifiers

At the new client, we had a discussion regarding access modifiers for classes, methods, members etc. One opinion was to keep things as private as possible, only allowing for protected (internal, public) level when necessary. The opposite opinion was…