Collaboration is the interaction of some objects to accomplish a task. Evey object involved in a collaboration has a role.

Component and Class

In Parham, a component is the implementation of a collaboration. Moreover, classes are defined within components and define the role of the objects involved in the collaboration.

In Parham a component has two types of objects: internal and interface. An internal object is only accessible inside the component. Therefore, its behavior is completely defined by the component. Such objects are defined by internal classes.

An interface object is an object which is common between this component and some other components. It means that every component that has access to this object can define its own role for it. Therefore, the behavior of the object is the union of the roles defined by various components for it. Interface objects are defined by interface classes.

Component Instantiation

When a component needs the service of another component it has to declare an instance of that component. In fact except the main component that defines the application, all other components should be instantiated in order to be used.

When a component is instantiated its interface classes are mapped onto the classes of the instantiating component.


Parham components are compile time entities. It means that they do not exist at the runtime. In fact, Parham components are stateless entities whose mere purpose is to define classes.

Moreover, interface classes do not define the behavior of an object completely. Therefore, in Parham objects can be created only from internal classes.

Counter Component

In Parham every component is defined in a separate file.

The declaration of a component begins with its name and its interface classes.


In Parham except the main component any other component must have at least one interface classes.

The body of a component is a set of declarations that define the internal classes and properties of the component.

The declaration of an internal class is as follows.


As it was noted in Parham only classes have state. It means that except methods any other property can be defined only for classes.

The simplest way to define a property for a class is to define an attribute for it. It is done using the following syntax.



    int count;


When a method belongs to a class its name is preceded by its class name.

void ()

When it does not belong to any class it is declared as follows.

int main ()

Sample Usage

In this example, a component is developed whose purpose is to maintain a counter. It has one interface class: CounterClass.

CounterClass is a counter. It has a counter attribute. When an object of CounterClass is created its counter value is zero. The class has two methods: inc and get. inc increases the value of counter and get returns its current value.

The sample is made from three files.

  • Counter component
  • App component (the main component of the program)
  • I/O functions in C
Counter component

As it was mentioned the file begins with the name of the component and its interface classes.

After them the public methods of the component are provided. Although it is not necessary doing so improves the readability of the code.

After it the constructor and the implementation of the methods of CounterClass are provided.

App component

App component is the main component of the application. Therefore, it does not have any interface class. However, it has an internal class named CCounter.

After declaring the internal class, it has declared an instance of Counter.


By this declaration, CCounter inherits the methods and attributes of CounterClassof Counter component.

Finally, the component has the main function. In the main function it has declared object c of type is CCounter.

The rest of the function makes an object of CCounter type and calls various methods on it.

I/O functions

Finally, the C file has the I/O functions which are called from Parham files.

Remember that they are marked by foreign modifier in Parham files.

The source code of the sample can be downloaded from the link provided at the beginning of this example.


public void ();

public int CounterClass.get ();



    int count;


CounterClass ()


    count = 0;


public void ()




public int CounterClass.get ()


    return count;


Counter component



foreign void cprint (int count);


foreign int main ()


    CCounter c;

    c = new CCounter ();

    cprint (c.get ()); ();

    cprint (c.get ());


App component

#include <stdio.h>

void cprint (int count)


    printf (“value of count is %dn”, count);


I/O functions in C