Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

part def

This notebook introduces part def; after running it you can declare concrete component types with no content of their own yet.

The previous notebook established ToastingSystem as the abstract system concept, together with the action it performs. This notebook introduces two concrete component types with no attributes or hierarchy yet: HeatingSystem and ControlSystem. They stay bare placeholders in this chapter; later chapters give them mechanisms, policies and interfaces.

part def HeatingSystem;

HeatingSystem is a concrete part definition, declared bare (terminated with ;, no body). Unlike abstract part def, it can be instantiated directly, but nothing yet says what it does.

part def ControlSystem;

ControlSystem takes the same bare form. Two part definitions can exist side by side with no relationship yet; the next notebook relates the whole they compose into to ToastingSystem by specialization.

Both part definitions load with no diagnostics. The next cell checks what a bare part def looks like when its terminating syntax is missing.

Expected error: missing ';' at end of declaration

Omitting the terminating ; (or a body) after a bare part def is a syntax error, reported in bad.diagnostics[0].

kind : partDef
id   : ToasterDemo::HeatingSystem

PartDefinition: ToasterDemo::ToastingSystem
PartDefinition: ToasterDemo::HeatingSystem
PartDefinition: ToasterDemo::ControlSystem
PartDefinition: ToasterDemo::Toaster

HeatingSystem and ControlSystem drawn as two boxes with no edge between them: both exist, neither refers to the other yet.

Loading...

The picture repeats what the PartDefinition query above already listed, now with no line joining them.

model.find() resolves HeatingSystem, and the PartDefinition query above lists every named part def in the model so far, ControlSystem included.

The two bare part def declarations printed above loaded without error, and the PartDefinition query above lists both names, confirming each is now part of the model.

Try the chapter exercise in exercises/ch01/exercise.ipynb: define BrewUnit and HeatExchanger as two concrete component types and verify they load.