nabil
nabil

Reputation: 904

What would the UML sequence diagram of the following code look like?

What is UML sequence diagram of the following code featuring a class with two inner classes where each one is instantiated once as seen in the main function?

class A{

 class B{
  C f(){}
 }
 class C{}

 static void main(){
  A a = new A()
  B b = new B();
  C c = new C();
  c = b.f();
 }

}

Upvotes: 1

Views: 2128

Answers (1)

Sean
Sean

Reputation: 152

You could use an automated sequence diagram generator in Eclipse such as Diver: Dynamic Interactive Dynamic Interactive Views For Reverse Engineering. It generates both static and dynamic sequence diagrams and looks to answer your question.

I adjusted your code a bit to make it compile and used Diver to generate a sequence diagram:

ABC Sequence Diagram

That is the sequence diagram for this code:

package org.testing;

public class A {

    static class B 
{
    C f() {
    return new C();
    }
}

static class C {
}

    public static void main(String args[]) {          
        A a = new A();
        B b = new B(); 
        C c = new C();
        c = b.f();
    }
}

Upvotes: 2

Related Questions