Benefits of the .NET Framework

The .NET Framework offers a number of benefits to developers:
1. A consistent programming model
2. Direct support for security
3. Simplified development efforts
4. Easy application deployment and maintenance

1. Programming model
Different programming languages offer different models for doing the same thing. For example, the following code demonstrates how to open a file and write a one-line message to it using Visual Basic 6.0:

Public Sub testFileAccess()
On Error GoTo handle_Error
' Use native method of opening an writing to a file...
Dim outputFile As Long
outputFile = FreeFile
Open "c:\temp\test.txt" For Output As #outputFile
Print #outputFile, "Hello World!"
Close #outputFile

' Use the Microsoft Scripting Runtime to
' open and write to the file...

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim outputText As TextStream
Set outputText = fso.CreateTextFile("c:\temp\test2.txt")
outputText.WriteLine "Hello World!"
outputText.Close
Set fso = Nothing
Exit Sub
handle_Error:
' Handle or report error here
End Sub

This code demonstrates that more than one technique is available to create and write to a new file. The first method uses Visual Basic's built-in support; the second method uses the Microsoft Scripting Runtime. C++ also offers more than one way of performing the same task, as shown in the following code:

#include
#include
#include
#include
using namespace std;
int main(int argc, char* argv[])
{
// Use the C Runtime Library (CRT)...
FILE *testFile;
if( (testFile = fopen( "c:\\temp\\test3.txt",
"wt" )) == NULL ) {
cout << "Could not open first test file!" << style="font-weight: bold;">

Visual Basic .NET:

Imports System.IO
Imports System.Text
Module Demo
Sub Main()
Dim outputFile As StreamWriter = _ New StreamWriter("c:\temp\test5.txt")
outputFile.WriteLine("Hello World!")
outputFile.Close()
End Sub

End Module

Visual C# .NET:

using System.IO;
using System.Text;
class Demo
{
static void Main()
{
StreamWriter outputFile = new StreamWriter("c:\\temp\\test6.txt");
outputFile.WriteLine("Hello World!");
outputFile.Close();
}

The preceding code demonstrates, apart from slight syntactical differences, that the technique for writing to a file in either language is identical — both listings use the StreamWriter class to write the "Hello World!" message out to the text files. In fact, unlike the Visual Basic and Visual C++ listings, which demonstrate that there's more than one way to do something within the same language, the preceding listings show that there's a unified means of accomplishing the same task by using the .NET Class Library.

The .NET Class Library is a key component of the .NET Framework — it is sometimes referred to as the Base Class Library (BCL). The .NET Class Library contains hundreds of classes you can use for tasks such as the following:
1. Processing XML
2. Working with data from multiple data sources
3. Debugging your code and working with event logs
4. Working with data streams and files
5. Managing the run-time environment
6. Developing Web services, components, and standard Windows applications
7. Working with application security
8. Working with directory services

The functionality that the .NET Class Library provides is available to all .NET languages, resulting in a consistent object model regardless of the programming language developers use.

2. Direct support for security
Developing an application that resides on a user's desktop system and uses local resources is easy, from a security point of view, because security simply isn't a consideration in this scenario. Security becomes much more important when you create applications that access data on remote systems or applications that perform privileged tasks on behalf of non privileged users, because systems may have to authenticate users, and encryption (scrambling to avoid eavesdropping) may be necessary to secure data communications.

Windows NT, Windows 2000, and Windows XP have a number of security features based on Access Control Lists (ACLs). An ACL contains a number of entries that specify which users may access, or are explicitly denied access, to resources such as files and printers. ACLs are a great way of protecting executable files (applications) from unauthorized access, but they do not secure all parts of the file. The .NET Framework enables both developers and system administrators to specify method-level security. Developers (through easy-to-use programming language constructs called attributes) and systems administrators (by using administrative tools and byediting an application's configuration file) can configure an application's security so that only authorized users can invoke a component's methods.

The .NET Framework uses industry-standard protocols such as TCP/IP and means of communications such as the Extensible Markup Language (XML), Simple Object Access Protocol (SOAP, a standard application messaging protocol), and HTTP to facilitate distributed application communications. This makes distributed computing more secure, because .NET developers cooperate with network connectivity devices as opposed to attempting to work around their security restrictions.

3. Simplified development efforts
Two aspects of creating Web-based applications present unique challenges to Web developers: visual page design and debugging applications. Visual page design is straightforward when creating static content; however, when you need to present the result of executing a query in a tabular format using an ASP page, page design can get rather involved. This is because developers need to mix traditional ASP code, which represents the application's logic, and HTML, which represents the resentation of the data. ASP.NET and the .NET Framework simplify development by allowing developers to separate an application's logic from its presentation, resulting in an easier-to-maintain code base. ASP.NET can also handle the details of maintaining the state of controls, such as the contents of text boxes, between calls to the same ASP.NET page, thereby reducing the amount of code you need to write. Visual Studio .NET, which is tightly integrated with the .NET Framework, assists developers as they create ASP.NET and other applications by providing visual designers that facilitate visual drag and drop editing, making page layout and form layout a breeze.

Another aspect of creating applications is debugging. Developers sometimes make mistakes; systems don't behave as you expect them to, and unexpected conditions arise — all of these issues are collectively referred to as, using the affectionate term, "bugs." Tracking down bugs — known as "debugging" — quickly and effectively requires developers to be familiar with a variety of tools, sometimes available from a third party, and techniques — a combination of programming techniques and techniques for using a particular tool. The .NET Framework simplifies debugging with support for Runtime diagnostics.

Runtime diagnostics not only help you track down bugs but also help you determine how well your applications perform and assess the condition of your application. The .NET Framework provides three types of Runtime diagnostics:
1. Event logging
2. Performance counters
3. Tracing

0 Comments: