Module 5 — Inheritance, Components & Advanced Modeling
🎯 Module Objective
By the end of this module, you will:
- Understand model inheritance using
extends - Learn how to use Components correctly
- Design reusable enterprise-grade models
- Avoid duplication in large systems
- Think in modular architecture
This module separates intermediate modelers from architects.
1️⃣ Why Advanced Modeling Matters
In real systems, you will not have:
- 1 building
- 3 rooms
- 5 devices
You will have:
- Hundreds of device types
- Shared behaviors
- Repeated patterns
- Large hierarchical environments
Without reuse → your models become messy and duplicated.
Advanced modeling solves this.
2️⃣ Inheritance in DTDL (extends)
Inheritance allows one model to reuse another model.
Example:
You have a base model called Device.
{
"@id": "dtmi:com:smartfactory:Device;1",
"@type": "Interface",
"@context": "dtmi:dtdl:context;2",
"displayName": "Device",
"contents": [
{
"@type": "Property",
"name": "serialNumber",
"schema": "string"
},
{
"@type": "Property",
"name": "operationalStatus",
"schema": "string"
}
]
}
Now you want a TemperatureSensor.
Instead of rewriting everything, you extend:
{
"@id": "dtmi:com:smartfactory:TemperatureSensor;1",
"@type": "Interface",
"@context": "dtmi:dtdl:context;2",
"extends": "dtmi:com:smartfactory:Device;1",
"displayName": "Temperature Sensor",
"contents": [
{
"@type": "Telemetry",
"name": "temperatureReading",
"schema": "double"
}
]
}
Now TemperatureSensor automatically inherits:
- serialNumber
- operationalStatus
Plus its own telemetry.
This keeps your system clean.
3️⃣ When to Use Inheritance
Use extends when:
- Multiple models share common properties
- You want reusable base models
- You want consistency across device types
Example:
Base: Equipment
Extended:
- HVACUnit
- Generator
- Pump
- ConveyorBelt
All inherit:
- installationDate
- manufacturer
- maintenanceStatus
4️⃣ Multiple Inheritance
DTDL supports extending multiple interfaces.
Example:
"extends": [
"dtmi:com:smart:Device;1",
"dtmi:com:smart:PowerConsumer;1"
]
This allows combining behaviors.
Use carefully.
Avoid overly complex inheritance trees.
5️⃣ Components — Composition Modeling
Components allow you to embed one model inside another.
This is NOT the same as relationships.
Think:
Inheritance → “is a”
Component → “has a”
Example:
A Machine has a Motor.
First define Motor:
{
"@id": "dtmi:com:smartfactory:Motor;1",
"@type": "Interface",
"@context": "dtmi:dtdl:context;2",
"displayName": "Motor",
"contents": [
{
"@type": "Property",
"name": "rpm",
"schema": "double"
}
]
}
Now embed it inside Machine:
{
"@id": "dtmi:com:smartfactory:Machine;1",
"@type": "Interface",
"@context": "dtmi:dtdl:context;2",
"displayName": "Machine",
"contents": [
{
"@type": "Component",
"name": "motor",
"schema": "dtmi:com:smartfactory:Motor;1"
}
]
}
Now Machine has a motor component.
6️⃣ Relationship vs Component (Critical Difference)
| Feature | Relationship | Component |
|---|---|---|
| Creates graph edge | Yes | No |
| Separate twin instance | Yes | No |
| Used for topology | Yes | No |
| Used for composition | No | Yes |
| Independent lifecycle | Yes | No |
If the entity should exist independently → Relationship.
If it is part of the entity → Component.
7️⃣ Real-World Design Pattern
Smart Factory Example:
Machine:
- extends Equipment
- has Component: Motor
- has Component: Controller
- has Relationship: connectedTo → ConveyorBelt
- has Relationship: poweredBy → PowerUnit
This is layered modeling.
8️⃣ Enterprise Modeling Strategy
Professional modeling approach:
- Define base interfaces
- Extend for specialization
- Use components for internal parts
- Use relationships for topology
Think modular.
9️⃣ Avoid These Mistakes
❌ Deep inheritance chains
❌ Using component instead of relationship
❌ Copy-pasting properties across models
❌ Mixing composition and topology
Architectural rule:
Use inheritance for shared structure. Use components for internal composition. Use relationships for graph connectivity.
🔟 Designing for Scale
Imagine:
1,000 machines
10 machine types
5 shared subsystems
Without reuse → 50 repeated definitions.
With inheritance + components → clean modular system.
This becomes critical at enterprise scale.
1️⃣1️⃣ Modeling Exercise
Design a Smart Car.
Car:
- extends Vehicle
- has Component: Engine
- has Component: Battery
- has Relationship: connectedTo → ChargingStation
Think carefully:
Is Engine a component or relationship?
Answer: Component (it is part of the car)
Is ChargingStation a component?
No. It exists independently. So → Relationship.
🧠 Key Takeaways
extendsenables inheritance- Components enable composition
- Relationships enable topology
- Use modular design
- Avoid duplication
- Design for reuse and scale
You are now thinking like a system architect.
🚀 What’s Next?
In Module 6 we go deep into:
- Schema types
- Enums
- Objects
- Arrays
- Complex data structures
- Validation-level modeling
This is where your models become fully expressive.
You are now building enterprise-grade DTDL.