The Difference Between a Passive Object & an Active Object in UML

Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.
UML helps simplify the representation of the internal logic of a program.

The "Unified Modeling Language," or UML, is a language designed to show how software is organized; engineers can use UML to diagram the flow of information in a program, allowing them to better understand how it can be simplified or changed. When modeling information flow, UML distinguishes between "active objects" that can initiate that flow, and "passive objects" that cannot.

Advertisement

Objects and Classes

Video of the Day

When it comes to so-called "object-oriented" programming, computer science differentiates between an "object" and a "class." A class is a generalized description of a set of things—such as variables or methods—whereas an "object" is an "instance" of that class, with its own unique properties. Think of classes as a blueprint or a template; in the physical world, "writing implement" might be considered a class, with "pen" or "orange crayon" examples of "objects" of that particular class type.

Advertisement

Video of the Day

Objects in UML

UML preserves a similar distinction between classes and objects, and they are represented in the same way; UML classes contain broad descriptions, and UML objects contain specific values that represent instances of those descriptions. Formally speaking, therefore, an "active object" in UML is any instance of an "active class," and similarly a "passive object" is an instance of a "passive class"—in a theoretical sense, you could consider these terms to be essentially interchangeable.

Advertisement

Active Objects

In UML, active classes, and therefore active objects, exist in their own thread of operations and have their own address space. If execution, or code activity, is thought of in terms of flow, active objects can start or control that flow. Active objects, in other words, are sequential and do something: modify variables, change program behavior, and so on. In UML, active classes and objects are distinguished by having a thicker border than passive objects.

Advertisement

Passive Objects

Passive objects in UML do not generally have the ability to modify or begin the flow of execution, because they must wait for another object to call them. Instead, passive objects are generally used to store information, and in many cases this information may be shared between multiple other objects. This may allow passive objects to be accessed concurrently, not sequentially. To make sure that the data contained inside has a high integrity, UML allows for passive objects to insist that they be accessed sequentially; if two threads attempt to call the same sequential passive object, that object can delay the second thread until the first has finished with it.

Advertisement

Advertisement

references