User:Avalkov/sandbox

In Object - Oriented Programming
In Object-Oriented Programming languages, Access Control is a part of the apparatus of achieving Encapsulation, one of four fundamentals of Object-Oriented Programming. The goal is to establish separation between interface (visible and accessible parts of the class) and implementation (internal representation and helper methods).

Also known as data hiding, it ensures exclusive data access to class members (both variables and methods) and protects object integrity by preventing corruption by a client programmer/ client classes.

For example, Java and C++ use public, protected and private access modifiers - keywords which allow a programmer to establish access levels to classes and class members (both data and methods).

Comparison of use of access modifier keywords in different OOP languages:
In Ruby, private methods always have self as a receiver. Therefore, can only be used on the current object.

Attribute Accessors
Special public member methods - accessors (aka getters) and mutator methods (often called setters) are used to control changes to class variables in order to prevent unauthorized access and data corruption.

Interfaces, Multiple inheritance, Mixins
In real world programming, however, sometimes it is more logical to provide a limited access to functionality of one class to objects of another class instead of rewriting the code for it from scratch. Different OOP languages use different methods to accomplish this. In Java, functionality of one class can be made accessible to other classes can be made available to other classes interface

Ruby allows only allows access via object methods