The argument values can be retrieved by using the va_arg, va_start and va_end macros.
These macros assume that the function will be called with a fixed number of required parameters and variable number of optional parameters.
The following sample program uses a function Add with variable arguments and returns the value of the added items.
#include
#include
int Add(int a,int b,...){
//This one handles 4 arguments in total.
int l_ParamVal=0;
int total=0;
int i;
//Declare a va_list macro and initialize it with va_start
va_list l_Arg;va_start(l_Arg,a);
//The required parameters can also be accessed directly
l_ParamVal = a;
printf("%d\n",l_ParamVal);
if(l_ParamVal != -1)
total = total +l_ParamVal;
l_ParamVal = va_arg(l_Arg,int);
printf("%d\n",l_ParamVal);
if(l_ParamVal != -1)total = total +l_ParamVal;
l_ParamVal = va_arg(l_Arg,int);
printf("%d\n",l_ParamVal);
if(l_ParamVal != -1)
total = total +l_ParamVal;
l_ParamVal = va_arg(l_Arg,int);
printf("%d\n",l_ParamVal);
if(l_ParamVal != -1)
total = total +l_ParamVal;
va_end(l_Arg);
return total;
}
void main()
{
printf("Total of C++ Variable Arguments: %d\n",Add(2,3,4));
}
The above sample takes some integer parameters and returns their added result. This function can handle up to 4 parameters.
Tuesday, October 30, 2007
Monday, October 15, 2007
Inline Functions in C++
When a function is declared inline, the function is expanded at the calling block.
The function is not treated as a separate unit like other normal functions.
But a compiler is free to decide, if a function qualifies to be an inline function. I
f the inline function is found to have larger chunk of code, it will not be treated as an inline function, but as like other normal functions.
Inline functions are treated like macro definitions by the C++ compiler.
They are declared with the keyword inline as follows.
//Declaration for C++ Tutorial inline sample:
int add(int x,int y);
//Definition for C++ Tutorial inline sample:
inline int add(int x,int y)
{
return x+y;
}
In fact, the keyword inline is not necessary. If the function is defined with its body directly and the function has a smaller block of code, it will be automatically treated as inline by the compiler.
As implied, inline functions are meant to be used if there is a need to repetitively execute a small block of code, which is smaller.
When such functions are treated inline, it might result in a significant performance difference.
The function is not treated as a separate unit like other normal functions.
But a compiler is free to decide, if a function qualifies to be an inline function. I
f the inline function is found to have larger chunk of code, it will not be treated as an inline function, but as like other normal functions.
Inline functions are treated like macro definitions by the C++ compiler.
They are declared with the keyword inline as follows.
//Declaration for C++ Tutorial inline sample:
int add(int x,int y);
//Definition for C++ Tutorial inline sample:
inline int add(int x,int y)
{
return x+y;
}
In fact, the keyword inline is not necessary. If the function is defined with its body directly and the function has a smaller block of code, it will be automatically treated as inline by the compiler.
As implied, inline functions are meant to be used if there is a need to repetitively execute a small block of code, which is smaller.
When such functions are treated inline, it might result in a significant performance difference.
Wednesday, October 10, 2007
Enhancements of Visual Studio.Net 2005
In this article, we will come across in brief the different enhancement that has been incorporated in the new release of Microsoft - Visual Studio .net 2005 code named Whidbey, which is touted to have major improvements in the software development experience and productivity.
Compared to the previous versions of .net that were released, in the new version, Microsoft has added Express versions for each of the languages C#, VB, C++, J# along with ASP .Net and SQL Server 2005 separately. All these versions of Express editions are freely downloadable and can be used for learning and development.
Below is a brief look at some of the feature enhancements in the new version.
Visual basic:
Visual basic IDE has been enhanced with a lot of features to improve developer productivity. Microsoft has tried reducing the pains of syntax errors by making the IDE more intuitive while development thereby easing the task of coding for both new and experienced programmers.
The Visual Basic IDE also includes the ability to edit code and continue to run without restarting the program.
Reduction in syntax errors by intuitive Intelli-senseDebugging support without restarting the applications, thereby reducing the time required for debugging cycle.
Improved Exception handling mechanisms. Error reporting with clear messages, paving the way for clear detection of errors.
Better upgrade support from old Visual basic 6.0 apps, There are many other productivity enhancements, including the MyServices abstraction. MyServices is a series of coded shortcuts that make it easier to find system and application resources.
For example, code such as My.Computer and My.WebServices are programmatic shortcuts to system resources and Web service references respectively.
Visual C++:
Visual C++ will offer expanded support for the CLR and the .NET Framework.
Better optimization facilities when compared with other .Net languages namely Profile Guided Optimizations (POGO).
This POGO technology enables the compiler to instrument an application and collect details on how an application is being used at runtime. This will be used by Visual C++ to optimize the code generated based on the real world patterns.
This is supported for 64 bit apps currently and will also be available for 32 bit apps. This is available as a part of the Build Menu in Visual Studio .Net.
Availability of 64 bit compilers targeting support for both Intel and AMD based hardware.
It offers enhanced support for Standard Template Library. STL is tuned for interacting with both managed code and data.
Support for a new category of type called Handle. Handles are pointers but use the Carat (^) symbol for access.
Visual C#:
C# Rapid App Development gets a major boost with .net framework 2.0 and Visual Studio 2005. The new features generics, iterators, anonymous methods, partial types and refactoring are some of the items which deserve to be highlighted.
Generics are a parallel for C++ templates. They allow high level of code reuse and further speed up the process of Software development.Anonymous methods are dynamic methods which need not be pre-defined. They can be defined at the point of need. They can be used in place of event handler delegates.
Another huge boost could be the support for Refactoring. Refactoring is one among the basic tenets of Test Driven Development. Visual C# 2005 automates this feature by providing support for this feature.
Visual Studio 2005 delivers a long-requested feature, which is the ability to correct programming errors during debugging and continue to run without restarting the program.
The C# IDE includes a suite of tools that automate many common refactoring code tasks.
Developers can easily rename classes, fields, properties, and methods, extract code into its own method, reorder or delete parameters to a method, promote a local variable to be a parameter, encapsulate fields, and perform many other refactoring tasks.
The tools ensure that when any change is made, all dependant modules are also updated.Web Development :
Apart from the above the support for Web development is also enhanced to a great extent.
Support for integrated database development with SQL Server 2005Personal Web starter kit enabling easier web application development, multi browser support.
Compared to the previous versions of .net that were released, in the new version, Microsoft has added Express versions for each of the languages C#, VB, C++, J# along with ASP .Net and SQL Server 2005 separately. All these versions of Express editions are freely downloadable and can be used for learning and development.
Below is a brief look at some of the feature enhancements in the new version.
Visual basic:
Visual basic IDE has been enhanced with a lot of features to improve developer productivity. Microsoft has tried reducing the pains of syntax errors by making the IDE more intuitive while development thereby easing the task of coding for both new and experienced programmers.
The Visual Basic IDE also includes the ability to edit code and continue to run without restarting the program.
Reduction in syntax errors by intuitive Intelli-senseDebugging support without restarting the applications, thereby reducing the time required for debugging cycle.
Improved Exception handling mechanisms. Error reporting with clear messages, paving the way for clear detection of errors.
Better upgrade support from old Visual basic 6.0 apps, There are many other productivity enhancements, including the MyServices abstraction. MyServices is a series of coded shortcuts that make it easier to find system and application resources.
For example, code such as My.Computer and My.WebServices are programmatic shortcuts to system resources and Web service references respectively.
Visual C++:
Visual C++ will offer expanded support for the CLR and the .NET Framework.
Better optimization facilities when compared with other .Net languages namely Profile Guided Optimizations (POGO).
This POGO technology enables the compiler to instrument an application and collect details on how an application is being used at runtime. This will be used by Visual C++ to optimize the code generated based on the real world patterns.
This is supported for 64 bit apps currently and will also be available for 32 bit apps. This is available as a part of the Build Menu in Visual Studio .Net.
Availability of 64 bit compilers targeting support for both Intel and AMD based hardware.
It offers enhanced support for Standard Template Library. STL is tuned for interacting with both managed code and data.
Support for a new category of type called Handle. Handles are pointers but use the Carat (^) symbol for access.
Visual C#:
C# Rapid App Development gets a major boost with .net framework 2.0 and Visual Studio 2005. The new features generics, iterators, anonymous methods, partial types and refactoring are some of the items which deserve to be highlighted.
Generics are a parallel for C++ templates. They allow high level of code reuse and further speed up the process of Software development.Anonymous methods are dynamic methods which need not be pre-defined. They can be defined at the point of need. They can be used in place of event handler delegates.
Another huge boost could be the support for Refactoring. Refactoring is one among the basic tenets of Test Driven Development. Visual C# 2005 automates this feature by providing support for this feature.
Visual Studio 2005 delivers a long-requested feature, which is the ability to correct programming errors during debugging and continue to run without restarting the program.
The C# IDE includes a suite of tools that automate many common refactoring code tasks.
Developers can easily rename classes, fields, properties, and methods, extract code into its own method, reorder or delete parameters to a method, promote a local variable to be a parameter, encapsulate fields, and perform many other refactoring tasks.
The tools ensure that when any change is made, all dependant modules are also updated.Web Development :
Apart from the above the support for Web development is also enhanced to a great extent.
Support for integrated database development with SQL Server 2005Personal Web starter kit enabling easier web application development, multi browser support.
Thursday, September 20, 2007
Java FX Script
The JavaFX Script programming language (known as JavaFX) is a declarative, statically typed scripting language from Sun Microsystems, Inc. As mentioned on the Open JavaFX (OpenJFX) web site, JavaFX technology has a wealth of features, including the ability to make direct calls to Java technology APIs. Because JavaFX Script is statically typed, it also has the same code structuring, reuse, and encapsulation features; such as packages, classes, inheritance, and separate compilation and deployment units, which make it possible for you to create and maintain very large programs using Java technology.
This article will help you get started with the JavaFX programming language is an introduction to the JavaFX programming language, targeted to those who are already familiar with Java technology and the basics of scripting languages.
The JavaFX Pad Application
If you have a Java Runtime Environment (JRE) on your system, the easiest way to get started with JavaFX technology is to fire up the Java Web Start-enabled demonstration program, JavaFX Pad. Once you start the application, you should see a screen similar to what appears in Figure 1
Figure 1. The JavaFX Pad Application Running on Microsoft Windows OS, JDK 6
JavaFX Pad starts with a default application already loaded, which it immediately executes. The JavaFX Pad application is a great way to see exactly what you're doing at runtime, modifying changes as you go, and instantaneously seeing the results
JavaFX Technology: A Statically Typed Language
The JavaFX programming language is a scripting language with static typing. What exactly does this mean? Consider the following:
var myVariable = "Hello";
This declaration, similar to what you may find in JavaScript technology, creates a variable called myVariable and assigns it the string value Hello. However, after declaring the variable, let's try to assign it something other than a string:
myVariable = 12345;
Because the code does not use quotation marks around 12345, this variable is now being assigned an integer instead of a string. In JavaScript technology, dynamically retyping the variable will work fine. However, a statically typed language such as JavaFX will not allow this. This is because myVariable was initially declared as a String type, and the code later tries to reassign it as an integer. With JavaFX, a variable that is declared as a String must remain a String.
In fact, if you enter those two lines of code into the JavaFX Pad demo, you'll immediately see an error at the bottom of the window, as shown in Figure 2.
This article will help you get started with the JavaFX programming language is an introduction to the JavaFX programming language, targeted to those who are already familiar with Java technology and the basics of scripting languages.
The JavaFX Pad Application
If you have a Java Runtime Environment (JRE) on your system, the easiest way to get started with JavaFX technology is to fire up the Java Web Start-enabled demonstration program, JavaFX Pad. Once you start the application, you should see a screen similar to what appears in Figure 1

Figure 1. The JavaFX Pad Application Running on Microsoft Windows OS, JDK 6
JavaFX Pad starts with a default application already loaded, which it immediately executes. The JavaFX Pad application is a great way to see exactly what you're doing at runtime, modifying changes as you go, and instantaneously seeing the results
JavaFX Technology: A Statically Typed Language
The JavaFX programming language is a scripting language with static typing. What exactly does this mean? Consider the following:
var myVariable = "Hello";
This declaration, similar to what you may find in JavaScript technology, creates a variable called myVariable and assigns it the string value Hello. However, after declaring the variable, let's try to assign it something other than a string:
myVariable = 12345;
Because the code does not use quotation marks around 12345, this variable is now being assigned an integer instead of a string. In JavaScript technology, dynamically retyping the variable will work fine. However, a statically typed language such as JavaFX will not allow this. This is because myVariable was initially declared as a String type, and the code later tries to reassign it as an integer. With JavaFX, a variable that is declared as a String must remain a String.
In fact, if you enter those two lines of code into the JavaFX Pad demo, you'll immediately see an error at the bottom of the window, as shown in Figure 2.
Thursday, September 13, 2007
Using EJB with AJAX
AJAX
AJAX is an acronym for Asynchronous JavaScript And XML. AJAX is not a new programming language, but simply a new technique for creating better, faster, and more interactive web applications. AJAX uses JavaScript to send and receive data between a web browser and a web server.
It makes web pages more responsive by exchanging data with the web server behind the scenes, instead of reloading an entire web page each time a user makes a change. AJAX is a technology that runs in your browser. It uses asynchronous data transfer (HTTP requests) between the browser and the web server, allowing web pages to request small bits of information from the server instead of whole pages. It makes Internet applications smaller, faster and more users friendly.
What is it?
A traditional web application will submit input (using an HTML form) to a web server. After the web server has processed the data, it will return a completely new web page to the user.
Because the server returns a new web page each time the user submits input, traditional web applications often run slowly and tend to be fewer users friendly.
AJAX is an acronym for Asynchronous JavaScript And XML. AJAX is not a new programming language, but simply a new technique for creating better, faster, and more interactive web applications. AJAX uses JavaScript to send and receive data between a web browser and a web server.
It makes web pages more responsive by exchanging data with the web server behind the scenes, instead of reloading an entire web page each time a user makes a change. AJAX is a technology that runs in your browser. It uses asynchronous data transfer (HTTP requests) between the browser and the web server, allowing web pages to request small bits of information from the server instead of whole pages. It makes Internet applications smaller, faster and more users friendly.
What is it?
A traditional web application will submit input (using an HTML form) to a web server. After the web server has processed the data, it will return a completely new web page to the user.
Because the server returns a new web page each time the user submits input, traditional web applications often run slowly and tend to be fewer users friendly.
With AJAX, web applications can send and retrieve data without reloading the whole web page. This is done by sending HTTP requests to the server (behind the scenes), and by modifying only parts of the web page using JavaScript when the server returns data.
XML is commonly used as the format for receiving server data, although any format, including plain text, can be used.
The standard and well-known method for user interaction with web-based applications involves the user entering information (e.g. filling out a form), submitting that information to the server, and awaiting a page refresh or redirect to return the response from the server.
This is at times frustrating for the user, besides being rather different to the 'desktop' style of user interface with which (s)he may be more familiar.
Ajax (Asynchronous Javascript And XML) is a technique (or, more correctly, a combination of techniques) for submitting server requests 'in the background' and returning information from the server to the user without the necessity of waiting for a page load.
Ajax is actually a combination of several technologies working together to provide this capability.
How does it work?
Instead of a user request being made of the server via, for example, a normal HTTP POST or GET request, such as would be made by submitting a form or clicking a hyperlink, an Ajax script makes a request of a server by using the Javascript XMLHTTPRequest object.
Although this object may be unfamiliar to many, in fact it behaves like a fairly ordinary javascript object. As you may well know, when using a javascript image object we may dynamically change the URL of the image source without using a page refresh. XMLHTTPRequest retrieves information from the server in a similarly invisible manner.
AJAX in EJB:
Instead of a user request being made of the server via, for example, a normal HTTP POST or GET request, such as would be made by submitting a form or clicking a hyperlink, an Ajax script makes a request of a server by using the Javascript XMLHTTPRequest object.
Although this object may be unfamiliar to many, in fact it behaves like a fairly ordinary javascript object. As you may well know, when using a javascript image object we may dynamically change the URL of the image source without using a page refresh. XMLHTTPRequest retrieves information from the server in a similarly invisible manner.
AJAX in EJB:
Enterprise applications can use Ajax to provide better Web interfaces that increase the user productivity. In many cases, it is possible to submit a partially completed form to obtain useful information from the server application. For example, the server could perform some early validation or it could use the partial user input to suggest values for the empty form fields, speeding up the data entry process. Ajax can also be used to connect to data feeds whose information is displayed without refreshing the whole page.
The following diagram depicts the EJB-AJAX application's architecture:

Thursday, August 23, 2007
WSDL and UDDI
Understanding WSDL and UDDI
Web Services Description Language (WSDL) is one of the prime specifications in web services, the other two being SOAP and UDDI. WSDL is the description language for web services that describes a set of SOAP messages and how these messages are exchanged across network. WSDL will be in XML format; therefore it can be easily understood and edited by humans and machines.
Another advantage of WSDL being in XML format is that it is programming language independent and also platform independent. In addition, WSDL defines where the web service is available from and what communications protocol has been used to talk to the web service. As a result the WSDL file describes everything that is required to write a program for an XML Web service.
There are tools available in Microsoft Visual Studio .NET to read a WSDL file and generate the code required to communicate with an XML Web service.
Universal Discovery Description Language (UDDI) is a directory where you can expose your web services for other users to easily access it. You can also consume the web service that is already posted in UDDI. However, you can also post a web service without registering it in UDDI.
DISCO is another directory where you can post your web service. But if you want to reach to maximum of customers, you can place it in UDDI. The UDDI directory offers three parts for you to register:
• White Pages
• Yellow Pages
• Green Pages
The white pages consist of the description such as name and address of the company offering the service.
The yellow pages consist of industrial categories based on standard taxonomies such as North American Industry Classification System and Standard Industrial Classification.
The green pages describe the interface to the web service in detail so that anyone can write an application after using the web service.
Web services are described in UDDI directory through a document called Type Model or tmodel. Normally, this tModel contains a WSDL file that describes a SOAP interface to an XML Web service, but the tModel is flexible enough to describe almost any kind of web service.
Apart from using the web services from UDDI, you can also search a particular web service in UDDI. In addition, you can search for companies’ information that posted web services. In certain times, you might know the names of the companies that offer web services but you may not be aware of the web services that they offer.
The WS Inspection is a specification in UDDI that allows you to search for a collection of web services that are located in a particular company name. You can evaluate these web services according to your requirements.
Web Services Description Language (WSDL) is one of the prime specifications in web services, the other two being SOAP and UDDI. WSDL is the description language for web services that describes a set of SOAP messages and how these messages are exchanged across network. WSDL will be in XML format; therefore it can be easily understood and edited by humans and machines.
Another advantage of WSDL being in XML format is that it is programming language independent and also platform independent. In addition, WSDL defines where the web service is available from and what communications protocol has been used to talk to the web service. As a result the WSDL file describes everything that is required to write a program for an XML Web service.
There are tools available in Microsoft Visual Studio .NET to read a WSDL file and generate the code required to communicate with an XML Web service.
Universal Discovery Description Language (UDDI) is a directory where you can expose your web services for other users to easily access it. You can also consume the web service that is already posted in UDDI. However, you can also post a web service without registering it in UDDI.
DISCO is another directory where you can post your web service. But if you want to reach to maximum of customers, you can place it in UDDI. The UDDI directory offers three parts for you to register:
• White Pages
• Yellow Pages
• Green Pages
The white pages consist of the description such as name and address of the company offering the service.
The yellow pages consist of industrial categories based on standard taxonomies such as North American Industry Classification System and Standard Industrial Classification.
The green pages describe the interface to the web service in detail so that anyone can write an application after using the web service.
Web services are described in UDDI directory through a document called Type Model or tmodel. Normally, this tModel contains a WSDL file that describes a SOAP interface to an XML Web service, but the tModel is flexible enough to describe almost any kind of web service.
Apart from using the web services from UDDI, you can also search a particular web service in UDDI. In addition, you can search for companies’ information that posted web services. In certain times, you might know the names of the companies that offer web services but you may not be aware of the web services that they offer.
The WS Inspection is a specification in UDDI that allows you to search for a collection of web services that are located in a particular company name. You can evaluate these web services according to your requirements.
Wednesday, August 8, 2007
WI-FI
Why / Where Should We Use Wi-Fi
The Wi-Fi LAN has a broad application nowadays. Because of the comfortable and quick installation people often replace old wired LANs with Wi-Fi. Such connection allows to move your machine around the place without losing the Internet or other network resources. Working on your laptop you can check your mail from anywhere in your home or office.
Some highly attended places like airports, libraries, schools or even coffee bars offer you constant Internet connection using exactly wireless LAN, so retrieving new files, cruising the global network or corresponding with others will not be a problem anymore in those (and many other) places.
The most important shortcoming in Wi-Fi is the range. So far we may have difficulties in making a connection with a receiver which is more than 50-75 meters away (inside the buildings).
The signal should be stronger to provide larger connectable spaces. Additionally, some of the wireless adapters works on the frequencies that are currently used by many other wireless devices. It can cause a serious interference, so the connection performance can be quite poor.
However, building Wi-Fi network is often the cheapest way to achieve the desired connection with the surroundings. The price of a single wireless adapter is decreasing almost every day, so making a large network area by means of Wi-Fi is the most reasonable way. You will not need to arrange all the wires around and profit by the installation time. By the way, most of the Wi-Fi adapters have user-friendly configuration and diagnostic tools which can help you to adjust or change your WLAN settings or even can do everything for you.
Security:
What about the security? Is there a possibility of stealing our data? Security is your personal decision, but having a wireless connection we should pay attention to protect our private files and encrypt sent messages.
Actually, the security modules were very important since the beginning of the Wi-Fi projection. In order to prevent intercepting your data by the others the designers implemented many security techniques, like Wi-Fi Protected Access (based on encryption), Virtual Private Network (making virtual "tunnels"), Media Access Control Filtering (rejecting unknown MAC addresses), RADIUS Authentication and Authorization (using login and password) or Kerberos (key distribution).
There is also a possibility to combine some of these security mechanisms making your transmissions even more secure.On the other hand providing such security in public places (like Internet cafes) may not meet its expectations. Connecting to protected wireless network you will be asked about a security code, encryption key or a password. If you do not know them, you will not be able to establish a communication link and use Internet resources.
Most of public areas do not use security modules because of that reason making Wi-Fi users data unsafe.
The Wi-Fi LAN has a broad application nowadays. Because of the comfortable and quick installation people often replace old wired LANs with Wi-Fi. Such connection allows to move your machine around the place without losing the Internet or other network resources. Working on your laptop you can check your mail from anywhere in your home or office.
Some highly attended places like airports, libraries, schools or even coffee bars offer you constant Internet connection using exactly wireless LAN, so retrieving new files, cruising the global network or corresponding with others will not be a problem anymore in those (and many other) places.
The most important shortcoming in Wi-Fi is the range. So far we may have difficulties in making a connection with a receiver which is more than 50-75 meters away (inside the buildings).
The signal should be stronger to provide larger connectable spaces. Additionally, some of the wireless adapters works on the frequencies that are currently used by many other wireless devices. It can cause a serious interference, so the connection performance can be quite poor.
However, building Wi-Fi network is often the cheapest way to achieve the desired connection with the surroundings. The price of a single wireless adapter is decreasing almost every day, so making a large network area by means of Wi-Fi is the most reasonable way. You will not need to arrange all the wires around and profit by the installation time. By the way, most of the Wi-Fi adapters have user-friendly configuration and diagnostic tools which can help you to adjust or change your WLAN settings or even can do everything for you.
Security:
What about the security? Is there a possibility of stealing our data? Security is your personal decision, but having a wireless connection we should pay attention to protect our private files and encrypt sent messages.
Actually, the security modules were very important since the beginning of the Wi-Fi projection. In order to prevent intercepting your data by the others the designers implemented many security techniques, like Wi-Fi Protected Access (based on encryption), Virtual Private Network (making virtual "tunnels"), Media Access Control Filtering (rejecting unknown MAC addresses), RADIUS Authentication and Authorization (using login and password) or Kerberos (key distribution).
There is also a possibility to combine some of these security mechanisms making your transmissions even more secure.On the other hand providing such security in public places (like Internet cafes) may not meet its expectations. Connecting to protected wireless network you will be asked about a security code, encryption key or a password. If you do not know them, you will not be able to establish a communication link and use Internet resources.
Most of public areas do not use security modules because of that reason making Wi-Fi users data unsafe.
Subscribe to:
Posts (Atom)