Consider this class:
class Writer {
@Inject
private SomeAPI remove;
public void write(Item item) {
remove(item);
}
}
I want to create a sequence diagram for this where I also want to represent the write method. Is below SD correct? Got a bit confused.
I did this like below now after thinking for a while. Please let me know opinion on both.
Several aspects to consider here:
Arrows describe messages or function calls (with parameters) from one entity to another and the corresponding response messages/return values. An arrow to the same lifeline represents a call within the same entity or a recursive call (see also this helpful introduction).
You can model loops or optional parts within the sequence by using combined fragments. However, error handling methods such as retrying are probably a general property of your system and not specific to this sequence. In fact, many people advise against modeling exceptions for better readablility of your diagrams.
Now assuming that the Writer's write
method is called by a third object (which is not quite clear to me from your question), the diagram should look like this: