IBM Support

Instantiating an abstract class in Rational Software Architect

Question & Answer


Question

In IBM Rational Software Architect and IBM Rational Software Modeler, you can instatiate an abstract class. Why is this allowed, when abstract classes are not meant to be instantiated?

Cause

The following steps demonstrate how you can instantiate an abstract class:

1. Create a UML project and UML model
2. Create a class and mark it as Abstract in the Properties view
3. Create an object diagram and drag the class onto the diagram

Result: An instance is created, when it should not be created.

Answer

If you look more closely at the UML Superstructure v2.1 specifications under Section 7.3.22 InstanceSpecification (from Kernel), you will notice the following:


- under Description: "If the only classifier specified is abstract, then the instance specification only partially describes the entity."
- under Semantics: "When used to specify the existence of an entity in a modeled system, an instance specification represents part of that system. Instance specifications can be modeled incompletely — required structural features can be omitted, and classifiers of an instance specification can be abstract, even though an actual entity would have a concrete classification."

In other words, a model is not treated the same way as code.

In this case, therefore, you are allowed to instantiate an abstract class to represent the case of having an instance of a class that implements all the methods on the abstract class. The result is polymorphic behavior with a known, enforced interface specification.

[{"Product":{"code":"SS4JE2","label":"Rational Software Architect Standard Edition"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Modeling: Diagrams","Platform":[{"code":"PF033","label":"Windows"},{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"7.5.5;7.5.4;7.5.3;7.5.2;7.5.1;7.5","Edition":"","Line of Business":{"code":"LOB36","label":"IBM Automation"}},{"Product":{"code":"SSCLKU","label":"Rational Software Modeler"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Modeling: Diagrams","Platform":[{"code":"PF033","label":"Windows"}],"Version":"7.5;7.5.1;7.5.2;7.5.3;7.5.4;7.5.5","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
29 September 2018

UID

swg21416833