How To Draw Diagram - Noda
How To Draw Diagram - Noda
Abstract—Software visualization with sequence diagrams is diagram of a size that is reduced but sufficient for easy
one of the promising techniques aimed at helping developers understanding.
comprehend the behavior of object-oriented systems effectively.
However, it is still difficult to understand this behavior, because Several methods and tools [4], [5] have been proposed to
the size of automatically generated sequence diagrams tends provide sequence diagrams with easy-to-understand focused
to be beyond the developer’s capacity. behavior by reducing the amount of execution information
In this paper, we propose a sequence diagram slicing method, to be visualized. We have also developed a method for
which is an extension of our previous method based on providing a “partial sequence diagram” whose size is small
a dynamic slicing technique using static information. Our
proposed method is capable of accurate slice calculation based enough to make the focused behavior of a program easy to
on high-precision data dependency and can support various understand by applying the program slicing technique [6].
programs, including exceptions and multithreading. However, in our previously proposed method, information
In addition, our proposed new tool performs slice cal- that should be contained in a slice may be missed, because
culations on the Eclipse platform and we demonstrate the we used approximated data dependency. The method also
applicability of this method by applying the tool to two Java
programs as case studies. The results confirm the effectiveness has strong limitations when applied to programs; for exam-
of our proposed method for understanding the behavior of ple, it only supports Java 1.4 and does not cover multithread
object-oriented systems. and exception occurrence programs.
Keywords-Sequence Diagram; Program Slicing; Reverse En- In this paper we propose a sequence diagram slicing
gineering; Program Comprehension; Program Maintenance; method, which extends our previous model and method,
Debugging analyzes data dependency more precisely and handles the
information about thread and exception to acquire the capa-
I. I NTRODUCTION bility to be used in a wider range of applications. We also
introduce our new tool “Reticella” that visualizes object-
Understanding the behavior of a large-scale object-
oriented program’s behavior and supports sequence diagram
oriented system is one of the more difficult tasks of program
slicing, which is implemented as an Eclipse plug-in. In
comprehension. Object-oriented programs tend to contain
addition, we discuss the applicability of the proposed method
many elements that are determined at the time of execution,
with two case studies.
because design patterns, polymorphism and delegation are
often used to improve changeability and reusability of their This paper makes the following major contributions.
source codes.
• We clearly define data dependency calculations for ex-
Visualization of interactions between objects is one of ecution traces with static control structure information.
the promising techniques to help developers comprehend • We propose a model to represent the behavior of a
the behavior of object-oriented systems effectively [1] . A multithread program that includes exception handling.
sequence diagram is a diagram that represents the sequence • We show the feasibility of the proposed method with
of messages passing of programs along a time line and an implemented tool as an Eclipse plug-in that supports
is suitable for representing the behavior of object-oriented all major features of Java programs.
programs. Several tools [2], [3] support automatic generation
of a sequence diagram from execution trace logs. However, The remainder of this paper is organized as follows. Sec-
it is still difficult to understand this behavior because the tion 2 shows our preliminary work to support comprehension
size of automatically generated sequence diagrams tends to of the program’s behavior. We explain our proposed method
be beyond the developer’s capacity. in Section 3 and our implemented tool in Section 4. Section
The purpose of this research is to help the developer un- 5 shows case studies. Section 6 discusses related works and
derstand the behavior of programs by providing a sequence Section 7 concludes this paper.
II. P RELIMINARY W ORK First, we describe the extension to analyze data depen-
We have proposed a method and a tool for generating a dency more precisely. In our previous method, the data
partial sequence diagram [7]. dependency arising by assignment expression cannot be
In our previous work, we have defined the simplified analyzed, because the B-model in our previous method does
Behavior Model (B-model). The B-model represents the not contain information that reflects data flow related to
execution behavior of object-oriented programs and consists values of variables. In the proposed method, to analyze data
of execution information, method entry/exit events, caller/- flow related to values of variables, we model two events,
callee objects of method invocation and start/end events ‘definition of’ and ‘reference to’ the value of the variable
of control structure such as a conditional branch and a during execution of the programs, and add the models to
loop statement. Elements of the B-model can be uniquely the B-model. We call these two events VariableDefinition or
converted to elements of a sequence diagram. VariableReference, respectively.
The tool generates B-model data from source codes Second, we describe the extension for covering programs
and execution traces, and calculates a subset of the B- that contain exception occurrences. There are two types of
model data for a partial sequence diagram by adapting our information about exceptions, exception occurrence and ex-
slicing method based on Dependence-Cache Slicing [8]. ception handling. To cover programs that contain exception
The proposed tool was implemented by using JavaCC [9] occurrences, we modelled seven events, exception occur-
to statically analyze the control structure in source codes, rence and start/end of try/catch/finally clause, and added
and JDI (Java Debug Interface) in JPDA (Java Platform these models to the B-model.
Debugger Architecture) to dynamically analyze how the Third, we describe the extension to cover multithread pro-
program is being executed. grams. We need information about a thread in which an event
We analyze the following four kinds of dependencies occurs to analyze programs that contain multithreading. We
in a data sequence based on the B-model that represents modelled two details about a thread, its ID and its name,
execution behavior. and made elements of the B-model to hold this information
• Control Dependency. as attributes.
A dependency that reflects control flow in programs. Finally, we describe the extension to choose slicing cri-
• Method Invocation Dependency. teria more flexibly. We made elements of the B-model to
A dependency that reflects a nested structure of method hold information about variables that can be referred to at
invocations. the point of the occurrence of an event as attributes. By
• Start–End Dependency. providing information about the variables when choosing
A dependency that associates a start event with a slicing criteria, it has become possible to choose slicing
corresponding end event in the B-model. criteria more flexible than those chosen using our previous
• Data Dependency. method.
An approximate dependency between B-model data that We represent a program behavior in a data sequence
reflects data flow in programs. hb1 , b2 , · · · , bn i, where bi (1 ≤ i ≤ n) is a leaf element
of the tree whose root is BehaviorEvent in Fig. 1 (e.g.
III. P ROPOSED M ETHOD
MethodEntry, ConditionEnd, ExceptionOccurrence, TryS-
In this paper, we propose a sequence diagram slicing tart, VariableDefinition, etc.). For any i, bi can be converted
method that expands our previous method mentioned in to an element of a sequence diagram uniquely. MethodEntry
Sect. II with respect to the B-model and definitions of depen- and ConstructorEntry correspond to ‘a synchronous mes-
dencies. The newly proposed method enables the following sage’ and ‘a object creation message’ respectively, and both
four types of content. MethodExit and ConstructorExit correspond to a reply mes-
• Slice calculation based on high-precision data depen- sage in a sequence diagram. Other leaf elements except for
dency. VariableDefinition and VariableReference are depicted using
• Handling programs containing exception occurrences. a comment (i.e. a note symbol) in a sequence diagram. Both
• Handling multithread programs. VariableDefinition and VariableReference are not depicted in
• Flexible choice of slicing criteria. a sequence diagram.
In the following, we explain the detail of extensions in the
proposed method to achieve the abovementioned four types B. Extension of Data Dependency
of content.
We redefined data dependency to analyze data depen-
A. Extension of Behavior Model dencies more precisely. In this section we explain the new
In this section, we explain the detail of extension of the B- definition of data dependency in the proposed method.
model. The class diagram of the extended B-model is shown As mentioned earlier in Sect. III-A, we added two ele-
in Fig. 1. ments related to the value of variables to B-model, namely
Behavior
VariableInfo # value ValueInfo
MethodSignature # variableName : String
- returnType : String 1 1
- methodName : String 1
- argumentTypeList : List <String> 0..* - behaviorEventList
ThreadInfo ObjectInfo PrimitiveValueInfo
# theadInfo BehaviorEvent LocalVariableInfo FieldInfo
- threadID : Integer - ownerObject - objectID : Integer - typeName : String
1 # methodSignature # eventNumber : Integer
- threadName : String 1 1 1 1 - className : String
EntryEvent ExitEvent
# argumentValueList : List<ValueInfo>
ExceptionHandlingStartEvent ExceptionHandlingEndEvent
ConditionStart LoopStart Looping ConditionEnd LoopEnd
- loopCount : Integer
Figure 3. Source code of program 1 Figure 4. Sequence diagram that represent the whole execution behavior
of program 1 shown at Fig. 3.
A. Case Study 1
By using our developed tool explained in Sect. IV, we
visualized the program shown in Fig. 3 as a sequence
diagram. As a result, we got the sequence diagram shown in
Fig. 4, which represents the whole execution behavior of the
program. In Fig. 4, the number between ’[’ and ’]’ indicates
that the event occurred ith in the execution of the program.
For the slicing criterion (bc , v), the number c is chosen from
numbers between ’[’ and ’]’. In Fig. 4, we used a special
lifeline whose name is “static#:FullyQualifiedClassName”,
where # is an arbitrary unique number per class, because a
static method does not have a callee object.
In the sequence diagram shown in Fig. 4, an exception
of the class “IllegalStateException” has occurred at event
number [35] and the exception was caught by a catch clause
at event number [39].
To detect what program behavior caused the exception,
we chose (b42 , e) as the slicing criterion, where the variable
e is able to be referred at the caller stackframe of b42 , and Figure 5. Slice of a sequence diagram shown at Fig. 4 by slicing criterion
sliced the sequence diagram shown at Fig. 4. (b42 , e).
As a result of slicing, we obtained a slice of the sequence
diagram, which is shown in Fig. 5. In the program shown
at Fig. 3, IllegalStateException has been thrown because: From this result, we confirmed that the data dependency
first, a negative integer value was assigned to f ield at arising from the assignment expression and the unusual
line 16; and second, the predicate of the if statement at control flow that occurs by exception occurrence—both of
line 20 was evaluated as true; and finally, the throw which could not be analyzed by our previous method—were
statement at line 21 was executed. The information that now correctly analyzed. Moreover our proposed method is
caused exception occurrence was indeed included in the also expected to facilitate developers’ tasks for large-scale
slice shown in Fig. 5 and information irrelevant to the programs by effectively providing useful information for
occurrence of exception, such as method invocation of m1 understanding the program’s complex behavior and time-
and println, was deleted and does not exist in the slice. consuming debuggings as a sequence diagram.
proposed method has the capability to extract appropriately
only information of interest that exists in several threads.
Hence, our proposed method could become a valuable aid to
support program comprehension and software maintenance.
VI. R ELATED W ORK
A reverse-engineered sequence diagram is a very useful
tool for software development such as comprehension of
a program’s behavior, software maintenance and debug-
ging. There are many works and tools related to reverse-
engineered sequence diagrams [11].
However, as mentioned in Sect. I, to simply generate
a reverse-engineered sequence diagram from the execution
trace may lead developers into difficulties, because of the
large size of the diagram. To solve the problem, several
works have proposed effective software visualization meth-
Figure 6. Slice of a sequence diagram shown at Appendix 1 by slicing ods and tools.
criterion (b158 , num). Sharp et al. discuss the visual limitations and propose
techniques to help developers explore large-scale reverse-
engineered sequence diagrams [12]. By filtering out infor-
B. Case Study 2 mation of no interest, and allowing the user to select and ex-
In this section, we show an application of our pro- amine details of messages on demand, effective exploration
posed method to a multithread program. We chose a Con- of the sequence diagram is achieved.
sumer/Producer problem, which is typical multithreading Taniguchi et al. propose a method of compressing a
problem, as the subject of the case study. sequence diagram and improving its readability. [4]. If rep-
In the program we used in this case study, a Consumer etitions and recursive method calls exist in a program, same
class gets the value of common buffer by getV alue method or similar method invocation patterns are expected to appear
and assigns the value to a variable num. Therefore, we in a reverse-engineered sequence diagram. In Taniguchi’s
chose (b158 , num) as the slicing criterion to examine what method, the patterns are visualized in compressed form, and
behaviors affect the value of the common buffer. Note that thus the readability of the sequence diagram improves.
the event b158 is a method entry event for printing the value AMIDA [5] is a tool for generating sequence diagrams
of num, after a second access of Producer/Consumer to the that represent the execution behavior of a program. AMIDA
common buffer, and the variable num is a local variable can perform automatic phase detection and separate a lot
which can be referred at the caller stackframe of b158 . of execution information to several parts corresponding to
A generated sequence diagram that represents the whole features, and provides visualized information effectively.
execution behavior of the Consumer/Producer program is JSlice [13] is one of the famous dynamic slicing tools for
shown in Appendix 1. In the diagram, two sets of access to Java programs. It collects and analyzes bytecode traces with
the common buffer are depicted. In the first set, the Producer lossless data compression, and improves space efficiency.
stored a value to the common buffer first and the Consumer
got the value from the common buffer first. In the second set, VII. C ONCLUSION AND F UTURE W ORK
there is second access to the common buffer by the Producer In this study, we proposed a sequence diagram slicing
and Consumer. method that extracts points of interest and parts related to
The result of slicing by slicing criterion (b158 , num) is them from a sequence diagram that represents the whole be-
shown in Fig. 6. The resulting diagram contains information havior of programs. The proposed method can perform slice
about a Producer storing a value to the common buffer calculation more correctly on the basis of high-precision data
secondly and a Consumer getting the value from the com- dependency and cover a larger variety of Java programs by
mon buffer secondly, and it does not contain information extending our previous method.
about the first set of accesses to the common buffer by We developed a tool that calculates a slice based on our
the Consumer and Producer. Therefore, only the information proposed method. Using the tool, we applied the proposed
related to the slicing criterion is correctly extracted in the method to two kinds of Java programs. The result confirmed
slice. that our proposed method 1) can reduce the size of informa-
There are many concurrent applications in recent year and tion in a sequence diagram appropriately, and 2) is effective
because of the complexity of the behavior, comprehending to support developers’ tasks, such as comprehension of a
the behavior of these applications is a tough task. Our program’s behavior and debugging.
Our plans for future work and challenges are as follows. [10] M. Strauch, “Quick Sequence Diagram Editor,” http://sdedit.
sourceforge.net/.
• More reduction in the information included in a slice
[11] C. Bennett, D. Myers, M.-A. Storey, D. M. German, D. Ouel-
of a sequence diagram.
let, M. Salois, and P. Charland, “A survey and evaluation of
Some approaches are expected to be effective in this tool features for understanding reverse-engineered sequence
challenge, for example using the method for com- diagrams,” J. Softw. Maint. Evol., vol. 20, no. 4, pp. 291–315,
pressing a sequence diagram together [4], introducing 2008.
interactive representation of a sequence diagram like [12] R. Sharp and A. Rountev, “Interactive exploration of uml
[12], and improving and refining our slicing algorithm sequence diagrams,” in VISSOFT ’05, pp. 1–6.
by introducing new dependencies. Moreover, filtering [13] T. Wang and A. Roychoudhury, “Using Compressed Bytecode
Traces for Slicing Java Programs,” in ICSE ’04, pp. 512–521.
out useless and unwanted information before tracing
[14] H. Zhong, L. Zhang, and H. Mei, “Early Filtering of Polluting
like [14] is also expected to be effective in improving
Method Calls for Mining Temporal Specifications,” in APSEC
the readability of the diagram and analyzing time ’08, pp. 9–16.
efficiency.
• Effective representation of multithread programs on a
sequence diagram.
Depicting several threads’ behavior in a program into a
single sequence diagram tends to lead to more complex-
ities and reduce the readability of the sequence diagram.
Therefore, we need to introduce some new methods that
cope with such problems, for example, grouping threads
that are related to each other and three-dimensional
representation of a sequence diagram.
ACKNOWLEDGMENT
We would like to thank Dr. Motoshi Saeki, Junya Katada
and Masashi Shikauchi for their comments. This work is
partially supported by a Grant-in-Aid for Scientific Research
of MEXT Japan (# 20300009, # 21700027).
R EFERENCES
[1] L. C. Briand, Y. Labiche, and J. Leduc, “Toward the Reverse
Engineering of UML Sequence Diagrams for Distributed Java
Software,” IEEE Trans. Softw. Eng., vol. 32, no. 9, pp. 642–
663, 2006.
[2] W. D. Pauw, E. Jensen, N. Mitchell, G. Sevitsky, J. M.
Vlissides, and J. Yang, “Visualizing the Execution of Java
Programs,” in Software Visualization (LNCS Vol.2269), 2002,
pp. 151–162.
[3] J. Kern and C. Garrett, “Effective sequence diagram gener-
ation,” Borrand White paper, 2003, http://www.borland.com/
resources/en/pdf/white papers/20263.pdf.
[4] K. Taniguchi, T. Ishio, T. Kamiya, S. Kusumoto, and K. In-
oue, “Extracting Sequence Diagram from Execution Trace of
Java Program,” in IWPSE ’05, pp. 148–154.
[5] T. Ishio, Y. Watanabe, and K. Inoue, “AMIDA: a Sequence
Diagram Extraction Toolkit Supporting Automatic Phase De-
tection,” in Proc. ICSE Companion ’08, pp. 969–970.
[6] M. Weiser, “Program Slicing,” in ICSE ’81, pp. 439–449.
[7] J. Katada, T. Kobayashi, M. Shikauchi, and M. Saeki,
“Sequence diagram generator based on slicing technique
(poster),” Workshop on Eclipse Technology eXchange, 2004,
http://www.se.cs.titech.ac.jp/research/sdg/index.html.en.
[8] T. Takada, F. Ohata, and K. Inoue, “Dependence-cache slic-
ing: A program slicing method using lightweight dynamic
information,” in IWPC ’02, pp. 169–177.
Appendix 1. Sequence diagram which represents the whole execution
[9] “JavaCC,” https://javacc.dev.java.net/. behavior of a Consumer/Producer program.