Wednesday, April 1, 2015

Important Features of .Net

Important Features of .Net

Introduction

Introduction on .NET Framework

.NET is the framework for which we develop applications.  It sits in between our application programs and operating system. Applications developed for .NET run inside .NET and are controlled by .NET. It supports both Windows and web applications. 

.NET provides an object oriented environment. It ensures safe execution of the code by performing required runtime validations. For example, it is never possible to access an element of an array outside the boundary. Similarly, it is not possible to a program to write into another programs area, etc. The runtime validations performed by .NET makes the entire environment robust.

Components of .NET
.NET framework has two main components.  They are:
  1. Common Language Runtime
  2. .NET class library
Common Language Runtime

The Common Language Runtime (CLR) is the environment where all programs in .NET are run. It provides various services, like memory management and thread management. Programs that run in the CLR need not manage memory, as it is completely taken care of by the CLR. For example, when a program needs a block of memory, CLR provides the block and releases the block when program is done with the block.

All programs targeted to .NET are converted to MSIL (Microsoft Intermediate Language). MSIL is the output of language compilers in .NET . MSIL is then converted to native code by JIT (Just-in Time Compiler) of the CLR and then native code is run by CLR.

As every program is ultimately converted to MSIL in .NET, the choice of language is pure personal.  A program written in VB.NET and a program written in C# are both converted to MSIL.  Then MSIL is converted to native code and run. So, whether you write program in C# or VB.NET at the end it is MSIL all that you get. 

It is believed VB6.0 programmers will migrate to VB.NET and C++ and Java programmers switching to .NET will prefer to use C# as it more resembles those languages.

For Java programmers, MSIL in .NET is same as Bytecode in concept.  CLR is same as JVM (Java virtual machine). So the inevitable question is “Is .NET platform independent like Java?” The answer is technically YES. A program written for .NET can run on any platform as long as .NET is made available on that platform. As of now, .NET runs only on Windows. So, .NET is technically platform independent but not reall, at least not now.  Efforts are on to make .NET run on Linux. The project is called as Mono and is currently being developed. Though some people doubt the seriousness of Microsoft, I will not be surprised if Microsoft comes out with .NET on Linux in future.  If that happens, all your VB.NET, and C# programs can run as they are on both Windows and Linux.  Who knows what more in store? 

The code that is run under CLR is called Managed code. 

.NET Class Library
.NET comes with thousands of classes to perform all important and not-so-important operations.  Its library is completely object oriented, providing around 5000 classes to perform just about everything.

The following are the main areas that are covered by Class library.
  1. Data Structures
  2. IO management
  3. Windows and Web Controls
  4. Database access
  5. Multithreading
  6. Remoting
  7. Reflections
The above list is comprehensive and only to provide you an instant idea regarding how comprehensive the library is.

The most fascinating part of .NET is the class library; it's common to all language of .NET. That means the way you access files in VB.NET will be exactly same in C#, and in fact all other languages of .NET.  You learn library only for once, but use it in every language. 

Also the library is common for all types of applications. The following are different types of applications that can make use of .NET class library.
  1. Console applications.
  2. Windows GUI applications.
  3. ASP.NET applications – web applications.
  4. XML Web services.
  5. Windows services.
So, you can leverage your knowledge of library irrespective of language and type of application you are developing.  I think it is the best thing that can happen to programmers. Imagine moving from COBOL to C and then from C to VB. You learned how to perform common operations three times because those three languages didn’t have any function in common
Features of .NET
The following are major features of .NET.  We will use these features throughout out journey.  Here is just a brief introduction to all key features of .NET.
Assemblies

An assembly is either a .DLL or .EXE that forms a part of an application. It contains MSIL code that is executed by CLR. The following are other important points related to an assembly:
  1. It is the unit on which permissions are granted.
  2. Every assembly contains a version
  3. Assemblies contain interfaces and classes. They may also contain other resources such as bitmaps, file etc.
  4. Every assembly contains assembly metadata, which contains information about assembly. CLR uses this information at the time of executing assembly.
  5. Assemblies may be either private, which are used only by the application to which they belong or Global assemblies, which are used by any application in the system.
  6. Two assemblies of the same name but with different versions can run side-by-side allowing applications that depend on a specific version to use assembly of that version.
The four parts of an assembly are:

Assembly Manifest - Contains name, version, culture, and information about referenced assemblies.

Type metadata - Contains information about types defined in the assembly.

MSIL – MSIL code.

Resources - Files such as BMP or JPG file or any other files required by application.
Note: Assembly that contains only resources is called as Satellite assembly. 

Common Type System

Common Type System (CTS) specifies the rules related to data types that languages must follow. As programs written in all languages are ultimately converted to MSIL, data types in all languages must be convertible to certain standard data types.

CTS is a part of cross-language integration, which allows classes written in one language to be used and extended by another language. 

Cross-language Interoperability

.NET provides support for language interoperability. However, it doesn’t mean every program written in a language can be used by another language. To enable a program to be used with other languages, it must be created by following a set of rules called Cross Language Specifications (CLS).

Cross-language inheritance is the ability to create a class in C# from a class created in 

 VB.NET.

When an exception is raised by a program written in C#, the exception can be handled by VB.NET. This kind of exception handling is called cross-language exception handling.

.NET has brought a set of new features which are to be understood by every programmer developing applications for Windows. There is no way any Windows programmer can ignore .NET, unless he is desperate to be outdated. Microsoft will provide .NET as part of its operating systems in future releases. It is the platform for programmers. It is not new OS from Microsoft or a new language. It is the environment for which you develop applications. It is rich in terms of features. Believe me, programming using VB.NET is fun and it is more productive than VB 6.0.
The following are different types of applications that can be developed in .NET:

Windows applications – typical Client/Server applications.
Web applications
– Web sites and Intranet applications.
Web services
– Programs that are accessible from anywhere using universal protocols like HTTP and SOAP.
Console Applications
– Simple console based applications without any GUI. Run from command prompt. Best suited to learn fundamentals and also for applications such as server sockets.
Mobile Applications
– Contain web pages that run in mobile devices such as PDAs (Personal Digital Assistant) and Cell phones.

Though .NET supports many languages, I believe only two languages will dominate programming in .NET: VB.NET and C#. 

VB.NET is the successor to VB 6.0, but language wise, it was modified substantially as it became complete OOPL – no more "object-based language." 

C# resembles Java. Though Microsoft claims, C# resembles C++, but let's face it: it resembles Java more than C++.
Visual Studio.NET
VS.NET is the application development tool to develop applications for .NET. It supports development of all types of applications that .NET supports. It also provides support for VB.NET ,C#, Visual C++.Net and Visual J# languages. VS.NET is a single environment that provides all tools required to develop and debug applications.
The following are key features of Visual Studio.NET.

Languages supported - VS.NET supports application development using the language of your choice. It also allows mixed language solutions.

IntelliSence - IntelliSense provides options that make programming in VS.NET easier than ever before. 

The following are important functions of intellisense.
  1. Allows you to see the syntax of the method that you are calling
  2. Completes the variable, command, or function name once you have entered enough characters to disambiguate the term.
  3. Displays the list of valid members for the class, structure or namespace you type so that you can select one form the list. It places the selected member in your code.
  4. Automatically brace matching allows whether ending brace is given after opening brace is given.
If VS.NET finds any error in the code, it underlines the code with red line to remind user about the error.

 

No comments:

Post a Comment