Is it acceptable to talk about instances of an abstract class?

Viewed 64

I am part of a working group that is developing an IEEE standard. The problem domain of the standard is expressed as an object-oriented model. The model is independent of any particular implementation language but does use UML to express aspects of the model. In many places in the text there are references to "instances of Foo" where Foo is an abstract class. What is really meant is, "instances of any instantiable subclass of Foo".

It has always been my experience that the "instances of Foo" was understood to mean "instances of any instantiable subclass of Foo". Is this understanding something that most people versed in object-oriented models would share? If so, is there some good reference that we can point to that would support this understanding? If this isn't something that is commonly understood then we need to change a lot of text, but that's the way it goes.

2 Answers

The question has two aspects, firt what is correct in senso of UML and second how is it understood in reality. Let us start with the simpler aspect. The UML standard clearly states that any instance of a classifier is also an instance of any of its generalizations

An instance of a Classifier is also an (indirect) instance of each of its generalizations. Any Constraints applying to instances of the generalizations also apply to instances of the Classifier.

This just gives a very static view on it. But and is not the compelete answer, because it does not say anything about how the instances can be used dynamically. But the standard also states that any instance can be used as an instance of any its generalized classifiers:

Type conformance means that if one Type conforms to another, then any instance of the first Type may be used as the value of a TypedElement whose type is declared to be the second Type. A Classifier is a Type, and conforms to itself and to all of its generalizations.

So in that case the standard is quite clear.

Second aspect, the reality. In reality most of the practically applied OOP languages support polymorphism. Simplified spoken, any object of class can be treated as if it were an object of any of its super classes. Thus most people intepretete it like you meant it.

Therefore I would propose to use it in the proposed way in your standard and additionally write this in an introductionary chapter as an help for interpretation.

All refernces are to OMG UML 2.5.1.

Having just gone back (again) to the OMG standard for UML and searched through it again I found this text:

An instance of a Classifier is also an (indirect) instance of each of its generalizations.

Furthermore, in clause 9.7.5 it uses the text

each instance of Person

in reference to a model shown in Figure 9.22.
enter image description here

In Figure 9.22, class Person is abstract. I think this pretty clearly resolves this in favor of , "instances of Foo," being completely correct and acceptable.

Related