Table Of Contents

Encapsulation of Class Fields and Methods

Last Modified: February 27, 2020

Encapsulation refers to the fact that a class is a single unit made up of class fields and the methods that can access those class field values. VIs not on the class Member List have restricted access to encapsulated class fields.

Class fields have a private access scope setting. Only methods on the class Member List can directly access and manipulate the value of a field on the Data view. Any VI 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.

Restricting access to class data prevents your program from making unintentional changes to class fields and data values of specific class objects. The VI that interacts with the class object can use the class data on the diagram without directly accessing that data.

Grouping 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 class Member List, or a VI external to the class. For example, to change the format of a class field, adjust the control on the Data view of the class.


When you add class functionality to a G Type document, any pre-existing controls and indicators become encapsulated class fields.

Recently Viewed Topics