DiagramElements-Connection/en: Unterschied zwischen den Versionen

Aus expecco Wiki (Version 2.x)
Zur Navigation springen Zur Suche springen
K
(8 dazwischenliegende Versionen von einem anderen Benutzer werden nicht angezeigt)
Zeile 1: Zeile 1:
== Introduction ==
== Introduction ==


A connection is used to interconnect two [[DiagramElements-Pin|pins]] in an activity diagram. Depending on the type of the pins, the connection models either a data flow- or a control flow-connection.
A connection is used to interconnect two [[DiagramElements-Pin|pins]] in an activity diagram. Depending on the type of the pins, the connection models either a data flow- or a control flow-connection.


[[DiagramElements-Pin#Input Pin|Input pins]] can only be connected with [[DiagramElements-Pin#Output Pin|output pins]] and the [[Datatype|datatypes]] of the pins must be compatible. That means they either have the same type or the input pin has a "more general" type than the output pin (e.g., for [[Datatype#Numeric Types|numeric types]], Number is more general than both Integer or Float. Inputs with an [[Datatype#Any|"Any" datatype]] are most general and can consume any value.
[[DiagramElements-Pin#Input Pin|Input pins]] can only be connected with [[DiagramElements-Pin#Output Pin|output pins]] and the [[Datatype|datatypes]] of the pins must be compatible. That means they either have the same type or the input pin has a "more general" type than the output pin; e.g., for [[Datatype#Numeric Types|numeric types]], Number is more general than both Integer or Float. Inputs with an [[Datatype#Any|"Any" datatype]] are most general and can consume any value.


Outputs can be connected to multiple input pins, but each individual connection consists of exactly one input and one output pin. If an output pin has more than one connection, an outgoing value is sent to all connected inputs (concrete: a reference to the same datum-object is sent to all inputs). Thus, you should be careful with data object which contain state, and are mutated (modified) by an action. If that is the case, you should ensure proper synchronization to avoid time/execution order dependencies during execution (eg. with control flow connections between trigger-in/trigger-out pins).
Outputs can be connected to multiple input pins, but each individual connection consists of exactly one input and one output pin. If an output pin has more than one connection, an outgoing value is sent to all connected inputs (concrete: a reference to the same datum-object is sent to all inputs). Thus, you should be careful with data object which contain state, and are mutated (modified) by an action. If that is the case, you should ensure proper synchronization to avoid time/execution order dependencies during execution (e.g. with control flow connections between trigger-in/trigger-out pins).


=== Suppressing the Type Check ===
=== Suppressing the Type Check ===
In some situations, expecco considers pins incompatible, although in reality they are not. This happens, when an output has been over-generalized (for example as "Any" or "Number") and needs to be connected to a less general input pin (for example "String" or "Integer"). If you are sure, that only correct values will actually be generated at the output pin, you can enforce a connection (against expecco's resistance, if you like), by pressing the <KBD>CTRL</KBD>-key while dragging the connection in the editor. The editor will then create the connection, but draw it as a dotted line, to indicate a possible type conflict at execution time.
In some situations, expecco considers pins incompatible, although in reality they are not. This happens, when an output has been over-generalized (for example as "Any" or "Number") and needs to be connected to a less general input pin (for example "String" or "Integer"). In such situations, expecco assumes that the output my generate values which cannot be consumed correctly by the input. However, expecco does not look into the actual code inside elementary blocks, and the code may actually only generate acceptable values.

If you are sure, that only correct values will actually be generated at the output pin, you can enforce a connection (against expecco's resistance, if you like), by pressing the <KBD>CTRL</KBD>-key while dragging the connection in the editor. The editor will then create the connection, but draw it as a dotted line, to indicate a possible type conflict at execution time. This can be changed to a solid line via the "''Disable Type Check''" context menu item.

=== Guidelines for Pin-Type Declarations ===
In general, it is a good strategy to declare the type of output pins as specific as possible, and input pins as general as possible. For example, an input that can deal with any collection should have a type "Collection", even if it will only deal with Strings in your setup. An output should be typed as String, if it produces strings, not as Any.
In general, avoid "Any"-typed outputs (see "[[Any_Type_Considered_Harmful]]").





Version vom 21. Juni 2017, 23:38 Uhr

Introduction[Bearbeiten]

A connection is used to interconnect two pins in an activity diagram. Depending on the type of the pins, the connection models either a data flow- or a control flow-connection.

Input pins can only be connected with output pins and the datatypes of the pins must be compatible. That means they either have the same type or the input pin has a "more general" type than the output pin; e.g., for numeric types, Number is more general than both Integer or Float. Inputs with an "Any" datatype are most general and can consume any value.

Outputs can be connected to multiple input pins, but each individual connection consists of exactly one input and one output pin. If an output pin has more than one connection, an outgoing value is sent to all connected inputs (concrete: a reference to the same datum-object is sent to all inputs). Thus, you should be careful with data object which contain state, and are mutated (modified) by an action. If that is the case, you should ensure proper synchronization to avoid time/execution order dependencies during execution (e.g. with control flow connections between trigger-in/trigger-out pins).

Suppressing the Type Check[Bearbeiten]

In some situations, expecco considers pins incompatible, although in reality they are not. This happens, when an output has been over-generalized (for example as "Any" or "Number") and needs to be connected to a less general input pin (for example "String" or "Integer"). In such situations, expecco assumes that the output my generate values which cannot be consumed correctly by the input. However, expecco does not look into the actual code inside elementary blocks, and the code may actually only generate acceptable values.

If you are sure, that only correct values will actually be generated at the output pin, you can enforce a connection (against expecco's resistance, if you like), by pressing the CTRL-key while dragging the connection in the editor. The editor will then create the connection, but draw it as a dotted line, to indicate a possible type conflict at execution time. This can be changed to a solid line via the "Disable Type Check" context menu item.

Guidelines for Pin-Type Declarations[Bearbeiten]

In general, it is a good strategy to declare the type of output pins as specific as possible, and input pins as general as possible. For example, an input that can deal with any collection should have a type "Collection", even if it will only deal with Strings in your setup. An output should be typed as String, if it produces strings, not as Any. In general, avoid "Any"-typed outputs (see "Any_Type_Considered_Harmful").



Copyright © 2014-2024 eXept Software AG