Skip to main content

Entity vs. entity type

A common source of confusion is the distinction between the terms 'entity' and 'entity type'. It is important to fully understand this terminology before diving deeper into VIKTOR's call-flow.

In short, an 'entity type' is the definition of a certain object, it's attributes and behaviour (logic) specified in (Python) code. An 'entity' is a single instance of an entity type. An entity always has a certain entity type and multiple entities can be created with the same type.

For example, an entity-type 'Cube' might be defined by its width, length and height. A 3 x 3 x 3 cube would be an entity of the type Cube, just as a 4 x 4 x 4 cube would be an(other) entity of the same type.

As a metaphor (thinking in terms of the Python language): the entity type would be a 'class', whereas an entity would be an 'instance' of the class.

Developer vs. User

Entity types are created by the app developer. The entity-type's definition and logic are defined in a controller class. Entity types are created during development.

On the other hand, entities (of the predefined types) are typically created by the user within the app, they are created and modified at run-time. Two entities of the same type share the same behaviour and the same set of attributes (since they share the same underlying code), but do not necessarily have the same attribute values.

For example, the user might create a new cube entity (with different width, length and height values) that resides next to the already existing two, or modify the 4 x 4 x 4 cube mentioned above to a 4 x 4 x 5 cube by updating the corresponding height field within the entity's editor in the app.

Entity vs. entity type


It is also possible for the developer to create initial entities at development time. In contrast, it is not possible for the user to create entity types (as he/she is not able to modify the underlying app-code).


Below are two example controllers (partly defined), in which the developer has defined 2 entity types: 'Project' and 'Design' (the latter being a child-type of the former).

class Project(ViktorController):    label = 'Project'    children = ['Design']    show_children_as = 'Cards'class Design(ViktorController):    label = 'Design'

The figure below shows a snapshot of the current live application, as seen by the user. We can see that the user created an entity of type 'Project' (and named it 'My Project'). Within the created project, the user created 3 entities of type 'Design' (notice that 'Design' is its label seen by the user) and named them 'Design A', 'Design B', and 'Design C' respectively.

Entity vs. entity type in VIKTOR

Since the designs are of the same entity type, opening their corresponding editor shows the same parametrization (after all, their logic is defined in the parametrization class of the entity type). Nevertheless, the attribute values assigned by the user make them unique:

Entities 'Design A' (top) and 'Design B' (bottom) have equal parametrization but differ by value