World's most popular travel blog for travel bloggers.

Dynamic changes to classes or context activation -- how to treat existing objects in a consistent way?

, , No Comments
Problem Detail: 

I am looking for references and papers on the following topic.

  1. In general, some programming languages allow dynamic changes to classes. As an example, a new instance variable 'weight' can be added to the class Edge (the class of unweighted edges of graphs). But what should happen with existing edge objects?

    They can be upgraded to include the new instance variable with a default value, perhaps weight 0, in the edge example. Or existing objects stay the same.

  2. In context-oriented programming, similar situations can arise, when a context is dynamically activated at run-time. This may affect changes to methods which are currently executed (although I am concerned at the single thread execution at the moment).

  3. Considering design patterns, when a proxy object wraps another object, references to the old object may expect certain invariants that the proxy object doesn't adhere to. This may also lead to inconsistencies when an object is wrapped/'updated' with a proxy object.

Are there any references that list possible ways to treat the problem in case of dynamic changes/activation? Like the options to keep the state consistent?

I looked primarily in the communities of dynamic software evolution, context-oriented programming and software components. Are there other important communities I can search to find references?

Asked By : mrsteve
Answered By : Dave Clarke

A recent paper on this topic that I stumbled upon is Incremental Dynamic Updates with First-class Contexts by Erwann Wernli, Mircea Lungu, and Oscar Nierstrasz. The approach taken in the paper is not based on global updates. Rather, multiple versions of a system run simultaneously in what is called a context. Objects are gradually migrated from one context to another, at which time an update is performed. Bidirectional transformations are used to maintain consistency between old an new contexts.

In general, I think you need to have a pair of update functions for any update, one for updating classes, the other for updating objects. The real issue is when/how do you apply the update functions to objects. In any case, you will often have multiple versions of classes around at the same time. UpgradeJ (by Biermann, Parkinson and Noble) is one programming language that deals with multiple versions of a class in a type safe fashion.

The bibliography of these papers provides a few leads that you could follow. Also look on google scholar to see what paper build on these.

Best Answer from StackOverflow

Question Source :

3200 people like this

 Download Related Notes/Documents


Post a Comment

Let us know your responses and feedback