Instances of Class class

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Instances of Class class

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:14 pm

by David Mitchell >> Fri, 14 May 1999 4:05:08 GMT

Okay, first a tip. NEVER try creating an instance of the class class unless you know EXACTLY what you are doing, this can seriously stuff up your .dat files. (Not that I have done it or anything. Hmm)

Now a question, does anybody know how I can add Classes dynamically and safely? Has somebody written a method to do this?

Thanks, David.

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

Re: Instances of Class class

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:14 pm

by Dean Cooper >> Fri, 14 May 1999 4:57:10 GMT

You cannot dynamically add classes to your schema (in fact, from Jade 4.1, the kernel prevents you from creating and deleting persistent instances of Class and many other system meta classes; you get a runtime exception if you try). Safely adding or modifying classes in a schema is complex; there are a number of issues to be aware of, especially in multi-user, and particularly to do with keeping the internal state of the kernel in synch across all nodes. The mechanisms Jade uses to achieve this are not available to user processes.

Dean.

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

Re: Instances of Class class

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:14 pm

by David Mitchell >> Fri, 14 May 1999 5:52:58 GMT

Maybe that could be a new feature in a later release of Jade, a method which takes a few parameters (a lot of things must have defaults, since there isn't much to set in the add class dialog) and adds a class, then there could be another two methods, one to add properties, and references and one to add new methods. Would this be possible?

David.

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

Re: Instances of Class class

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:14 pm

by Craig Shearer >> Sun, 16 May 1999 20:26:21 GMT

Want to tell us why you'd want to do this David?

Craig.

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

Re: Instances of Class class

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:14 pm

by David Mitchell >> Mon, 17 May 1999 3:56:19 GMT

I'm not sure if any of you have heard of DAVE before (Arjan will have). DAVE is an attempt at a virtual talking program type thing. Kind of like chatting to your computer. Anyway, what I planned to do, if it was feasible was to make him expand himself by adding classes dynamically, and then he would be able to handle each word differently. The instances of the class would be the different types of the specific word.

For instance if he created a Coffee class then the instances would be things like Expresso, Cappucino, Perculator etc.

But since it appears I won't be able to do this, I have had to resort to using a horrible different method. I can send you a copy of DAVE sometime if you like, but at the moment he is somewhat less intelligent than I would like.

David.

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

Re: Instances of Class class

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:14 pm

by David Mitchell >> Mon, 17 May 1999 3:56:19 GMT

I'm not sure if any of you have heard of DAVE before (Arjan will have). DAVE is an attempt at a virtual talking program type thing. Kind of like chatting to your computer. Anyway, what I planned to do, if it was feasible was to make him expand himself by adding classes dynamically, and then he would be able to handle each word differently. The instances of the class would be the different types of the specific word.

For instance if he created a Coffee class then the instances would be things like Expresso, Cappucino, Perculator etc.

But since it appears I won't be able to do this, I have had to resort to using a horrible different method. I can send you a copy of DAVE sometime if you like, but at the moment he is somewhat less intelligent than I would like.

David.

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

Re: Instances of Class class

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:14 pm

by Wilfred Verkley >> Tue, 18 May 1999 2:18:11 GMT

I dont think it would benifit the mayority of Jade applications to make it that dynamic as to be able to create classes, and other programming constructs on the fly (ala Prolog?).

You can always simulate a class/inheritence/instance relationships with a data structure within the database itself i.e. for DAVE

WordType inheritsFrom Class
name : String [50];
parent : WordType;
children : ClassDict;
instances : WordDict;

Word inheritsFrom Class
name : String [50];
wordType : WordType;

If you did implement word types as jade classes, how would you change and delete them like you would with your normal data?

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

Re: Instances of Class class

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:14 pm

by Dean Cooper >> Tue, 18 May 1999 3:30:12 GMT

WordType and Word should not be subclasses of Class unless you only ever intend to create transients. From Jade 4.1, if you attempt to create persistent instances of Class or a subclass of Class (even if it's a subclass defined in one of your own schemas), an exception will be raised. This is true for a number of other system meta classes as well. This is done to prevent the creation of dependencies in user data on the structure of system meta classes (which, if we allowed it, could result in you having to reorg your data after installing a Jade upgrade that modified meta classes), and to support file-based deployment (we can determine a clear separation at the class level of the files in which system-meta, user-meta and user data objects are stored). This is what allows us, for example, to ship schema upgrades as a set of _sys*.dat files that you simply install over your existing ones; without any impact on your user data.

Dean.

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

Re: Instances of Class class

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:14 pm

by Wilfred Verkley >> Tue, 18 May 1999 22:27:32 GMT

I actually meant "Object". Got one-tracked in my head :-)

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

Re: Instances of Class class

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:14 pm

by Carl Ranson >> Tue, 18 May 1999 21:54:29 GMT
I dont think it would benifit the mayority of Jade applications to make it that dynamic as to be able to create classes, and other programming constructs on the fly (ala Prolog?).
{snip}

I would much rather see a mechanism for generic classes in Jade. It would allow for much more useful utility classes.

eg
vars
L : List[Customer]
index : HashTable[SubSection]
etc.

It seems to me that Jade could be changed to do this without too much effort. After all collections are doing the same thing with MemberType and KeyType.

Anyone from the plant wish to comment on the difficulty of opening up these features?

Regards
CR


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 10 guests