ASP.net 2.0 fundamental part 2

The Common Type System (CTS)

A number of types are supported by the CLR and are described by the CTS. Both value types are supported—primitive data types and reference types. The primitive data types include Byte, Int16, Double and Boolean while Reference types include arrays, classes and object and string types. Reference types are types that store a reference to the location of their values. The value is stored as part of a defined class and is referenced through a class member on the instance of a class.

User defined value types and enumerations are derived from the value types mentioned above.

Language compilers implement types using their own terminology.

The process of converting a value type to a reference type and vice versa is called boxing and unboxing. The implicit conversion of a value type to a reference type is referred to as boxing. The explicit conversion of an object type into a specific value type is referred to as unboxing.

The Common Language Infrastructure (CLI)

A subset of the .NET framework is the CLI. The CLI includes the functionality of the Common Language Runtime and specifications for the Common Type System, metadata and Intermediate language. A subset of the Framework Class Library incorporates the base class library, a Network library, a Reflection library, an XML library and Floating point and Extended Array Library. The shared source implementation of the CLI is available for both the FreeBSD and Windows operating Systems.

The Common Language Specification (CLS)

The CLR supports the CLS which is a subset of it. Additionally the CLR supports a set of rules that language and compiler designers follow. It provides robust interoperability between the .NET languages and the ability to inherit classes written in one language in any other .NET language. Cross language debugging also becomes a possibility in this scenario. It must be noted that the CLS rules apply only to publicly exposed features of a class.

Classes

A blueprint of an object is called a class. All definitions of haw a particular object will be instantiated at runtime, its properties and methods and storage structures are defined in the class. Classes are used by developers for creating instances of the class at runtime using the keyword “New”.

Namespaces

This is the key part of the .NET Framework. It provides scope for both preinstalled framework classes and custom developed classes. Vb.NET uses the “Imports” keyword to enable the use of member names from the namespace declared. C# uses the “using” keyword. In both cases the System Namespace is also imported so that the Console window can be written without explicitly referring to the System.Console.

Assemblies

Assemblies are also known as managed DLLs. They are the fundamental unit of deployment for the .NET platform. The .NET framework itself is made of a number of assemblies. An assembly contains the Intermediate language generated by the language compiler, an assembly manifest, type metadata and resources. They can be private or public. They are self describing and hence different versions of the same assembly can be run simultaneously.

Intermediate language (IL)

This is a processor independent representation of executable code. It is similar to assembly code and specific to the CLR. It is generated by the language compilers that target the CLR. At runtime, the CLR just-in-time compiles the IL to native code for execution. The tool ngen.exe which is part of the .NET framework pre-compiles assemblies to native code at install time and caches the precompiled code to the disk.

Managed execution

This refers to code whose execution is managed by the CLR. It includes memory management, access security, cross-language integration for debugging and exception handling etc. These assemblies are required for the creation of metadata on the code and the assemblies so that the CLR can manage the execution of the code.

Manifests, Metadata and Attributes

 

Metadata and manifests are key aspects of managed code execution. The portions of an assembly that contains descriptive information about the types contained in the assembly, the members exposed by the assembly and the resources required by the assembly are called manifests. Metadata is contained within the manifest. This metadata describes the assembly and some of it is generated by the language compiler at compile time. Other metadata may be added by the developer at design time. Declarations added to the code to describe or modify some aspect of the code’s behavior at runtime are known as Attributes. These are stored with an assembly as metadata. They serve many useful purposes in the .NET Framework

Object Orientation in the .NET Framework

Objects are the core of Object oriented programming. Classes are blueprints of objects and contain all the methods and properties of the object. Encapsulation, inheritance and polymorphism are attributes of an object. Encapsulation means the ability of an object to hide its internal data from outside view and allow access to only that data that is publicly available. Inheritance is the ability to derive one class from another.

New classes can be created from existing classes and the new class inherits all the properties and methods of the old class and new methods and events can be added to the new class. This is useful when users want to create specialized classes. Polymorphism is the ability of multiple classes derived from the same base class to expose methods in the same name, regardless of the underlying process of implementation.

Rapid Development and Reuse

The object orientation of the .NET Framework provides for faster development and deployment of applications. The use of classes, derived classes to provide common functionality has gone a long way in reducing development time. Object orientation is also the crucial element in the development of the code-behind concept and the latest code beside concept. Code behind allows developers to separate executable code form the HTML markup of the user interface. The executable code is placed in a module called code behind file. This file contains a class that inherits from the Page class. The ASP.NET page inherits from code-behind class and the two are compiled at runtime into a single executable assembly.

The BETA 2.0 has added a number of functionalities to aid in rapid development. We will be looking at these changes in the next unit “What’s new in BETA 2.0”

Choosing a Language

An important aspect of the .NET framework is that developers can continue to use the language of their choice in application development. The cross language interoperability in .NET makes it possible to create an application in any .NET supported language as all languages will work together smoothly using the CLR which translates all languages into Intermediary language.
 

2 Responses

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: