Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

History of access control modifiers such as public/private/protected

Tags:

oop

history

How did these keywords and concepts come to life? What were the forces and problems that made them appear? What was the first language to have them?

Actually, it's not just about public/private/protected, but rather the whole range of keywords that enforce some rules (abstract, final, internal).

But, please, do not assume things. Answer if you know at least part of the answer or answer if you lived those moments. References are greatly appreciated.

like image 561
Ionuț G. Stan Avatar asked Aug 26 '09 12:08

Ionuț G. Stan


People also ask

What are private public protected modifiers?

The private modifier specifies that the member can only be accessed in its own class. The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.

What is the difference between public and protected access modifiers?

Protected access modifiers allow the data members to be accessed by class, package, subclass (same package), subclass (different package). The difference between public and protected is that public can be accessed from outside class but protected cannot be accessed from outside class.

What is difference between default and public modifier and protected and private access modifier?

Default: The access level of a default modifier is only within the package. It cannot be accessed from outside the package. If you do not specify any access level, it will be the default. Protected: The access level of a protected modifier is within the package and outside the package through child class.


2 Answers

Simula (1967), considered to be the first OO language, has modifiers called protected and hidden. I assume that public is the default, I can't remember. It also uses virtual.

And, with thanks to Pavel, Simula introduced the most important keywords (and concepts) of class, this, new, downcasting and reference types.

Smalltalk (1980), a later but much more fundamental OO language, gave us Methods responding to Messages. This basically is the same functionality as virtual functions. Messages and Classes were later imitated in C (non-OO) to give the Windows API polymorphic behavior. But still needing ugly switch-statements and function pointers to replace inheritance.

The first use of Properties was, as far as I know, in Delphi (Object Pascal, < 1994).

like image 52
Henk Holterman Avatar answered Oct 12 '22 19:10

Henk Holterman


public, private and protected access modifiers come from C++. It seems that public and private already existed in "C with classes", short lived precursor of C++. This is probably detailed in The design and Evolution of C++.

I think abstract and final come from Java and internal from C#.

like image 30
philant Avatar answered Oct 12 '22 19:10

philant