Skip to main content
Skip table of contents

Relationships

Classes can have relationships with each other and with other elements:

  • Two classes can be associated. This structural relationship specifies that objects of one type are connected to objects of another type. In Designer context, this is configured via the class properties types.

  • A class can inherit properties and operations (methods) from another class via a generalization. In Designer context, this is configured by defining a Base Class.

  • A class can realize one or multiple interfaces. In Designer context, this is configured by configuring Interfaces on the class.

Association

There is an association between two classes, if an instance of one class must know about the other in order to perform its work.

Have a look at the class diagram below.

grafik-20250521-130032.png

Customers have an address, which is represented in a separate Address class. This class is linked to the Customer class via an association called address. In the Designer, this is defined by adding a property address to class Customer, having the type Address.

Associated classes are not instantiated automatically when their associated classes are instantiated. They need to be created as well.

CODE
create customer;

results in

JSON
{
  "name": null,
  "phoneNumber": null,
  "address": null
}

Wheras

CODE
create customer;
create customer.address;

results in

JSON
{
  "name": null,
  "phoneNumber": null,
  "address" {
    "street": null,
    "zipCode": null,
    "city": null
  }
}

Generalization

A generalization defines a relationship from a child class (a more specific class) to a parent class (a more general class). The child class is fully consistent with the parent class, and provides additional information.

Our ACME example company sells adapters and connectors. Both are article types of the company that share some properties but do also have dedicated properties that apply to the distinct type.
The class diagram below shows the shared definitions in class Article, and the classes Adapter and Connector that each derive from Article.

grafik-20250521-133643.png

Adapters have a direction and connectors have a color (both marked in orange). The category of adapters is "Adapter", the category of connectors is "Connector". Apart from that, they share the common properties of ACME articles like name, category, price and serviceInterval.

All articles can be serialized using the serialize() operation.

  • Article.serialize() is an abstract operation that has no implementation (see example service). However, we could have implemented a general serialization here.

  • Adapter.serialize() and Connector.serialize() each implement a different serialization format.

For the implications of overriding operations of base classes, refer to Polymorphism.

Polymorphism_ArticleSerialization_Example

Click here to download a simple example model that shows how model polymorphism in Scheer PAS Designer.

Realization

In the Designer, you can define interfaces (see Interfaces) that subsequently are realized by concrete classes. This is done by specifying the Interfaces attribute on the related classes.

  • The same interface can be realized by multiple classes.

  • One class can realize multiple interfaces.

The realizing class must implement all operations provided by the interface.

Related Content

Related Pages:

  • Relationships

    Classes can have relationships: associations, generalizations, and realizations.

  • Polymorphism

    How polymorphism can be implemented using the Designer.

  • Interfaces

    How to define and use interfaces in the Designer.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.