For example, I have a code like this:
if (morning) {
if (beforeTenAM) {
System.out.println("Go back to sleep"); }
else {
System.out.println("Wake up!"); }
}
else {
System.out.println("It's not morning anymore");
}
How can I represent this nested if else statement in a UML sequence diagram? Is it possible to do so? Or is a communication diagram better in this case?
Well, you can do that with a fragment in a SD like

As you can see it's geeting crowded soon and the code is more clear than that. Don't be tempted to start graphical programming. SDs are here to give an overview of collaborating objects. Leave the rest to coders and eventually provide some pseudo code.
An AD delivers a more business oriented aspect:

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