Closed justincred closed 6 months ago
every time u would need to delete the class after finish using them no
Only if the object has no more references (i.e., ready for garbage collection). In this case, when cook()
method returns, the d
object is no longer referenced at that exact point in time, so the X
is required (note that the return arrow coincides horizontally with the X
to indicate that they occur at the same time).
In other cases, the object may continue being referenced and we may not know when it is ready for garbage collection.
note that the return arrow coincides horizontally with the
X
to indicate that they occur at the same time
@aureliony This is more of a happy coincidence. We are not so particular about the horizontal alignment of the X, provided it appears after (and not before) it is no longer referenced.
@damithc Sorry, is the deletion X
compulsory?
hi @damithc ,so this is for like temporary variables?
@damithc Sorry, is the deletion
X
compulsory?
In general, show only if it adds value to the purpose of the diagram. In the exam, consider it as compulsory (i.e., if you forgot or put it in the wrong location, it can affect your ability to pick the expected answer in related MCQs as well).
hi @damithc then may i ask do i put the object deletion symbol at the end for unit since it was a temporary variable created during the function? here
hi @damithc then may i ask do i put the object deletion symbol at the end for unit since it was a temporary variable created during the function? here
@justincred yes, you can.
thanks prof
As shown below, the lifeline is deleted, however when do u have to do that as this would mean that every time u would need to delete the class after finish using them no?