J characteristics

 

Java-like syntax

J is an object language with a Java-like syntax.  It is dedicated to handling the metamodel (browsing capacities) and the UML profile mechanism (double look up mechanism). 

 

Several Java features, such as interface, package and many Java libraries cannot be handled, but J does have some specific unique features that are very convenient when using the metamodel.

 

 

Interpreted language

J is an interpreted language, which means that its code can be modified and tested rapidly.  Instructions are immediately taken into account and their impact is immediately apparent.

 

As a consequence, J provides the "eval" method, which makes it possible to dynamically execute a string containing J code (please see "The eval statement").

 

 

Language for handling the metamodel

J is run at metamodel level and handles model elements created by the user. 

 

For example, if the user creates a "client" class with "name" and "age" attributes, a J program will be able to access the "client" object, ask for its attributes and then handle the "name" and "age" objects.

 

The classes provided in J are, therefore, those defined by the metamodel.

 

 

UML profiles

UML profiles are essential to the structuring and customizing of a J program.  For the J interpreter, the current UML profile is a fundamental piece of information, used to identify the service (operation or attribute) that has been called by a message.  The class of the destination instance is just as important. 

 

The J programmer uses UML profiles to:

·         structure processing by theme (C++ generation, documentation generation, …)

·         redefine the method of a parent UML profile (generation parameterization)

·         define a service that can be shared by several independent J programs (for example, the directory that produces generated files)

 

 

Composition of a J program

J classes are predefined - basic classes (int, …) plus the Objecteering metamodel (Class, Association, …). 

 

As a J programmer, you can declare new methods on them, but you cannot define new classes.  A J programmer uses the objects created by Objecteering users (classes, attributes, …).

 

Note:      Objecteering work products are an exception to this.  You can define "work product classes" that can be handled in J.

 

 

Accessing information

There are several ways to access or handle information:

·         through simple attributes, which are predefined by the Objecteering metamodel

·         through "class" attributes, which can be defined by the J programmer

·         through method parameters

·         through local variables

 

 

Sets

One of the most important aspects of the J language is its capacity to handle sets. 

 

Sets are found in:

·         elements linked to a given model element (for example, the attributes of a class, or the parameters of an operation)

·         variables, attributes or parameters

 

 

Browsing made easier

The J language lets you browse a model, in order to manage all the related information (for example, the classes of a package, or the operations of its classes).  This browsing is handled through:

·         the sending and diffusing of messages

·         the notion of context

·         control messages

 

 

The sending and diffusion of messages

J provides two major control structures:

·         the sending of a message, used to apply a method to an object, is written as follows:

   object.method_name (parameters) ;

 

·         the diffusion of messages applies either to a set of objects, or to an object reference.  Message diffusion is used to send the message to all set occurrences, or to avoid the processing of an empty reference, and is written as follows:

   ReferenceSet.<method_name (parameters) ;

 

Anonymous methods are a special case of diffusion.  They work in the same way, but instead of applying a method to a set or to an object reference, the whole block of instructions is applied according to the set or the reference.

 

ReferenceSet

{

   J processing

}

 

 

The "if" instruction

The "if" instruction is the conditional control structure within J programs.  It applies to boolean expressions:

 

if (condition1)

{

   instructions

}

else if (condition2)

{

   instructions

}

else

{

   instructions

}

 

 

Control messages

J provides the following control messages, which make browsing easier:

·         the "select" message, which is used to filter certain elements (selection)

·         the "while" message, which can limit the evaluation of an expression

These messages are particularly well adapted to sets.

 

 

Comments

The "//" characters indicate comments, which are valid until the end of the current line.

 

if (condition) { // a comment

 

The "/*...*/" characters surround contained comments.