How do you determine which technological features should be present in any application? This chapter looks at advancements that will help make you increase you VB.NET application performance, as it becomes more secure, manageable, and scaleable. The key scenarios include VB.NET security implementation (IPrincipal interface, IIdentity interface property, cryptographic objects), VB.NET application manageability (configuration files), .NET deployment process features, multithreading, ASP.NET page caching and ADO.NET.
Security attacks are very common, and nobody wants to have an unsecured application running in their organization. That is why the .NET Framework provides classes that help to manage security situations: they make it easy to implement role-based security in your application. Implementing and enforcing security consists of two parts: authentication and authorization. This is achieved by implementing custom principal and identity classes based on the IPrincipal and IIdentity interfaces.
The UserIdentity type implements the IIdentity interface, which requires you to implement three properties:
A Principal object is a holder for all the roles the user belongs to (according to the active authentication mechanism). Any .NET class that implements the IPrincipal interface is a valid Principal object. The IPrincipal interface exposes the Identity property (which returns the underlying Identity object) and the IsInRole method.
They support well-known algorithms and their common uses, including hashing, encryption, and generating digital signatures. These objects are designed to allow you to easily incorporate these basic capabilities into more complex operations, such as signing and encrypting a document.
The cryptographic algorithms supported include:
You can use configuration files to configure .NET applications without compiling them. These configuration files help you to store application variables and configuration values, just as you could with earlier versions of Visual Basic (by using .ini files and later, registry settings). In addition, Visual Basic .NET configuration files allow you to keep properties for visual components so they can be dynamically changed by just editing a text file.
Configuration files can contain different types of information, depending on the type of application that will use them. A configuration file for a .NET client application will be significantly different from those for a .NET server application: the configuration file will contain different sections, attributes, and values.
Typically, you need to perform the following tasks:
The .NET Framework offers different ways to deploy your application, including:
Both classes contain the same properties and methods. The difference between them is that Debug is available only when the application runs in Debug mode, while Trace is available in both Debug and Release modes. This means that the code you write using the Debug class cannot be executed in the Release configuration.
These are the most important:
Exception Handling Considerations
Exception handling is a key aspect of developing applications on the .NET Framework. It allows you to easily and gracefully recover from errors that could easily crash an application. However, exception handling can be expensive in terms of system resources. For this reason, you should exercise restraint when using exceptions in your applications.
String Handling Considerations
When a string is altered, the original string is garbage collected, and a new object is created to hold the changed string. This may not be an issue for a small number of changes, but an excessive number can tax the system.
The .NET Framework includes the StringBuilder class, which is a special class designed to be used when you manipulate string objects. The StringBuilder class includes methods for altering the contents of a string. It is contained in the System.Textnamespace.
Data Base Access Considerations
The .NET Framework recommends that you tune for database access by using only the functionality that you need, and that you design for a disconnected approach. With this approach, you make several connections in sequence, instead of holding a single connection open for a long time. In addition, Microsoft recommends an n-tier strategy for maximum performance, as opposed to a direct client-to-database connection strategy. Consider this recommendation as part of your design philosophy, because many of the technologies in the .NET Framework are optimized to take advantage of a multi-tiered architecture.
Multithreading, or free-threading, refers to the ability of a program to execute multiple threads of operation simultaneously. Multithreading can be a powerful tool to use in component programming. By writing multithreaded components, you can create components that perform complex calculations in the background while leaving the user interface free to respond to user input.
Yes. Caching is a well tested and successful technique for performance improvement. HTML pages can be cached to improve their loading speed. A more indirect example of caching is connection pooling, which provides an efficient way to manage connections and share them across different service requests. In connection pooling, whenever a connection request is received, the connection pool checks if there is an existing idle connection that can be used to fulfill the request.
The following are some of the key concepts for caching ASP.NET pages:
Marshaling is the process of converting information for communication between threads. In COM, marshaling is used when data moves across context boundaries such as operating system processes or computers.
Web proxies are components that reside on the client computer. They facilitate the client’s communication with a Web service and are responsible for transparently issuing requests to the Web service and interpreting the results for the client.
A service agent is a service that helps your application work with other services.
The agent runs topologically close to the application consuming the service. It helps both to prepare requests sent to a service and to interpret responses from the service. Service agents offer the following advantages:
The ODBC and OLE DB components can be described as follows:
You must upgrade the programmer interface used to interact with the data source. Depending on the data source, this interface will be DAO, RDO, or ADO. Information on how to upgrade DAO, RDO, and DAO code is provided in Chapter 12, “Upgrading Data Access.” However, if the resources are available to do so, it is recommended that you upgrade any data access interfaces to ADO.NET.