Databases Reference
In-Depth Information
to the same pattern if and only if there exists a bijective map : O 1 ! O 2 with
o 1 7! o 2 2 map , role(o 1 ) = role(o 2 )
For example, executing method addElements() in Figure 4.3(b) leads to a
collaboration that is similar to that from Figure 4.3(a). After applying all of
the collaboration transformers, both contain two objects with exactly the same
roles and types: an instance of Iterable with role fiteratorg and an instance
of Iterator with role fhasNext();next()g. Hence, both collaborations belong
to the same collaboration pattern.
4.2.4.2
Removing Infrequent Collaborations
In performing a dynamic analysis, there are two notions of frequency we
can use. On the one hand, each pattern occurs in a certain number of collab-
orations, that is, it appears a certain number of times at runtime. We refer to
that number as dynamic frequency. On the other hand, our analysis consid-
ers the number of different static call sites in which a pattern is found. This
number is referred to as static frequency.
When extracting frequent collaboration patterns, our analysis removes all
patterns with static and dynamic frequencies below certain thresholds. Requir-
ing a large dynamic frequency favours patterns that appear often at runtime,
while a minimal static frequency enforces a certain spread of a API usage
pattern in the source code.
4.2.5 Generating Finite State Machines
The final part of our analysis generates FSMs that encode commonly ob-
served API usage patterns. Each FSM contains a protocol of using one or more
API objects and species in which order the objects' methods are typically
called. The analysis maps each collaboration pattern to a weighted FSM as
follows:
States. For each object, create a state for each of the methods called on
it.
Methods. Whenever two methods are observed consecutively in one of the
collaborations that belong to the pattern, connect the two corresponding
states with a transition and assign weight one to it. If there is already
such a transition, increment its weight. Label the transitions with the
method of the destination state.
As a result, the FSM describes which method sequences occur in the col-
laborations of a pattern. Furthermore, the weights indicate how often each
transition was observed, and hence, provide an estimate of how likely one
method call is to follow another.
 
Search WWH ::




Custom Search