next up previous contents
Next: 3.2 Clientship Relation Up: 3. Yet Another Object Notation Previous: 3. Yet Another Object Notation

Subsections


3.1 Classes

Three types of classes are supported: standard, active and synchronized classes. As in Java there is no generic class in YAON. The class system of YAON is flat, i.e. there is no way to declare local classes inside a class nor anonymous classes, although Java provides syntactic constructs for them. The reason is quite easy. As is pointed out in [Fla97] some semantics problems arise by using the features mentioned above. Inner classes create quite a few special cases, and a confusing array of new rules. That is, one can write programs using these features where the intended semantics is violated by obscures and pathological cases. Also in Java 1.1 and Java 1.1.1, there are compiler bugs where the intended scope of some class modifiers is violated. Discussions about flat class systems versus hierarchic class systems have been done in different forums with different results. For example, in the standardization of Lisp only flat class systems were allowed.

3.1.1 Standard Classes

In the majority of object-oriented languages, object templates are called classes. The basic class icon is as in figure 1:
  
Figure 1: Standard Class
\begin{figure}
\center
\begin{tabular}{\vert c\vert}\hline
\textrm{standard\_...
...\_1() \\
Method\_2() \\
$\ldots$\space \\ \hline
\end{tabular} \end{figure}

The class name is written in the top part of the rectangle as indicated. The attributes of the class are described in the middle section of the icon, and the methods of the class in the lower section. This general arrangement of information is retained wherever properties of classes or methods are defined. The ellipses (...) appearing after the attributes and methods are significant, and are explained further in section 3.6. As a shortcut, the attributes and methods may be omitted. Two icons, as shown in figure 2, are used independently and with the same semantics.


  
Figure 2: Standard Class Shortcut
\begin{figure}
\center
\begin{tabular}{ll}
\begin{tabular}{\vert c\vert}\hlin...
...rd\_class} \\ \hline
\\ %
\\ \hline
\end{tabular}
\end{tabular} \end{figure}

Normally each YAON diagram has a root class, i.e. the class which will bootstrap the whole diagram. Thinking in Java, this corresponds to the class which contains the main method. Diagrams for distributed systems would have more than one root class, that is more than one bootstraper. This is the case of a client/server where both client and server have a root class. These classes, the root classes, will be depicted with a triangle in the left hand side of the icon class as depicted in figure 3.


  
Figure 3: Root Diagram Element
\begin{figure}
\center
\begin{tabular}{\vert c\vert}\hline
\textrm{standard\_...
...{\LARGE {$\triangleright$ }}
\end{picture} \\ \hline
\end{tabular} \end{figure}

3.1.2 Modifiers

Java defines the following visibility modifiers: public, default, protected and private. In YAON this modifiers will be specified as a prefix of the class, method or attribute name. These modifiers and their corresponding symbols are shown in table 3:


 
Table 3: Visibility Modifiers
Modifier Symbol
public +
private -
protected #
default  
 

If no modifier is used, the default visibility is assumed.

In addition, Java defines special modifiers applicable to classes, methods and attributes. Table 4 gives an overview.

 
Table 4: Special modifiers

Modifier

Class Method Attribute
final * * *
native   *  
synchronized * *  
transient     *
volatile     *
abstract * *  
static * * *
 

These special modifiers are denoted by the appropriate keyword written in typewriter font, e.g. static method-name. The only exception is abstract, which may also be written abstract. The modifiers can be combined as for example:

+ static main (String [] args)

This specifies the public static method main of a given class. An example, which shows the use of modifiers, is depicted in Figure 4.

  
Figure 4: Class Icon using Modifiers
\begin{figure}
\center
\begin{tabular}{\vert l\vert}\hline
\multicolumn{1}{\v...
...
\multicolumn{1}{\vert c\vert}{$\ldots$ } \\ \hline
\end{tabular} \end{figure}

3.1.3 Active Classes

An active class is one whose instances have an independent thread of control. Thus, they have the ability to run methods ``spontaneously''. In contrast, an instance of a passive class executes a method only when it is called by another object. After completing the method it is passive again. To depict an active class, the basic class icon is extended as in figure 5.


  
Figure 5: Active Class
\begin{figure}
\center
\begin{tabular}{\vert c\vert}\hline
\textrm{active\_cl...
... \texttt{- }Method\_2 \\
$\ldots$\space \\ \hline
\end{tabular} \end{figure}

The icon for an active class is similar to the one used in ION. However, it is placed next to the class name to leave enough space for the attributes and methods. If the attributes and methods are omitted in the class icon, the active class icon may be placed inside the class icon as in ION (see figure 6).


  
Figure 6: Active Class Shortcut
\begin{figure}
\center
\begin{tabular}{\vert c\vert}\hline
\textrm{active\_cl...
...{\vector(0,-1){1}}
\end{picture}\\ \hline
\\ \hline
\end{tabular} \end{figure}

3.1.4 Synchronized Classes

A synchronized class is depicted by a circle with two crossed lines inside as in figure 7.


  
Figure 7: Synchronized Class
\begin{figure}
\center
\begin{tabular}{\vert c\vert}\hline
\textrm{synchroniz...
...ular} &
\end{tabular} \\
$\ldots$\space \\ \hline
\end{tabular} \end{figure}

These classes are called protected in ION. But, the name protected is already used in Java as a visibility modifier. Therefore, the name synchronized was chosen. If the attributes and methods are omitted in the class icon, the synchronized class icon may be placed inside the class icon as in ION.

Synchronized classes are those whose methods are protected from concurrent invocation of their methods. Some ``synchronisation protocol'' exists in order to protect them. The synchronization of the methods is also depicted in the class box. Icons for the most common synchronization protocols, such as mutual exclusion, readers/writers, guarded, etc. are provided. Actually, the protocol icon must be interpreted as a shorthand of another diagram where the synchronization protocol is specified. Synchronization protocols can be specified using Petri nets, state-charts, etc. If the user would like to have a new one, he has to depict a new protocol icon and must give its specification using one of the formalisms mentioned above.

Now we give examples for the specification of the mutual exclusion and reader/writer protocol using the Petri net class place/transition systems without capacities. A place/transition system consists of places, transitions, arcs to connect places and transitions and a marking of the places. Places are represented as circles, transitions as rectangles and arcs as arrows. A transition may occur if its incoming places contain at least as much tokens as denoted on the incoming arcs with an empty arc meaning one token. If a transition occurs, it removes the needed tokens from its input places and marks it output places with the number of tokens specified by the inscriptions of its outgoing arcs.

Figure 8 shows a mutual exclusion protocol with a critical section modelled by a place and two jobs modelled as tokens on place In waiting to enter it. The rightmost place with an initial marking of one token ensures that only one job can enter the critical section at a time. In figure 9, the reader/writer protocol is shown. The synchronisation is achieved by the place between Reading and Writing. A writer can only enter the critical section modelled by place Writing if there are n tokens in the synchronisation place. This is only possible if no jobs are reading or writing because the total number of jobs is n, the initial marking of place Jobs. Of course, this model may lead to a starvation of a writer if there is always at least one reader reading. However, this issue will not be discussed here because the specifications are only examples.


  
Figure 8: Mutual Exclusion
\begin{figure}
\center
{%
\unitlength=1.000000pt
\begin{picture}
(309.00,300.00...
...,200.00){\rule{60.00\unitlength}{30.00\unitlength}}
\end{picture}}
\end{figure}


  
Figure 9: Reader Writers
\begin{figure}
\center
{%
\unitlength=1.000000pt
\begin{picture}
(403.00,391.00...
...00\unitlength}}
\put(223.00,351.00){\circle{40.00}}
\end{picture}}
\end{figure}

The table 5 includes all the `built-in'' synchronization protocols of YAON which is similar to the one used in ION.


 
Table 5: Built-in synchronization protocols of YAON

\begin{picture}(60.00,50.00)(0.00,0.00)
\put(0.00,0.00){\line(6,5){60.00}}
\put(60.00,0.00){\line(-6,5){60.00}}
\end{picture}
Strict Mutual Exclusion.

\begin{picture}(60.00,60.00)(0.00,0.00)
\put(20.00,10.00){\makebox(0.00,0.00)[t...
...{\makebox(0.00,0.00){Readers}}
\put(0.00,0.00){\line(4,3){60.00}}
\end{picture}

Concurrent Readers, mutually exclusive Writers.

\begin{picture}(60.00,60.00)(0.00,0.00)
\put(20.00,10.00){\makebox(0.00,0.00)[t...
...{\makebox(0.00,0.00){READERS}}
\put(0.00,0.00){\line(4,3){60.00}}
\end{picture}

Concurrent Readers with priority for waiting readers, mutually exclusive Writers.

\begin{picture}(60.00,60.00)(0.00,0.00)
\put(20.00,10.00){\makebox(0.00,0.00)[t...
...{\makebox(0.00,0.00){Readers}}
\put(0.00,0.00){\line(4,3){60.00}}
\end{picture}

Concurrent Readers, mutually exclusive writers with priority for waiting Writers.

\begin{picture}(90.00,50.00)(0.00,0.00)
\put(77.00,42.00){1}
\put(77.00,22.00)...
...0,25.00){\oval(70.00,10.00)}
\put(35.00,5.00){\oval(70.00,10.00)}
\end{picture}

The methods are called following the priority where 1 is the highest priority.