Home > Mobile >  How can I represent relationships between instances of the same class in a concurrent system
How can I represent relationships between instances of the same class in a concurrent system

Time:12-04

I made a concurrent system which has a critical section which involves read and write access to a TXT file.

First, an Auctioneer class creates a TXT file and writes the number 50 to it. The Auctioneer then allows the next node, one of three instances of the Bidder class, to open the file and change the current bid. The bidder class then allows the next node, another bidder to bid, then another bidder, and then that bidder allows the Auctioneer to look at the file. I allowed the nodes to take turns using server sockets. Each node waits for access using the one possible class diagram

Is this the correct way to represent the relationship which I have described? If not, which way would be better/UML compliant?

CodePudding user response:

Class diagrams, as the name suggest represent classes of objects and not individual objects, i.e. instances of these classes. Moreover, a class diagram is structural: it does not tell how objects interact or wait one for another, but how classes relate.

In tour case the class diagram would therefore represent one bidder class. To represent a concrete example with instances and how they relate, you could consider an object diagram. There you could very well represent different instances of the same class.

However, if you’re interested in the interactions between classes (e.g. the tokens they exchange), you’d better consider an interaction diagram such as the sequence diagram.

  • Related