Methods that switch from Client to Server

Discussions about design and architecture principles, including native JADE systems and JADE interoperating with other technologies
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Methods that switch from Client to Server

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

by JADE Kid - Ray Hidayat >> Sat, 13 Jan 2001 6:03:01 GMT

I have a method. It has a reference to certain files. Now the files could be on either the server or the client.

Obviously, if I was going to create a database of what is in certain folders and do other operations I would want it to be server or client execution depending on the situation.

Do I need to write two methods that do the same thing, but have either client or server execution in its signature, or is there an easier way?

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

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

Re: Methods that switch from Client to Server

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

by Abduhl >> Sat, 13 Jan 2001 6:47:05 GMT
Do I need to write two methods that do the same thing, but have either client or server execution in its signature, or is there an easier way?

In current releases you need to define two methods, that is separate clientExecution and a serverExecution versions. It would pay to implement a single jacket method that is called from each of the client and serverExecution methods. There is a proposal to allow a method's execution node to by dynamically sepcified at runtime; 'its all there, someone just has to write the code'.

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

Re: Methods that switch from Client to Server

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

by JADE Kid - Ray Hidayat >> Sat, 13 Jan 2001 8:52:22 GMT

Having two methods call another is a very good idea. I never thought of that.

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

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

Re: Methods that switch from Client to Server

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

by Robert Barr >> Sun, 14 Jan 2001 20:39:25 GMT

I found that following to be a fairly elegant solution - you can write a number of methods with a 'selectable' processing node, but with a single copy of critical code.

Create subclasses of File (for example) as below.

File
|--ServerFile
|--ClientFile

Add your method (the one with the code) on the File class. Create jacket methods on the subclasses that specify the processing node (serverExecution or clientExecution).

If you know the processing node at development time, then you can create refs or vars of the appropriate class. If the processing node is unknown until runtime, you can use the "create ... as ..." construct.


Return to “Design and Architecture”

Who is online

Users browsing this forum: No registered users and 12 guests

cron