list of dots Digital Research Alliance of Canada logo  NSERC logo  University of Ottawa logo / UniversitĂ© d'Ottawa

User Manual    [Previous]   [Next]   

E040 Singleton Has Subclasses

Umple semantic error generated when a singleton class has subclasses

Singleton is a software pattern to allow only one instance of a class. A singleton class has a private constructor and cannot be inherited.

Example

// In this example a singleton class
// has subclasses and it generates an error
class Airplane
{
  singleton;
}
class F16
{
	isA Airplane;
}
      

Load the above code into UmpleOnline

 

Solution to The Above So the Message No Longer Appears

//I this example the singleton class
// does not have a subclass and is correct
class Airplane
{
  
}
class TheAirplane
{
  singleton;
}
class F16
{
	isA Airplane;
}
      

Load the above code into UmpleOnline