list of dots University of Ottawa logo / Université d'Ottawa

User Manual    [Previous]   [Next]   

Traits and Umple Mixins

In the same way Umple supports mixins to compose classes, traits can also be composed in this way. This means that a trait can be defined in several places or files and when they are used by clients, all elements defined in those separate places will be applied to clients.

The example 1 depicts two definitions for trait T1 (lines 4 and 8). Class C1 uses trait T1 and implement the required method method1() and also obtains two provided methods method2() and method3().


  Example 1: showing how traits are combined with
  Umple mixins.

  To see different diagram views in UmpleOnline:
    Use control-g for auto-layout as a class diagram
    Use control-r to switch between trait view and
       plain classes resulting from applying traits
    Use control-m to show/hide methods
trait T1{
  void method1();
  void method2(){/*impl… */ }
trait T1{
  void method3(){/*impl… */ }
class C1{
  isA T1;
  void method1(){/*impl… */ }    

Load the above code into UmpleOnline