🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
MDrivenStart Methods
This page was created by Hans.karlsen on 2020-07-06. Last edited by Wikiadmin on 2026-07-29.

You can define methods in your model to either calculate and return information with OCL or perform data-changing work with action language.

Choose the method type

A method has an IsQuery setting that determines what its body is allowed to do.

IsQuery value Use the method for Method body
true Reading or calculating information without changing model data OCL. Data changes are not permitted.
false Performing an operation that changes model data Action language. Data changes are permitted.

Use a query method when the result can be derived without changing any object. For example, a method that returns a text value calculated from existing attributes is a query.

Use a non-query method when the operation must create, update, or otherwise change data. For example, an operation that changes an attribute value is a non-query method.

Define a method signature

A method signature defines the method name, its input arguments, and its return type. Use this form:

MethodName(argumentName:Type;argumentName:Type):ReturnType

Arguments are separated with semicolons. Each argument has a name followed by a colon and its type. The return type appears after the closing parenthesis.

For example:

MyMethod(argument1:String;argument2:Double):String

In this example:

Part Meaning
MyMethod The method name.
argument1:String An input argument named argument1 with type String.
argument2:Double An input argument named argument2 with type Double.
:String The method returns a String value.

Add a method

  1. Decide whether the method only reads data or must change data.
  2. Set IsQuery to true for a read-only OCL expression, or to false for action language that changes data.
  3. Enter a signature that names each input argument, gives its type, and states the return type.
  4. Write the method body according to the selected method type.
  5. Save the model and check that it is free of validation errors before you run or deploy it. See MDrivenStart:MDrivenStart Verify.

Use methods with the rest of the model

Methods belong with the model elements that describe your application behavior. Keep the method name and arguments focused on the information it works with, and document the surrounding class purpose as needed in MDrivenStart:MDrivenStart Class. You can show the relevant methods on a diagram while hiding unrelated features; see MDrivenStart:MDrivenStart Diagrams.

A method defines behavior in the model. To make behavior available to a user, define the appropriate user action separately. User actions can be global, class-specific, or specific to a ViewModel.

See also