The Uniform Access Principle states that in an Object-Oriented
programming language, the notation
for invoking an operation
on a class
should be the same whether the operation is implemented through storage
, or in other words whether you are accessing a routine
or data member
Few languages have ever implemented this fully, the most noticeable of those which have been Algol W and Simula 67. This behaviour is easily simulated by never putting data members in the public interface of a class, and instead making clients use member functions of the Get/Set ilk to get or set the data members.
The UAP is only appropriate in a system that supports information hiding to the full (and in a way, implies this), as otherwise a client would be entirely justified in trying to perform an operation such as
x.f = y;
Where f is in fact a routine defined on x! Whereas if they are aware that everything in the public interface of a class is a function, they would not be justified in trying to perform such an action.
If we support the OOP dogma to the full, then the outside world has no business in knowing what a class' internal representation is like, and therefore the UAP is wholly appropriate, as all operations performed on the class would be instructions to the class, never direct mutation of its internal state.