Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An object can outlive another ...What does it mean?

I am studying design patterns. In the UML description aggregation its defined so : A has B , and B can outlive A. Element to describe that is :

A<>------B (where the funny arrows, should be a diamond)

I simply do not understand the concept of "OUTLIVE" even if I understand that B type is in A under the form of a field (property...etc).

What do they mean with this "outlive" ?? In which case B can outlive A ?

like image 462
Iulian Radulescu Avatar asked Nov 27 '25 02:11

Iulian Radulescu


1 Answers

It means that B is/could be referenced from outside A in some way.

It's easier to get in contrast with Composition, where B is solely 'owned' by A and then when A becomes unreachable, B automatically becomes garbage too.

So lifetime is used here to define visibility/scope. A little backward reasoning.

like image 187
Henk Holterman Avatar answered Nov 28 '25 15:11

Henk Holterman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!