Modo, Easy Modeling Language

Documentation

Elements

Modo is used for describing systems. For better understanding, the system, its subsystems, its super system (the system that encompasses the system that is in focus), its environment and context can be separated into meaningful pieces. This approach has different names for different disciplines (e.g. Systems approach, object-oriented design). This approach is handy for analyzing and modeling systems. Sharing the same point of view, Modo offers separation of systems into signicifant unique pieces for modeling. These pieces are called "Elements" in Modo syntax. This chapter gives information about the declaration and usage of elements in Modo syntax.

Declarations

Declarations are used for representing the real-life system entities as Modo elements. There are three types of declarations:

  1. Assignments
  2. Basic Declarations
  3. Extended declarations

Following sections give detailed information about declarations.

Assignments

Real-Life entities can have properties and sub elements. In Modo, these properties and sub elements are called "Member Elements".

Declaration of the elements can be made by assigning values to the member elements. In the following example assignments are used to declare the Company element.

Company Name = String;
Company Founder = String;
Company TaxNumber = String;
Company $Name = "Doe Software Inc.";
Company $Founder = "John Doe";
Company $TaxNumber = "123456789987654321";
                

The example above shows the declaration of Company element. On line 1, Name attribute is defined and on line 4 the value "Doe Software Co.,Ltd." is assigned. On line 2, Founder attribute is defined and on line 5, the value "John Doe" is assigned. Finally, on line 3, TaxNumber attribute is defined and on line 6, the value "123456789987654321" is assigned.

Basic Declarations

Basic declarations are the typical element declarations in Modo syntax.

Following example shows the basic declaration of Company element:
Company {
    Name = String;
    $Name = "Doe Software Inc.";
    Founder = String;
    $Founder = "John Doe";
    TaxNumber = String;	
    $TaxNumber = "123456789987654321";
}
                

The example above shows the declaration of Company element. Declaration of the Company element starts on line 1. Company element has three attributes called Name, Founder and TaxNumber. These attributes are defined on lines 2, 4 and 6 respectively; and their values are assigned on lines 3, 5, and 7. Finally, Company element declaration ends with end declaration symbol on line 8.

Extended declarations

Element declarations can be made by extending built-in or previously defined elements. The extended element carries all the properties of the parent element. Additionally, extended element can have its original member elements.

Following are the basic declarations of the Worker element and the Developer element which extends the Worker element:
Worker {
    Name = String;
    Surname = String;
    Department = String;
}
                

The above example is the basic declaration of the Worker element. On line 1, the declaration of the element starts. On lines 2, 3 and 4, the member elements Name, Surname and Department are defined respectively.

Developer = Worker {
    $Department = "Software Development";
    Expertise = String;
}
                

On line 1, Developer element is declared extending the Worker element. With this assignment, extended declaration of the Developer element starts. On line 2, a value, "Software Development", is assigned to the Department element. In the above example the Department element belongs to the Worker element.  So in line 2, the Developer element extends the Worker element via assigning a value to an existing member element. However in line 3, a new member element Expertise, which belongs only to Developer element, is defined. So this time, the Worker element is extended via defining a new member element.

Using elements

Declaration process of the Modo elements is not limited to specifying the member elements, but it also includes relating them with each other and other Modo elements. This section gives details about using elements.

Member elements

In Modo syntax, all the properties/attributes of an element are also elements, which are called member elements. Member element declaration starting without any preceding characters, defines the type of the member element. The type of the member elements can be a built-in or previously declared element.

When the definition of the member element starts with the dollar symbol "$", this assignment specifies the initial value of this element in the system. If the initial value is assigned with a rule, then that value will be condition dependent.

Following is the Modo declaration of the Company element:

Company {
    Name = String;
    $Name = "Doe Software Inc.";
    $Name = "DOE Corp." @ ($CurrentYear > 2008);
    Founder = String;
    $Founder = "John Doe";
    TaxNumber = String;
    $TaxNumber = "123456789987654321";	
}
                

In the above example, on lines 2, 5 and 7, the member elements Name, Founder and TaxNumber are declared respectively. Their types are also specified as String, which is another built-in or previously declared element. On lines, 3, 6 and 8 initial values are assigned with the help of dollar symbol "$". On line 4, a different value is assigned to the Name member element, but this time depending on a rule ($CurrentYear > 2008).

Modo syntax also allows nested declarations where the member elements can extend an existing element. This nested declaration is one of the ways to define the relationship between the elements.

Following examples shows the nested declaration of member elements:

Worker {
    Name = String;
    Surname = String;
    Department = String;
}
                

The example above shows the declaration of the Worker element. On lines 2, 3 and 4, the member elements Name, Surname and Department are declared respectively.

Department {
    DepartmentName = String;
    Manager = Worker{
       $Department = $DepartmentName;
    }
}
                

The above example shows the declaration of the Department element. On line 2, DepartmentName member element is declared. On line 3, member element Manager is declared extending the element Worker. On line 4, the value of the Department member element of the Manager element is assigned to the value of the DepartmentName member element.

Accessing member elements

The value of built-in elements, previously declared elements or member elements could be used while declaring the member elements.

Following examples give details about accessing member elements:

Worker {
    FirstName = String;
    LastName = String;
    FullName = String;
    $FullName = ($FirstName + " " + $LastName);
}
                

The example above shows the declaration of Worker element. On line 5, the value of the FullName member element is assigned using an expression that accesses the values of the FirstName and LastName member elements of the Worker element.

Worker {
    $FirstName = "";
    $LastName = "";
    $FullName = ($FirstName + " " + $LastName);
}

Department {
    DepartmentName = String;
    Manager = Worker{
       Title = String;
       $Title = "Manager " + $FullName;
    }
}
                

Above is an example of accessing element attributes in extended declaration. On line 11, Title attribute is assigned a value using an expression which accesses FullName attribute of the Worker element.

Functions and member methods

Modo syntax does not allow the definition of user defined functions and member methods. However, Modo generators/compilers/interpreters can provide some built-in functions and member methods.

This section gives information about using built-in functions and member methods in Modo declarations.

Following example shows the use of member methods in Modo declarations:

Worker {
    FirstName = String;
    LastName = String;
    FullName = String;
    $FullName = ($FirstName + " " + $LastName);

    /* FormatCurrency function takes 2 parameters
     * param1: Amount
     * param2: Decimal Count
     */
    Salary = String;
    $Salary = FormatCurrency(1500, 2);
}
                

The example above shows the use of member methods in Modo declarations. On line 12, the value of the Salary member element is specified by the return value of FormatCurrency function. FormatCurrency function takes two parameters:

  1. Currency amount and
  2. Decimal count

The value of the Salary member element becomes "1500.00".

Warning: FormatCurrency function used in the example above only shows the use of member methods. This function is not a part of Modo syntax.

Note: The above examples assume that the element String has already been declared.