Share via


Defining Domain Classes

Domain classes are the main elements of the domain model. You can use domain classes to represent any kind of entity in your domain-specific language. These include states, use cases, and activities.

Root Domain Class

Domain-specific languages have one root domain class, which is associated with the diagram. All Domain-Specific Language Tools solution templates include a root domain class, for example, ExampleModel in the MinimalLanguage solution template. The diagram element has its ClassRepresented property set to the root domain class. 

Adding Domain Classes

To add a domain class to the domain model, in the Toolbox, select either Domain Class or Named Domain Class and drag it to the diagram. (The only difference between a domain class and a named domain class is that the named domain class includes a Name domain property, which is distinct from the name of the domain class itself.) In both cases, a domain class is displayed on the diagram, and also in the DSL Explorer under Domain Classes.

You can add domain properties to the domain class by right-clicking the domain class on the diagram, pointing to Add, and then clicking Domain Property. You can also right-click the domain class in the DSL Explorer and then click Add New DomainProperty.

You must define the relationship of the domain class to the root domain class. All the domain classes in the domain model must be embedded in (in other words, contained by) the root domain class, either directly or indirectly. For more information about embedding relationships, see Defining Domain Relationships.

If you want to delete a domain class, right-click the domain class on the diagram or in the DSL Explorer and then click Delete. You can also select the domain class and then press DELETE.

Inheritance

The relationship between a base class and a derived class is an inheritance relationship. Inheritance relationships do not have names, roles, or multiplicities. To add an inheritance relationship between two classes, select the Inheritance tool in the Toolbox and then draw a line from the derived class to the base class. The relationship will appear on the diagram as a straight line that has a hollow arrow on the end that is nearer the base class.

In the following illustration, the abstract domain class UseCaseElement has a derived class Actor.

Inheritance Relationship

For more information about inheritance, see Inheritance.

Properties of Domain Classes

The domain class has properties such as Access Modifier (public or internal) and Inheritance Modifier (abstract, sealed, or none). For more information about domain class properties, see Properties of Domain Classes.

Presentation of Domain Classes

You can define the appearance of a domain class by adding a geometry shape to the diagram and then mapping the domain class to the shape. To map a shape to a domain class, drag the shape from the Toolbox to the diagram, and then select Diagram Element Map in the Toolbox and draw a line from the domain class to the shape. For more information about how to map elements to shapes, see Defining the Appearance of the Generated Language Designer.

See Also

Other Resources

Domain-Specific Language Tools Glossary

Change History

Date

History

Reason

July 2008

Rewrote and refactored project.

Content bug fix.