Subclassing JadeScript

The use of specific JADE features and proposals for new feature suggestions
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Subclassing JadeScript

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:41 am

by Robert Barr >> Fri, 23 Jun 2000 3:41:41 GMT

Is there a reason why you can't subclass JadeScript?

JadeScript subclasses would be particularly useful when several developers are working on a system - purely as a mechanism to separate each developer's working scripts and make them easier to find, e.g.

JadeScript
|
|----- JadeScript_fred
|
|----- JadeScript_jo
|
| ----- JadeScript_bert


On a large development, I often have a few 'initialisation' methods for JadeScripts - these 'common' methods, defined on JadeScript, would be available to the subclasses.

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

Re: Subclassing JadeScript

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:41 am

by JADE Kid - Ray Hidayat >> Tue, 4 Jul 2000 21:15:20 GMT

Well, I don't think that there is any reason to have JadeScript non-subclassable, but I think it is that JadeScript isn't a object thingy where you can create objects, and all that. It is special, so subclassing it would just be stupid, because you aren't going to have a database that uses the class, and why would you want to have objects that are a kind of JadeScript. So I'm sure that the people at JADE realised that a sub-JadeScript isn't a JadeScript, and so you can't subclass it.

About the initialisation methods.

Did you know...
You can use initialisation methods in your application? Just set it in your application properties. And make sure the method is in the app class. So you can get these initialisation methods to run automatically.

--
Ray Hidayat
JADE Kid - 2000
www.jadekids.com

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

Re: Subclassing JadeScript

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:41 am

by BeeJay >> Tue, 4 Jul 2000 21:51:55 GMT
Well, I don't think that there is any reason to have JadeScript non-subclassable, but I think it is that JadeScript isn't a object thingy where you can create objects, and all that. It is special, so subclassing it would just be stupid, because you aren't going to have a database that uses the class, and why would you want to have objects that are a kind of JadeScript. So I'm sure that the people at JADE realised that a sub-JadeScript isn't a JadeScript, and so you can't subclass it.


Actually I think you may have missed Rob's point which was to create a different subclass for each developer so they can keep their list of scripts small and logically grouped. I think this would be a fine idea and you may too when you get into a multiUser development environment with 10+ developers working in one set of schemas all creating their own JadeScripts.
About the initialisation methods.

Did you know...
You can use initialisation methods in your application? Just set it in your application properties. And make sure the method is in the app class. So you can get these initialisation methods to run automatically.


I'm sure Rob is more than aware of this but what initialise method is going to run automatically for you when you F9 a JadeScript to execute it?

BeeJay.

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

Re: Subclassing JadeScript

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:41 am

by Craig Shearer >> Tue, 4 Jul 2000 23:17:44 GMT

I think that subclassing JadeScript is a good idea, and I completely agree with Robert.

Actually, did you know that you can create JadeScript objects at runtime, say if you want to run a method on them. I'd frown upon this, as if you have methods on JadeScript that really are part of your production system then they really should be on a dedicated class. However, you can do the following:

vars
js : JadeScript;begin

// create a transient instance of the JadeScript class
create js transient;

// execute the method I want
js.doSomething;

epilog
delete js;
end;

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

Re: Subclassing JadeScript

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:41 am

by John Porter >> Wed, 5 Jul 2000 7:06:41 GMT

How do you create the method itself? I want to generate and run a JadeScript. In development, of course! :-)

Cheers,
John P

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

Re: Subclassing JadeScript

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:41 am

by Craig Shearer >> Wed, 5 Jul 2000 10:18:41 GMT

Well, to create a JadeScript method, you add a method to the JadeScript class as usual in the development environment :-)

But of course, this isn't what you were meaning.

There is a class called JadeCompiler of which you can create a transient instance, then call the execute method to compile and execute some source code you provide in a string.

Here's an idea of how to do it:

vars
jc : JadeCompiler;
src : String;
errorCode,
errorPos,
errorLen : Integer;
begin

create jc transient;
src :=
"begin

write 'Hello, world!';
end;
";

jc.execute(src, self, currentSchema, null, errorCode, errorPos, errorLen);
if errorCode <> 0 then
write "Error code: " & errorCode.String;
endif;

epilog
delete jc;
end;


You can do pretty much anything you want, but the limitation is that you're restricted to compiling one method - ie, you can't have more than one method that you compile and execute on the fly with one calling another.

And also, there is the performance overhead of having to compile the method before it is executed. However, I have used this technique to allow me to write some code in a textbox in a production system, then execute it (after carefully checking it!!!!) - this is sometimes better than having to take a production system down so you can load a new method to achieve some task.

Hope this helps :-)

Craig.


Return to “Feature Discussions”

Who is online

Users browsing this forum: No registered users and 4 guests

cron