Table Of Contents

Encapsulation of Class Fields and Methods

Version:
Last Modified: September 25, 2017

Encapsulation consolidates the fields of a class and methods that can access the values of those fields into a single unit. This consolidation restricts the access that VIs not on the class member list have to the class fields.

Class fields have a private access scope setting. Only methods on the Member List of the class G Type document can directly access and manipulate the value of a field on the Data view. Any VI that is not on the class member list must interface with a public access scope class method to interact with the data values of a class object on the diagram.

The restriction of access to class data prevents your program from making unintentional changes to the fields of a class and the data values of specific class objects. The VI that interacts with the class object does not need to know how a class stores its data in order to use the data on the diagram.

The grouping of data and member VIs allows you to separate your code into clearly defined segments. Segmenting the code you write can prevent changes you make to one class method from causing issues in the other methods on the Member List of the class, or a VI external to the class. For example, to change the format of a class data attribute you only need to adjust the control on the Data view of the G Type document.

spd-note-note
Note  

If the G Type document already contains controls and indicators when you add class functionality to the document, they are encapsulated and become class fields.


Recently Viewed Topics