In good Object-Oriented Programming and Modeling, instances of classes are linked through associations. This establishes a powerful interdependence within groups of related classes but makes clean-up more complex. An instance cannot simply delete itself without considering instances of other linked classes.
Since associations in xtUML are explicit and captured in the model data, the disposal process can be automated. Some associations are unconditional; others are conditional. This distinction is available to the code generator at translation time. One such model compiler helped in a soil sampling robotics application.
Consider this model of a soil sampling mission. On the right, a “zone” is defined by at least one (but possibly many) outer boundaries and 0-many inner boundaries (“holes”). Basically a point is in the zone if it is within any of the outer boundaries and not in any of the inner boundaries.
There is an operation in the application that allows boundaries to be deleted. Suppose a boundary that is being used as a zone that contains samples is deleted. If it is the last outer boundary, it cascades and causes the zone itself to be disposed (because it is an unconditional association), the zone deletion causes “sample zone” to get deleted which causes “sample site” to get deleted, which causes all “samples” to get deleted which causes all “soil cores” to get deleted which causes a “core point” to get deleted which causes a “waypoint” to get deleted (phew!!)
It is pretty amazing! That is a ton of clean-up work the modeler simply does not even have to think about.