Transient Properties?

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Transient Properties?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:40 am

by Carl Ranson >> Sun, 28 Feb 1999 22:59:49 GMT

Hi All,

I wanted to "run this up the flagpole..."

I have often thought it might be nice if jade classes had the option of marking properties as transient.

This would allow you to have some properties on a class that can be modified without being in transaction state. Could be useful for partial results, caching results etc.

Anybody going to salute?

Regards,
Carl Ranson (Turing Solutions)

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Transient Properties?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:40 am

by Craig Shearer >> Mon, 1 Mar 1999 19:02:56 GMT

Hmmmm.... can't think of a use for this (other than those you propose Carl), but I know that the feature is commonly available in other OODB environments.

Craig.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Transient Properties?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:40 am

by Dean Cooper >> Tue, 2 Mar 1999 2:08:27 GMT
I have often thought it might be nice if jade classes had the option of marking properties as transient.
This would allow you to have some properties on a class that can be modified without being in transaction state. Could be useful for partial results, caching results etc.


This is an interesting idea and one that we may consider in the future.

But you can achieve something similar today quite easily with a couple of classes and methods on app, for example:

abstract class WorkingStorage
(
referenceDefinitions:
relatedObject: Object;
)

class WorkingStorageDict subclassOf MemberKeyDictionary
(
membership:
WorkingStorage
keys:
relatedObject
)

Now you can subclass WorkingStorage with whatever classes you require, with each class containing your necessary ("transient") properties. If you need only a simple or common working storage area, then you could just make WorkingStorage a concrete class, add the additional properties you need and use it.

On your app class, add a reference (workingStores, say) of type WorkingStorageDict. You can then implement a couple of methods like the following (basic implementations):

getWorkingStorage(obj: Object; wsSubclass: Class): WorkingStorage updating; vars
ws: WorkingStorage;begin

ws := workingStores[obj];
if ws <> null then
return ws;
endif;
if wsSubclass = null then
// null working storage class
// raise an exception, return null, etc...
endif;
if not wsSubclass.inheritsFrom(WorkingStorage) then
// we create only WorkingStorage subclasses
// raise an exception, return null, etc...
endif;
if wsSubclass = WorkingStorage then
// WorkingStorage is abstract
// raise an exception, return null, etc...
endif;
create ws as wsSubclass transient;
ws.relatedObject := obj;
workingStores.add(ws);
return ws;
end;

removeWorkingStorage(obj: Object) updating;
vars
ws: WorkingStorage;begin

ws := workingStores[obj];
if ws <> null then
workingStores.remove(ws);
delete ws;
endif;
end;

Now, when you need a transient working storage area for an object (say a Customer), you can implement:

vars
cust : Customer;
wsCust : CustWorkingStorage; // subclass of WorkingStorage
begin

// some code...

wsCust := app.getWorkingStorage(cust,
CustWorkingStorage).CustWorkingStorage;

// some more code using wsCust...

epilog
app.removeWorkingStorage(cust);
end;

If you want to avoid the type guard on the call to app.getWorkingStorage you could have a method on app for each type of working storage that you need. Personal preference I guess.

Hope this helps.

Dean.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 30 guests