An object contains all the data that defines the characteristics of the object and all the operations that the object can perform. In object-oriented terms, an object's data are called its attributes, and an object's operations are called its methods, as this diagram shows:
![]() |
Objects can represent physical entities such as a computer system, a machine, or a network. Objects can also be conceptual, such as a database, a file, a message, a recipe, or a data type, such as a list or an array. Thus, objects are abstract data types with which you can represent a wide range of knowledge.
Classes and Instances
When you design objects, you encapsulate related knowledge so that it can be shared among other objects in the application. For example, an object might be one of many "types of" similar objects, each with the same characteristics and behaviors. You represent this object-oriented principle by using:
Thus, a class encapsulates the definition of a set of similar instances. Classes provide the structure for the specific knowledge contained in its instances, and instances provide the specific characteristics and behaviors.
For example, you might define a robot class, which has characteristics such as "function," "rate," and "capacity." These characteristics are the attributes of the class. Each instance provides specific values for each of these attributes.
In addition, the robot class might define common behaviors such as "rotate," "reach," and "load program." These behaviors are the methods of the class. Each instance of a class responds the same way to the same method.
Thus, attributes say what an object knows, while methods say what an object does, as this diagram illustrates:
![]() |
For information on how you implement each of these object-oriented principles in G2, see the references in this table:
Inheritance
If one class of objects shares similar characteristics and capabilities with another class of objects, you typically encapsulate the common features into a single class, which is called the superior class. A class that obtains its definition from another class is called a subclass. A subclass obtains its definition from its superior class by a mechanism called inheritance. When one class inherits its definition from another class, the subclass is said to be a "kind of" its superior class, and it only needs to define its unique characteristics and behaviors.
![]() |
For information on how to create a class hierarchy in G2, see Representing Subclasses and Class Hierarchies.
Subsystems
Another aspect of object-oriented design and encapsulation is to identify how objects interact to form subsystems. A subsystem is a set of classes or objects that collaborate to accomplish a set of higher-level responsibilities. In a subsystem, one object is a "part of" a larger, fully-functioning entity. Abstracting the higher-level capability of a subsystem into a single entity is an other example of encapsulation.
![]() |
For information on creating compound objects and workspace hierarchies, see Representing Compound Objects and Workspace Hierarchies.
Information Hiding
You can think of an object as a black box that knows what operations it can perform; however, an object is under no obligation to make known how it performs these operations. Thus, in well designed object-oriented systems, each object should have a public interface and a private representation.
![]() |
By restricting the amount of information about an object that is public, you can more easily maintain, modify, and extend the capabilities of the object.