Search This Blog

Wednesday, November 30, 2011

Server and Client execution Process

What does server and client keywords do?
Many of the new x++ developers, when they start coding in x++ they really find hard to understand the usage of “Server” and “Client” keyword or server and client properties, Like when they should use the server method or the class and when the client keyword come into play. So I thought I should compose a post on this.
There are many books which throws light on this keyword, however they are more theoretical than practical and I think for a developer it is really necessary they are taught by live example by scenario so through the post below, I will try to be less theoretical and will try to be more practical and conceptual. Through my overall experience, I found that there are two ways to learn things

1. Fall and get stuck into the problem and try everything before you go through the book or search net (that who else fall into this problem and how he resolved it) and then use that solution. When you do that, you will understand the thinking behind the invention of the technique. You will get more clearer concept and you will have the Eagle’s eye view of the problems
2. Go through the book, copy paste the example and learn. But in this technique, it is hard to recall when you actually get into the problem.
Anyways let’s move to server client approach, I will try to keep it short and will post an example.
Ok so what does server keyword do?
Consider a scenario, where you as a developer or a technical consultant given a job to copy some files to the server through when someone setups something.
For instance, take an example of interest code in Account Receivable –> Collections –> Interest code. The scenario is, On the setting of interest code, you are setting something in file system, specific to the interest code and those file system settings will be used later by the interest calculation job for some calculation. Now, the requirement is there will be other web service that will be consuming those file settings.
What does the above scenario mean?
It means you need to do some setting in the code to copy the file system setting on the server as well. Now you if you see from top view, you need to do two things
1. Create Files on the client (Use the client class or client method for it)
2. Create files on the server because copy is not allowed between client and server normally.(Use the server keyword or server class for it)
How can I make server and client methods?
It is easy just put the server or client keyword before the method or class name and method should be static for Server. Client does not have this limitation.
We also have keyword Server Client for the method and class, what does it mean?
The server client method works as the Called from property of the AOT Object, which means the object execution will be dependent on the caller. If the client method or class is calling the server client class, the class or method will be executed on the client machine and vice versa.

No comments:

Post a Comment

Thanks for visiting my blog,
I will reply for your comment within 48 hours.