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

User Manual    [Previous]   [Next]   

Basic Mixsets

Mixsets can be used to create different members of the same product line from a given Umple model, or to help divide the system into features for feature-oriented development. They can also be seen as providing conditional compilation capabilities such as those commonly found in C++ or C.

Mixsets are one of several separation-of-concerns capabilities available in Umple. The others being mixins, traits, aspect orientation and filters.

A mixset is a named set of fragments of Umple code that may or may not be included in the system. A mixset is included using a use statement or a command line argument, in the same manner that a .ump file is included. So, taken together the fragments can be seen as a virtual file.

When a use statement (or command line argument) matching the mixset's name is encountered, then the fragments comprising the mixset are mixed in to the Umple code using Umple's mixin mechanism, which allows multiple definitions of an entity such as a class to be combined.

A mixset fragment can be defined in the following ways:

  • At the top level of any Umple file, simply by the notation mixset name followed by a block in curly brackets. The block in curly brackets can be any Umple code.
  • Within a class, trait or other top-level entity. In this case the contents of the block are included in that entity (if a matching use statement is encountered).

Example

// Initially there are two classes with no attributes
class X {}
class Z {}

// In another place, potentially a separate file.
// class X is given attribute a
// This is a simple mixin
class X {
 a;
}
 
// In a third place we conditionally want to
// include attribute b, perhaps only in certain
// versions of the software.
mixset specialVersion {
  class X {
    b;
  }
}

// To activate the specialVersion mixset we need
// to encounter the following
use specialVersion;

// We can also have another 'fragment' of
// the specialVersion mixset elsewhere
mixset specialVersion {
  class X {
    c;
  }
}

// The following notations can also be used
class X {
  mixset specialVersion {d;}
}

// Any features of a class can be incorporated
// using a mixset including the following
// Here we introduce a second mixset
mixset specialVersion2 {
 class Z {p;}
}

class X {
  mixset specialVersion2 {
    isA Z;
    0..1 -- * Z;
  }
}

use specialVersion2;

// The following mixset will be ignored since
// there is no use statement for it
mixset specialVersion3 {
 class W {}
}

      

Load the above code into UmpleOnline

 

YouTube Video with Additional Explanation

 
 

Syntax


// Anything inside a class that is not parsable by Umple is passed on to the base language
// compiler. To raise warnings when this occurs, use the strictness directive.
extraCode- : [**extraCode]

mixsetDefinition : mixset [mixsetName]
  ( [[mixsetInnerContent]]
    | [[requirement]]
    | [[mixsetInlineDefinition]]
  )

mixsetInnerContent- : { [[extraCode]] | [[reqImplementation]] }

mixsetInlineDefinition- :
  ( [entityType] [entityName]
  ( [[mixsetInnerContent]]
    | [entityOneElement]
  )
    | [oneElement]
  )