Sobes.tech
Junior — Senior

Identify the shortcomings in the presented Swift fragment №1

livecode

Task condition

In the provided example, two classes are created — Person and Pet. The Person class stores a name and an optional reference to a pet, while the Pet class stores a name and a weak reference to its owner. After creating instances john (a person) and dog (a pet), they are mutually linked: john.pet = dog and dog.owner = john. Analyze the code and identify potential issues that may arise (for example, related to memory management, strong/weak references, optionality, etc.).