nus-cs2103-AY2223S2 / forum

12 stars 0 forks source link

Can we omit the creation of an object in a sequence diagram? #315

Closed hingen closed 1 year ago

hingen commented 1 year ago

Hello. I was editing the developer documentation when I realised that the sequence diagram ArchitectureSequenceDiagram.png specifies an argument p in the method call deletePerson(p). However, p is never defined anywhere.

Intuitively, as developers who have a rough understanding of the code base, we can infer that p is the Person object that is to be deleted. However, I feel it can be rather ambiguous for a developer new to the code base. Perhaps a name like person or personToDelete would be more intuitive.

My question is, in a sequence diagram, can we omit details such as object creation?

If so, are there any conditions to be met? For example, the argument name and/or context surrounding the sequence diagram must be intuitive enough for the developer to infer the meaning of the arguments.

Screenshot: image

damithc commented 1 year ago

My question is, in a sequence diagram, can we omit details such as object creation?

@hingen the example you gave doesn't concern object creation, right? But in general, yes you may omit details that are not important to the purpose of the diagram, provided the omission does not mislead the reader.

If so, are there any conditions to be met? For example, the argument name and/or context surrounding the sequence diagram must be intuitive enough for the developer to infer the meaning of the arguments.

The general condition is that the diagram must be 'fit for purpose'. If the details given are sufficient to convey whatever explanation the diagram is expected to convey, without misleading the reader, that should be good enough.

Intuitively, as developers who have a rough understanding of the code base, we can infer that p is the Person object that is to be deleted. However, I feel it can be rather ambiguous for a developer new to the code base. Perhaps a name like person or personToDelete would be more intuitive.

Yes, a more meaningful name can help in this case.

hingen commented 1 year ago

the example you gave doesn't concern object creation, right?

My bad, my phrasing was poorly done. My intention was to ask if we need to specify where the objects are obtained from, be it through a method call (such as the case for p) or through a call to a constructor.

Either way, your answer addresses my issue. Thanks!