Browse Prior Art Database

Use preserve keyword for highly secure data

IP.com Disclosure Number: IPCOM000243798D
Publication Date: 2015-Oct-17
Document File: 3 page(s) / 38K

Publishing Venue

The IP.com Prior Art Database

Abstract

Disclosed is a method for governing the access of class member data by a friend function or friend class in order to provide flexibility for better encapsulation and thus evangelizing the adoption of friend functions/classes in other object oriented programming languages that currently achieve near similar functionality using complex methods. This will also frees friend functions/classes from being guilty of violating the encapsulation principles.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 50% of the total text.

Page 01 of 3

Use preserve keyword for highly secure data

Disclosed is a method for governing the access of class member data by a friend function or friend class in order to provide flexibility for better encapsulation and thus evangelizing the adoption of friend functions/classes in other object oriented programming languages that currently achieve near similar functionality using complex methods. This will also frees friend functions/classes from being guilty of violating the encapsulation principles.

Taking C++ as reference,

Class Members:

Data hiding is one of the important features of Object Oriented Programming which allows preventing the functions of a program to access directly the internal representation of a class type. The access restriction to the class members is specified by the labeled public, private, and protected sections within the class body. The keywords public, private, and protected are called access specifiers.

A public member is accessible from anywhere outside the class but within a program. You can set and get the value of public variables without any member function.

A private member variable or function cannot be accessed, or even viewed from outside the class. Only the class and friend functions can access private members.

A protected member variable or function is very similar to a private member but it provided one additional benefit that they can be accessed in child classes which are called derived classes.

Inheritance:


Public Inheritance: When deriving a class from a public base class, public members of the base class become public members of the derived class and protected members of the base class become protected members of the derived class. A base class's private members are never accessible directly from a derived class, but can be accessed through calls to the public and protected members of the base class.

Protected Inheritance: When deriving from a protected base class, public and protected members of the base class become protected members of the derived class.

Private Inheritance: When deriving from a private base class, public and protected members of the base class become private members of the derived class. Friend functions or friend classes of the derived class can thus access the data of base class too.

When we talk about private members for a class, it's mostly related to highest encapsulation level for operating on the data. On the other side, a friend function or a friend class is what gets access to it which in some ways is actually a violation of encapsulation principle. Though there are benefits of using friend functions/classes in some scenarios, there may be cases where some private data needs to be encapsulated from even friend functions/classes.

The proposal here is to have a new label or access specifier named 'preserved' which will have the affect similar to private label in addition to encapsulating class members from friend functions or friend classes. Advantages of it can be s...