4th International Conference on Principles and Practices ... - MADOC
4th International Conference on Principles and Practices ... - MADOC
4th International Conference on Principles and Practices ... - MADOC
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Interacti<strong>on</strong> am<strong>on</strong>g Objects via Roles<br />
Sessi<strong>on</strong>s <strong>and</strong> Affordances in Java<br />
Matteo Bald<strong>on</strong>i<br />
Dipartimento di Informatica<br />
Università di Torino - Italy<br />
bald<strong>on</strong>i@di.unito.it<br />
Guido Boella<br />
Dipartimento di Informatica<br />
Università di Torino - Italy<br />
guido@di.unito.it<br />
Leendert van der Torre<br />
University of Luxembourg<br />
Luxembourg<br />
leendert@v<strong>and</strong>ertorre.com<br />
ABSTRACT<br />
In this paper we present a new visi<strong>on</strong> in object oriented programming<br />
languages where the objects’ attributes <strong>and</strong> operati<strong>on</strong>s depend<br />
<strong>on</strong> who is interacting with them. This visi<strong>on</strong> is based <strong>on</strong> a new definiti<strong>on</strong><br />
of the noti<strong>on</strong> of role, which is inspired to the c<strong>on</strong>cept of<br />
affordance as developed in cognitive science. The current visi<strong>on</strong> of<br />
objects c<strong>on</strong>siders attributes <strong>and</strong> operati<strong>on</strong>s as being objective <strong>and</strong><br />
independent from the interacti<strong>on</strong>. In c<strong>on</strong>trast, in our model interacti<strong>on</strong><br />
with an object always passes through a role played by another<br />
object manipulating it. The advantage is that roles allow to define<br />
operati<strong>on</strong>s whose behavior changes depending <strong>on</strong> the role <strong>and</strong> the<br />
requirements it imposes, <strong>and</strong> to define sessi<strong>on</strong> aware interacti<strong>on</strong>,<br />
where the role maintains the state of the interacti<strong>on</strong> with an object.<br />
Finally, we discuss how roles as affordances can be introduced in<br />
Java, building <strong>on</strong> our language powerJava.<br />
1. INTRODUCTION<br />
Object orientati<strong>on</strong> is a leading paradigm in programming languages,<br />
knowledge representati<strong>on</strong>, modelling <strong>and</strong>, more recently, also in<br />
databases. The basic idea is that the attributes <strong>and</strong> operati<strong>on</strong>s of an<br />
object should be associated with it. The interacti<strong>on</strong> with the object<br />
is made via its public attributes <strong>and</strong> via its public operati<strong>on</strong>s. The<br />
implementati<strong>on</strong> of an operati<strong>on</strong> is specific of the class <strong>and</strong> can access<br />
the private state of it. This allows to fulfill the data abstracti<strong>on</strong><br />
principle: the public attributes <strong>and</strong> operati<strong>on</strong>s are the <strong>on</strong>ly possibility<br />
to manipulate an object <strong>and</strong> their implementati<strong>on</strong> is not visible<br />
from the other objects manipulating it; thus, the implementati<strong>on</strong><br />
can be changed without changing the interacti<strong>on</strong> capabilities of the<br />
object.<br />
This view can be likened with the way we interact with objects<br />
in the world: the same operati<strong>on</strong> of switching a device <strong>on</strong> is implemented<br />
in different manners inside different kinds of devices,<br />
depending <strong>on</strong> their functi<strong>on</strong>ing. The philosophy behind object orientati<strong>on</strong>,<br />
however, views reality in a naive way. It rests <strong>on</strong> the assumpti<strong>on</strong><br />
that the attributes <strong>and</strong> operati<strong>on</strong>s of objects are objective,<br />
in the sense that they are the same whatever is the object interacting<br />
with them.<br />
Permissi<strong>on</strong> to make digital or hard copies of all or part of this work for<br />
pers<strong>on</strong>al or classroom use is granted without fee provided that copies are<br />
not made or distributed for profit or commercial advantage <strong>and</strong> that copies<br />
bear this notice <strong>and</strong> the full citati<strong>on</strong> <strong>on</strong> the first page. To copy otherwise, or<br />
republish, to post <strong>on</strong> servers or to redistribute to lists, requires prior specific<br />
permissi<strong>on</strong> <strong>and</strong>/or a fee.<br />
PPPJ 2006, August 30 – September 1, 2006, Mannheim, Germany.<br />
Copyright 2006 ACM . . . $5.00.<br />
This view limits sometime the usefulness of object orientati<strong>on</strong>:<br />
1. Every object can access all the public attributes <strong>and</strong> invoke<br />
all the public operati<strong>on</strong>s of every other object. Hence, it is<br />
not possible to distinguish which attributes <strong>and</strong> operati<strong>on</strong>s<br />
are visible for which classes of interacting objects.<br />
2. The object invoking an operati<strong>on</strong> (caller) of another object<br />
(callee) is not taken into account for the executi<strong>on</strong> of the<br />
method associated with the operati<strong>on</strong>. Hence, when an operati<strong>on</strong><br />
is invoked it has the same meaning whatever the caller’s<br />
class is.<br />
3. The values of the private <strong>and</strong> public attributes of an object<br />
are the same for all other objects interacting with it. Hence,<br />
the object has always <strong>on</strong>ly <strong>on</strong>e state.<br />
4. The interacti<strong>on</strong> with an object is sessi<strong>on</strong>-less since the invocati<strong>on</strong><br />
of an operati<strong>on</strong> does not depend <strong>on</strong> the caller. Hence,<br />
the value of private <strong>and</strong> public attributes <strong>and</strong>, c<strong>on</strong>sequently,<br />
the meaning of operati<strong>on</strong>s cannot depend <strong>on</strong> the preceding<br />
interacti<strong>on</strong>s with the object.<br />
The first three limitati<strong>on</strong>s hinder modularity, since it would be useful<br />
to keep distinct the core behavior of an object from the different<br />
interacti<strong>on</strong> possibilities that it offers to different kinds of objects.<br />
Some programming languages offer ways to give multiple implementati<strong>on</strong>s<br />
of interfaces, but the dependance from the caller cannot<br />
be taken into account, unless the caller is explicitly passed as<br />
a parameter of each method. The last limitati<strong>on</strong> complicates the<br />
modelling of distributed scenarios where communicati<strong>on</strong> follows<br />
protocols.<br />
Programming languages like Fickle [9] address the sec<strong>on</strong>d <strong>and</strong> third<br />
problem by means of dynamic reclassificati<strong>on</strong>: an object can change<br />
class dynamically, <strong>and</strong> its operati<strong>on</strong>s change their meaning accordingly.<br />
However, Fickle does not represent the dependence of attributes<br />
<strong>and</strong> operati<strong>on</strong>s from the interacti<strong>on</strong>. Aspect programming<br />
focuses too <strong>on</strong> the sec<strong>on</strong>d <strong>and</strong> third issue, while it is less clear how<br />
it addresses the other <strong>on</strong>es.<br />
Sessi<strong>on</strong>s are c<strong>on</strong>sidered with more attenti<strong>on</strong> in the agent oriented<br />
paradigm, which bases communicati<strong>on</strong> <strong>on</strong> protocols ([10, 13]). A<br />
protocol is the specificati<strong>on</strong> of the possible sequences of messages<br />
exchanged between two agents. Since not all sequences of messages<br />
are legal, the state of the interacti<strong>on</strong> between two agents must<br />
be maintained in a sessi<strong>on</strong>. Moreover, not all agents can interact<br />
with other <strong>on</strong>es using whatever protocol. Rather the interacti<strong>on</strong> is<br />
188