Basic Mixsets
[Previous]  [Next] 
|
User Manual [Previous]  [Next] Basic MixsetsMixsets 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:
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 ExplanationSyntax// 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]  ) |