See for calculation: https://101.jqassistant.org/calculate-metrics/index.html
Given is the UML-Diagram of the car-simulation application. Every layer represents its own package.
Calculate the Martin-Metrics for the four packages.
Apart from the initialization this is a correct example of a layered architecture. Therefore calculate the afferent and efferent coupling again, this time without the initialization package.
Which number(s) give a hint, that these three packages may form a correctly layered architecture?
I wanted to know if my solution is correct and if I have calculated it correctly.
Direct dependencies are documented with dashed arrows.
Dependencies can also be deducted from associations (and aggregations and compositions):
We assume that the diagram is comprehensive and does show all the relevant classes.
The inventory:
SensorBus
directly depends on Dashboard
. Note that the label of the dependency notifies()
is very strange. Is it a usage dependency (i.e. an operation notifies()
uses Dashboard
as parameter, but from where does it get this parameter)?Startup
in initialization depends on Dashboard
, SensorBus
and Car
Dashboard
in UI depends on Locale
SensorBus
in functional layer depends on Sensor
, Car
, as well as Weather
and Locale
which are in the same packageCar
in HW-layer depends on Sensor
which is in the same packageSensor
in HW-layer depends on SensorType
which is in the same packageAccording to your definition, this leads us to:
Ca Ce
----------------------------------
Initialization 0 3
UI 2 1
Functional layer 2 3 !!
HW layer 2 !! 0
Yes: 2 classes outside the HW package depend on HW classes.
Yes: the functional layer, SensorBus
depends on 3 external classes: Car
, Sensor
and Dashboard
.
The wording used in your linked document is ambiguous about Ce:
Moreover, there is an issue about the package level of the calculation: