How To Show The Relationship Between A Class And Another Class That Takes The Instance Of The Class's Instance As An Input With A Sequence Diagram?
Solution 1:
How can I show the relationship between these two classes with UML sequence diagrams?
The goal of a Sequence Diagram is not to show relationships between classes, a Sequence Diagram describes an Interaction by focusing on the sequence of Messages that are exchanged, along with their corresponding OccurrenceSpecifications on the Lifelines (formal/2017-12-05 § 17.8 Sequence Diagrams)
From your code buildHouse creates a new instance of House so there is an object creation Message. Because house is a local variable the instance is immediately lost and then we can consider it is immediately deleted by the garbage collector of Python, so a DestructionOccurrenceSpecification depicted by a cross in the form of an X at the bottom of a Lifeline (§ 17.4.4.2 DestructionOccurrenceSpecification).
(I used a found message for buildHouse because the caller is unknown nor relevant in your question)
House can exist without the Person class
If you speak about the class, yes for sure because House definition is not nested in Person.
If you globally speak about instances, there is nothing saying only a Person can instantiate a House so yes too.
If you refer to your previous question in my answer I do not use a composition so the deletion of an instance of Person does not imply the deletion of the associated instance of House.
But again in buildHouse the new instance of House is immediately lost because not returned nor saved in a global variable nor saved in an attribute of Person, and then will be deleted by the garbage
Post a Comment for "How To Show The Relationship Between A Class And Another Class That Takes The Instance Of The Class's Instance As An Input With A Sequence Diagram?"