Your sequence diagram appears to be fine.
Your class diagram is however misleading:
- The class diagram is a structural diagram, and not a behavioral diagram. SO you don't really care for elapsed time unless it appears in a property or an operation.
- The navigation arrow between
Machine
and Timer
does not facilitate the proposed sequence diagram, which assumes that the Timer
knows to find the Machine
.
- Isn't the association with
worker
end and with works
end not the same associations in the end, if considered at the general level?
- The qualifier for the elapsed time is not correct.
For the time based association between Machine
and Worker
, you could consider making this a many to many association, with an association class defining the time-slot (start and end time, from which you can calculate the duration). You may find here some information about how to work with timeslods (although you do not need the additional constraints mentioned in that other question).
Edit: review of your updated diagrams
The class diagram looks better. Some advices:
Class
and Subclass1
are probably Machine
and E1
?
- Is the
duration
association class specific to Subclass
or is it general for any Class
? In the latter case, you should draw it between Worker
and Class
. It is not necessary to repeat it for Subclass, since the specialisation automatically inherits the associations, properties and operations of its generalisation.
- If the
Timer
has to send messages to objects? The dependency relation therefore seems misplaced. Shouldn't it then have an association with the classes to the instances of which it shall send messages?
- How does the
Timer
know about new Duration
objects ? Does it need to know Duration objects or couldn't it send ticks to the machines, which would forward the ticks to the durations?
On the sequence diagrams, and independently of the impact of the above-mentioned advices, it is important to realize that lifelines do not represent classes, but objects that belong to the classes. The class-names should therefore be preceded by a :
or an object name and a :
.
The second diagram would be integrated in the first diagram if you'd go for the tick forwarding. Nevertheless, if you'd keep it, you should ask yourself how a Duration could check if elapsed_time==timeExplode
since timeExplode is a property of the machine and not of the duration.