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

User Manual    [Previous]   [Next]   

W001 Singleton With Non-Lazy Attribute

Umple semantic warning reported when a singleton class has an attribute that is not marked lazy

A singleton class can't have any arguments in its constructor. In general in Umple, unless an attribute is specified as 'lazy', then an argument for the attribute is added to the constructor. In the case of singletons, this is not done. This warning is to let programmer know this. To avoid the warning, add the keyword 'lazy' to all attributes of a singleton class. However, whether or not this is done, the generated code will behave as if it had been done.

Example

// This example generates the warning message
class X {
  singleton;
  Integer x;
}
      

Load the above code into UmpleOnline

 

Solution to The Above So the Message No Longer Appears

// The following shows how to avoid the warning
class X {
  singleton;
  lazy Integer x;
}
      

Load the above code into UmpleOnline