27.03.2014 Views

SEKE 2012 Proceedings - Knowledge Systems Institute

SEKE 2012 Proceedings - Knowledge Systems Institute

SEKE 2012 Proceedings - Knowledge Systems Institute

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

model has two types of diagrams: the Class Diagram and<br />

Sequence Diagrams. Each of these is translated in a different<br />

way, since they contain different types of information, even<br />

though some information is shared between them. We will<br />

begin with the class diagram translation.<br />

In the class diagram, it is possible to identify all the<br />

methods the framework makes available to the user. For each<br />

of these methods, a different operator will be made. The<br />

name of the operator will contain the name of the method<br />

being used and, in order to allow methods with the same<br />

name in different classes, the operator name will also contain<br />

the class name. The resulting operator name will then be<br />

“ClassName.MethodName”.<br />

Following the name, the set of preconditions is built. This<br />

set contains all the elements required to use the method. This<br />

set will contain one proposition “object(Object Type)” if the<br />

method is from an object, that is, the method requires an object<br />

to be used, as opposed to constructors and static methods<br />

that can be used without creating objects first. Next, one<br />

proposition “object(Argument Type)” is added to the set for<br />

each input argument the method has, in which the Argument<br />

Type will be replaced by the corresponding object type. To<br />

conclude this set, a proposition “interface(Used Interface)” is<br />

added if the method requires any interface to be called before<br />

it can be used, and these interfaces are identified by the “use”<br />

dependency relationship.<br />

It is worth noting that, if a method does not have one of<br />

these elements, the respective rule can just be ignored. It may<br />

happen that, in some cases, such as some constructors, the<br />

Precondition set will be empty.<br />

To complete the operator, the Effects set must be built. This<br />

set will contain all the propositions that will become true once<br />

the operator is used. This set will contain one proposition<br />

“object(Return Type)” should the method return any object.<br />

A proposition “interface(Name)” is added to the set if the<br />

method is responsible for implementing a service. The set will<br />

also contain a proposition “link(Type1, Type2)” if the method<br />

creates a link between objects of Type1 (the object that has<br />

the method being used) and Type2 (the second object). This<br />

link can be “created” either with the input argument, as in<br />

the “set” methods of objects, or if it returns an object already<br />

associated with the target object, “get” methods for example.<br />

Lastly, a proposition “sequence(Name)” is added if the method<br />

starts any of the Sequence Diagrams.<br />

To exemplify this process, let us use the class “JFrame”<br />

from the SWING framework, shown in figure 3.<br />

Fig. 3: JFrame Class from the SWING framework<br />

Starting by the “JFrame” constructor method, we get that<br />

the operator name should be “JFrame.JFrame”, since it is<br />

composed of both class and method names. Since this is a<br />

constructor, that has no input argument and does not require<br />

any other interface, its precondition set will be empty. The<br />

effect set will be composed only of its return type, a “JFrame”<br />

object. This will result in the following operator:<br />

Name : JFrame.JFrame<br />

Precondition (PC) : {}<br />

Effect (E) : object(JFrame)<br />

Next, using the “setVisible” method, we get an operator<br />

named “JFrame.setVisible”. Its precondition set will include<br />

one proposition “object(JFrame)”, since this is an object<br />

method (neither static or constructor). Although this method<br />

does not return an object, it is responsible for the interface<br />

“Create Window”, and a proposition “interface(Create<br />

Window)” is added to the effect set. This will result in the<br />

following operator:<br />

Name : JFrame.setVisible<br />

PC : object(JFrame)<br />

E: interface(Create Window)<br />

As a last example, let us use the “validate” method. As the<br />

method used before, this method has no input argument and is<br />

an object method, so the precondition set will be composed of<br />

the proposition “object(JFrame)”. This method has no return<br />

type and it is not responsible for any interface, but it starts<br />

the “Update Screen” mechanism, shown in figure 2. Hence<br />

the effects will include one proposition “sequence(Update<br />

Screen)”, resulting in the operator:<br />

Name : JFrame.validate<br />

PC : object(JFrame)<br />

E : sequence(Update Screen)<br />

This process is repeated for each method described in the<br />

Class Diagram, with each of them generating one operator.<br />

To complete the set of operators representing the framework,<br />

those created from any Sequence Diagram included in the<br />

model must be included. These diagrams contain information<br />

on functionalities that should be accessed through specialized<br />

classes and overwritten methods.<br />

Each Sequence Diagram will be inspected in order to<br />

identify which of the methods it contains can be overwritten.<br />

It is assumed that those methods that do not invoke any other<br />

methods inside their behavior description can be overwritten<br />

without introducing errors in the behavior of the framework.<br />

Once the method to be overwritten is identified, an operator<br />

named “overwrite:ClassName.MethodName” is created.<br />

The precondition set for this operator will be composed<br />

of one proposition “specialization(Class)”, in which Class<br />

represents the class that has the method to be overwritten. The<br />

set also contains a proposition “link(Type1, Type2)” where<br />

Type1 is the type of object that starts the mechanism and Type2<br />

is the type of object being overwritten, and a proposition “sequence(Mechanism)”,<br />

indicating that the Sequence Diagram<br />

must be used for the method to be called.<br />

The effect set of the operator will include one proposition<br />

“interface(Name)”, if the method is responsible for any interface<br />

and one proposition “object(Argument Type)” for each<br />

input argument the method has. The argument type is included<br />

in the effect set, instead of the precondition set like the other<br />

operators, because when overwriting a method, it is possible<br />

to use the input methods, instead of having to supply them<br />

when calling a method.<br />

Then, for each “overwrite” operator made, one additional<br />

operator is included. This operator will be named “special-<br />

565

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!