list of dots

User Manual    [Previous]   [Next]   

W042 Namespace Cannot Be Default

Umple warning reported when an entity cannot be in the default namespace

If you declare an entity in the default namespace and then declare another entity that extends, implements, or has an association with the first entity, this warning is issued. The reason for the warning is that if two related entities are in different namespaces, import will be generated for those entities, and many programming laguages do not support import from the default namespace. Therefore, the namespace for entities in the default namespace will be changed.

Example

// Classes A, B and C are in the 
// default namespace. Class D is in
// namespace m. All these classes are
// linked to each other via associations,
// therefore, and because they are not all
// in the same namespace, an import text
// will be generated. However, many programming
// languages do not support import from
// the default namespace so the namespace of
// C will become m because it is linked to
// D, and the same goes for B because C is 
// now in namespace m, and then A is placed 
// in m because B is now in m.

class A{}
class B{*--*A;}
class C{*--* B;}
namespace m;
class D{*--* C;}
namespace -;


// The same issue occurs when an
// entity in a non-default namespace
// extends or implements an entity
// in the default namespace

interface E{}
interface F{isA E;}
interface J{isA F;}
namespace n;
interface K{isA J;}


// Here an import text will be generated for D in X
// because D is in a different namespace
// This feature is not yet supported for interfaces
// and the import text will not be generated for K in Y

namespace p;
class X{isA D;}
// interface Y{isA K;}
      

Load the above code into UmpleOnline