1

I made a state diagram for the Purchase object (parent) and for the Item object (child), as you can see below. One of my doubts is how to represent the integration between parent/child objects in the state diagram.

The system flow is the following: Purchase object has an ArrayList to keep Item objects. Purchase is created first, then Item is created and added into the ItemArrayList as much as needed. F4 is pressed in order to open the Payment screen; the same happens to the Finisher object: it is added to the FinisherArrayList till [amountPayable = 0] guard returns True. while guard is False, I can close the Payment screen and return to the Purchase screen in order to add/remove items. After Purchase beeing saved in the table, it will loop ItemArrayList and save Item by Item in the table. If, for some reason, one of the Items fail to save in the table, the whole Purchase will be deleted.

Just to explain that this POS system will not have refund option for this moment.

my DB diagram: enter image description here

my class diagram: enter image description here

state diagram for Purchase object: enter image description here

state diagram for Item object: enter image description here

Thanks in advance.

1 Answer 1

1

One of my doubts is how to represent the integration between parent/child objects in the state diagram.

A state diagram shows the states and transitions between them of one class (or sub-system if you model at a higher abstraction level). The only kind of integration that a state diagram can show is that it responds to events that are triggered by another class and even that level of integration is very implicit, because the diagram doesn't show the origin of the event, nor does it have a dedicated element to show that an event is created that is relevant for another state diagram.

This means that the interaction between objects is best explained in text or with other diagrams, like activity diagrams or sequence diagrams.

5
  • Ok. Superstates and submachines represent states of only one class, even if this class has another class in it as attribute. So, when a superstate is applicable in the diagram, as well as a submachine? Oct 25, 2021 at 17:29
  • @AlexBoorjs, a sub statemachine (or nested state machine) is applicable, for example, if you have a group of states that have some common transition out of that group. To give a real-world scenario, a microwave oven can have the states that it is idle, actively heating and waiting (for heat to disperse though the frozen food). In all these states, it is possible that the user opens the door. (cont.) Oct 26, 2021 at 6:39
  • (cont.) When that happens, the system must be brought quickly into a state where it is safe for the user to reach into the oven. Such a requirement is usually modeled with a superstate (door closed) that has a sub statemachine. Oct 26, 2021 at 6:39
  • Good. Once I have my diagram fixed, I will have to learn how to implement it in the proper way, considering that I'm using VBA language. It doesn't have STM class generator, like Java has. Would you have any good site or book to recommend me? It is been tough to find one good about state diagram implementation. Oct 26, 2021 at 20:33
  • I'm realizing now that every time that I want to implement a state diagram, I'll have to apply the state/strategy pattern to my code. Right? Oct 26, 2021 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.