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

User Manual    [Previous]   [Next]   

W107 Names Differ Only By Case

Umple semantic warning reported when two or more classes or interfaces, attributes of a class, or mixsets have names that differ only in case

Names such as Ping and PinG, or apple and apPle, are distinct identifiers to Umple and to languages such as Java, but they are easily confused by people and can lead to defects (see CWE-178). They also cause concrete problems in generated code. Each class and interface becomes a file named after it, so when two of them are generated into the same directory on a case-insensitive file system, such as the defaults on Windows and macOS, one file overwrites the other. Attribute names are capitalized to form method names, so apple and apPle produce setApple and setApPle, which PHP treats as the same method. Mixsets named, for example, M1 and m1 are separate mixsets, and a use statement that names one of them does not include the other.

Class and interface names are compared together. The attributes of a class are compared with each other, including those it inherits from its superclasses and those it gets from traits; the same letters in unrelated classes are fine. Mixsets are compared wherever they are declared, including inside method bodies. The message lists all the names that clash and points at the first of them that duplicates an earlier one. A clash with an inherited attribute is reported once, at the subclass attribute that introduces it. When the names differ only in the case of their first letter, such as attr and Attr, the generated methods are identical and error E048 is reported as well when Java or PHP code is generated. To avoid the message, rename the elements so their names differ by more than their case.

The first example below is not compiled when the manual is built, since its generated code shows exactly these problems: on some file systems and in PHP it does not compile.

Example

// This example generates the message three times:
// for the classes, the attributes and the mixsets
use Logging, logging;

mixset logging class Account {
  logLevel;
}

mixset Logging class Account {
  logFile;
}

class Customer {
  firstName;
  firstname;
}

class CUSTOMER {}

      

Load the above code into UmpleOnline

 

Solution to The Above So the Message No Longer Appears

// The following shows how to avoid the message:
// names differ by more than their case
use Logging;

mixset Logging class Account {
  logLevel;
  logFile;
}

class Customer {
  firstName;
  preferredName;
}

class CorporateCustomer {}

      

Load the above code into UmpleOnline