Flylib.com

Books Software

 
 
 

Windows on the Desktop

Team-Fly    

 
Application Development Using Visual Basic and .NET
By Robert J. Oberg, Peter Thorsteinson, Dana L. Wyatt
Table of Contents
Chapter 1.  What Is Microsoft .NET?


Windows on the Desktop

Microsoft began with the desktop. The modern Windows environment has become ubiquitous. Countless applications are available, and most computer users are at least somewhat at home with Windows. While Microsoft has made much progress in modernizing Windows, there are still significant problems.

Problems with Windows

Maintaining a Windows PC is a chore, because applications are quite complex. They consist of many files, Registry entries, shortcuts, and so on. Different applications can share certain DLLs, and installing a new application can overwrite a DLL an existing application depends on, possibly breaking an old application (DLL Hell). Removing an application is a complex operation and is often imperfectly done.

A PC can gradually become less stable, sometimes requiring the drastic cure of reformatting the hard disk and starting from scratch. While there is tremendous economic benefit to using PCs, because standard applications are inexpensive and powerful and the hardware is cheap, the savings are reduced by the cost of maintenance.

Windows was originally developed when personal computers were not connected over a network and security was not an issue. While security was built into Windows NT and Windows 2000, the programming model is difficult to use.

The Glass House and Thin Clients

The old "glass house" model of a central computer that controls all applications has had an appeal , and there has been a desire to move toward "thin clients" of some sort . But the much heralded "network PC" never really caught on. There is too much of value in standard PC applications. Users like the idea of their "own" PC, with their data stored safely and conveniently on their local computer. Without broadband connectivity, a server-based application such as word processing would not perform very well. Security is also a very difficult issue to solve with thin clients. The personal computer is undoubtedly here to stay.

A Robust Windows

With all the hype about .NET and the Internet, it is important to realize that .NET has changed the programming model to allow the creation of much more robust Windows applications. Applications no longer rely on storing extensive configuration data in the fragile Windows Registry. .NET applications are self-describing , containing metadata within the program executable files themselves . Different versions of an application or component can be deployed side by side. Applications can share components through the Global Assembly Cache. Versioning is built into the deployment model. A straightforward security model is part of .NET. Windows Forms technology is a new paradigm for building Windows GUI applications.


Team-Fly    
Top
 
Team-Fly    

 
Application Development Using Visual Basic and .NET
By Robert J. Oberg, Peter Thorsteinson, Dana L. Wyatt
Table of Contents
Chapter 1.  What Is Microsoft .NET?


A New Programming Platform

Let us look at what we have just discussed from the point of view of .NET as a new programming platform:

  • Code can be validated to prevent unauthorized actions.

  • It is much easier to program than the Win32 API or COM.

  • All or parts of the platform can be implemented on many different kinds of computers (as has been done with Java).

  • All the languages use one class library.

  • Languages can interoperate with each other.

There are several important features to the .NET platform:

  • .NET Framework

  • Common Language Runtime

  • Multiple language development

  • Development tools

.NET Framework

Modern programming relies heavily on reusable code provided in libraries. Object-oriented languages facilitate the creation of class libraries, which are flexible, have a good degree of abstraction, and are extensible by adding new classes and basing new classes on existing ones, "inheriting" existing functionality.

The .NET Framework provides over 2,500 classes of reusable code, which can be called by all the .NET languages. The .NET Framework is extensible, and new classes can inherit from existing classes, even those implemented in a different language.

Examples of classes in the .NET Framework include Windows programming, Web programming, database programming, XML, and interoperability with COM and Win32. The .NET Framework is discussed in the next chapter and throughout the rest of the book.

Common Language Runtime

A runtime provides services to executing programs. Traditionally, there are different runtimes for different programming environments. Examples of run-times include the standard C library, MFC, the Visual Basic runtime, and the Java Virtual Machine. The runtime environment provided by .NET is called the Common Language Runtime, or CLR.

Managed Code and Data

The CLR provides a set of services to .NET code (including the .NET Framework, which sits on top of the CLR). In order to make use of these services, .NET code has to behave in a predictable fashion, and the CLR has to understand the .NET code. For example, to do runtime checking of array boundaries, all .NET arrays have identical layout. NET code can also be restricted by type safety requirements.

As we will discuss in the next chapter, the restrictions on .NET code are defined in the Common Type System (CTS) and its implementation in the Microsoft Intermediate Language (MSIL or IL). The CTS defines the types and operations that are allowed in code running under the CLR. For example, it is the CTS that restricts types to using single implementation inheritance. MSIL code is compiled into the native code of the platform.

.NET applications contain metadata, or descriptions of the code and data in the application. Metadata allows the CLR, for example, to automatically serialize data into a storage.

Code that can use the services of the CLR is called managed code.

Managed data is allocated and deallocated automatically. This automatic deallocation is called garbage collection . Garbage collection reduces memory leaks and similar problems.

Microsoft and ECMA

Microsoft has submitted specifications for the C# programming language and core parts of the .NET Framework to the European Computer Manufacturers Association (ECMA) for standardization. The ECMA specification defines the platform-independent Common Language Infrastructure (CLI). The CLR can be thought of as the CLI plus the Base Class Libraries (BCL). The BCL has support for the fundamental types of the CTS, such as file I/O, strings, and formatting. Since the CLR is platform-dependent, it makes use of the process and memory management models of the underlying operating system.

The ECMA specification defines the Common Intermediate Language (CIL). The ECMA specification allows for CIL to be compiled into native code or interpreted.

Verifiable Code

Managed code can be checked for type safety. Type-safe code cannot be subverted. For example, a buffer overwrite cannot corrupt other data structures or programs. You can only enter and leave methods at fixed points; you cannot calculate a memory address and start executing code at an arbitrary point. Security policy can be applied to type-safe code. For example, access to certain files or user interface features can be allowed or denied . You can prevent the execution of code from unknown sources.

Not all code that makes use of the facilities of the CLR is necessarily type safe. The classical example is managed C++. Managed C++ code can make use of CLR facilities such as garbage collection, but cannot be guaranteed to be type safe.

Multiple Language Development

As its name suggests, the CLR supports many programming languages. A "managed code" compiler must be implemented for each language. Microsoft itself has implemented compilers for managed C++, Visual Basic .NET, Jscript, and the new language C#. Well over a dozen other languages are being implemented by third parties, among them COBOL by Fujitsu and Perl by ActiveState. To accommodate the use or creation of .NET data types, however, new syntax often has to be introduced. Nonetheless, programmers do not need to be retrained in a completely new language in order to gain the benefits of .NET. Legacy code can be accessed through the interoperability mechanism.

Development Tools

A practical key to success in software development is a set of effective tools. Microsoft has long provided great tools, including Visual C++ and Visual Basic. With .NET they have combined their development tools into a single integrated environment called Visual Studio .NET.

  • VS.NET provides a very high degree of functionality for creating applications in all the languages supported by .NET.

  • You can do multiple language programming, debugging, and so on.

  • VS.NET has many kinds of designers for forms, databases, and other software elements.

As with the languages themselves , third parties can provide extensions to Visual Studio .NET, creating a seamless development environment for their language that interoperates with the other .NET language. The tool set includes extensive support for building Web applications and Web services. There is also great support for database application development.

The Importance of Tools

The importance of tools should not be underestimated. Ada, a very powerful programming language, never achieved widespread use. While part of the initial vision was to create a standard Ada Programming Support Environment (APSE), most of the attention was paid to specifying the language, not the APSE. Consequently, Ada never did develop any development environment comparable to that of Visual Studio, Smalltalk, or some of the Java IDEs .

Visual Studio .NET will be highly tuned for productivity, and much training will be available. Microsoft has far more resources to throw at Visual Studio .NET than do smaller vendors in the highly fragmented tools market. Java is highly standardized in the language and API, but tools, which are required for productivity, are not standard.


Team-Fly    
Top