Bhai Ki Link's

A Very Basic Concept


Bhai Ki Quick List

Back to Home

Dot NET Introduction

What is this .NET all about ?

The simple answer is 'it is the technology from Microsoft, on which all other Microsoft technologies will be depending on in future.'.

It is a major technology change. Just like the computer world moved from DOS to Windows, now they are moving to .NET. But don't be surprised if you find anyone saying that "I do not like .NET and I would stick with the good old COM and C++". There are still lot of people who like to use the bullock-cart instead of the latest Honda car.

.NET technology was introduced by Microsoft, to catch the market from the SUN's Java. Few years back, Microsoft had only VC++ and VB to compete with Java, but Java was catching the market very fast. With the world depending more and more on the Internet/Web and java related tools becoming the best choice for the web applications, Microsoft seemed to be loosing the battle. Thousands of programmers moved to java from VC++ and VB. This was alarming for Microsoft and many of the Microsoft fan's kept on asking "is Microsoft sleeping?". And Microsoft had the answer. One fine morning, they announced : "We are not sleeping. We have the answer for you.". And that answer was .NET.

But Microsoft has a wonderful history of starting late but catching up quickly. This is true in case of .NET too. Microsoft put their best men at work for a secret project called Next Generation Windows Services (NGWS)., under the direct supervision of Mr. Bill Gates. The outcome of the project is what we now know as .NET. Even though .NET has borrowed most of it's ideas from Sun's J2EE, it has really outperformed their competitors.

Microsoft's VC++ was a powerful tool. But it was too complex. It has too many datatypes, and developers had to learn many libraries including WIndows SDK, MFC, ATL, COM etc. There were many datatype compatibility issues while exchanging data between different layers. Visual Basic was too easy, and many serious programmers hated it just for that reason. Even though Visual basic was very easy to use, it was not very flexible to develop serious applications. SUN's Java became a very good choice for these reasons. It had the flixibility and power of C++ and at the same time easy enough to catch the attention of VB programmers.

Microsoft recognised these factors and they introducd the .NET considering all these factors. All unwanted complexities are eliminated and a pure object oriented programming model was introduced. This makes programmer's life very easy.

.NET framework comes with a single class library. And thats all programmers need to learn!! Whether they write the code in C# or VB.NET or J#, it doesn't matter, you just use the .NET class library. There is no classes specific to any language. There is nothing more you can do in a language, which you can't do in any other .NET language. You can write code in C# or VB.NET with the same number of lines of code, same performance and same efficiency, because eveyone uses same .NET class library.

What is .NET ?
·  It is a platform neutral framework.
·  Is a layer between the operating system and the programming language.
·  It supports many programming languages, including VB.NET, C# etc.
·  .NET provides a common set of class libraries, which can be accessed from any .NET based programming language. There will not be separate set of classes and libraries for each language. If you know any one .NET language, you can write code in any .NET language!!
·  In future versions of Windows, .NET will be freely distributed as part of operating system and users will never have to install .NET separately. <![if !supportLineBreakNewLine]>
<![endif]>
What is Not ?
·  .NET is not an operating system.
·  .NET is not a programming language.

".NET is a framework"

Are you confused by this definition? Well, that is OK. It is really confusing!

We cannot define .NET as a 'single thing'. It is a new, easy, and extensive programming platform. It is not a programming language, but it supports several programming languages. By default .NET comes with few programming languages including C# (C Sharp), VB.NET, J# and managed C++. .NET is a common platform for all the supported languages. It gives a common class library, which can be called from any of the supported languages. So, developers need not learn many libraries when they switch to a different language. Only the syntax is different for each language.

When you write code in any language and compile, it will be converted to an 'Intermediate Language' (Microsoft Intermediate Language - MSIL). So, your compiled executable contains the IL and not really executable machine language. When the .NET application runs, the .NET framework in the target computer take care of the execution. (To run a .NET application, the target computer should have .NET framework installed.) The .NET framework converts the calls to .NET class libraries to the corresponding APIs of the Operating system.

Whether you write code in C# or VB.NET, you are calling methods in the same .NET class libraries. The same .NET framework executes the C# and VB.NET applications. So, there won't be any performance difference based on the language you write code.

What is Visual Studio.NET ?

Many people always get confused with Visual Studio .NET (VS.NET) and .NET technology. VS.NET is just an editor, provided by Microsoft to help developers write .NET programs easily. VS.NET editor automatically generates lot of code, allows developers to drag and drop controls to a form, provide short cuts to compile and build the application etc.

VS.NET is not a required thing to do .NET programming. You can simply use a notepad or any other simple editor to write your .NET code!!! And you can compile your .NET programs from the command prompt.

Well, what I said is true theoretically.. but if you decide to use notepad for .NET programming, by the time you develop few sample applications, Microsoft would have introduced some other new technology and .NET would be outdated. You may not want that. So, let us go by VS.NET, just like every other .NET guys.


.NET supported languages

Currently .NET supports the following languages:
·  C#
·  VB.NET
·  C++
·  J# The above languages are from Microsoft. Many third parties are writing compilers for other languages with .NET support.

Difference between VB and VB.NET

Believe us, there is not much in common between VB and VB.NET other than the name. VB.NET is a totally new programming language. It just retains the syntax of old VB. So, if you are a vb programmer, probably you may like VB.NET than C# just because of the syntax.

In addition to this, VB.NET still support many of the old VB functions just for backward compatibility. But if you are a serious .NET programmer, we strongly suggest never use old VB functions in VB.NET. So, switching from VB to VB.NET is just like learning a new programming language, with very small similarities between them.

C# or VB.NET ? Which one to choose ?

Whether you write code in VB.NET or C#, when you compile, your code will get converted to MSIL (Microsoft Intermediate language). It is this MSIL which you deliver to your customer in the form of a DLL or EXE. The MSIL is executed by the same .NET framework, whether you wrote it originally in C# or VB.NET.

The MSIL generated by C# and VB.NET is almost 99% is the same! Many believe that C# has the power of C++ and VB.NET has the user friendliness of VB. That is not true. Both are equally powerfull and friendly.

VB.NET has backward compatibility with old Visual basic. So, it supports old vb functions. C# is a fresh, clean language. So strongly support using C# instead of VB.NET just for this clean compiler.

Many old VB guys usually like to stick with VB.NET and are kind of scared of C

Is it platform independent ?

Many people ask this question "Java is platform independent, what about .NET ?".

The answer is "Yes" and "No" !
The code you write is platform independent, because whatever you write is getting compiled into MSIL. There is no native code, which depends on your operating system or CPU. But when you execute the MSIL, the .NET framework in the target system will convert the MSIL into native platform code.

So, if you run your .NET exe in a WIndows machine, the .NET framework for Windows will convert it into Windows native code and execute. If you run your .NET application in Unix or Linux, the .NET framework for Unix/Linux will convert your code into Unix/Linux native code and execute. So, your code is purely platform independent and runs anywhere!

But wait, we said it wrong... there is no .NET framework for Unix or Linux available now. Microsoft has written the .NET framework only for Windows. If you or some one else write a .NET framework for other platforms in future, your code will run there too. So, let us wait until someone write .NET framework for Linux before you run your .NET code in Linux.

Is it worth learning .NET ?

Are you sure you have a very good job now and your job is safe for next 10 years? Then, probably you don't need to waste your time to learn this new technology.

If you are not sure about the future of your job, better spend sometime and make sure you have fuel to run for next few years!

How long it will take to learn .NET ?

It all depends on how fast you can learn. If you are familiar with Visual Basic or C++, you can come to speed in .NET within 1-2 months. If you are a new to programming, we estimate 6 months will be a reasonable period to become comfortable with .NET world.

Future of .NET

Microsoft is moving all its technologies to be .NET based or .NET related. The next version of SQL Server even supports writing stored procedures in .NET languages. .NET runtime will be part of all Operating Systems by default.
In short, if you like to work on Microsoft technologies for programming, .NET would be the only choice you will have. 

.NET, Java Killer?
Microsoft had first said J++ is no longer one of the languages in the Visual Studio.NET suite of many languages. Microsot's Java User Migration Path (JUMP) is to the C# (pronounced "see sharp") language.
Microsoft has countered Java's “Write once, Run anywhere” premise, with “Write many languages, Run on one Micosoft platform”.
Microsoft adapted the Java runtime into Microsoft's own Intermediate Language (MSIL) called OptIL, associated compilers: one for each of the "20" existing programming source languages, and a run-time compiler to create machine code executable native to each hardware platform.
The complete solution is not likely to be available -- let alone bullet-proof -- in the short term.
Much like the Java RunTime engine, a Common Language Runtime (CLR) execution engine (EE) "assembles" and "manages" OptIL code and provides services such as memory management, cross language integration, exception handling, code access security, and automatic lifetime control of objects.
Prepare to be Assimilated
.NET applications interoperate using a contract of cooperation.
Microsoft 's replacement for IDL (Interface Definition Language) is to have self-describing objects. The new OptIL compilers supply metadata for the .NET Framework to locate and unwind stack frames, and include information required for debugging and garbage collection, as well as security attributes, marshaling data, extended class and member definitions, version binding, and other information required by the runtime.
.NET applications, components, and controls are built using Microsoft's .NET Framework class library. Existing "unmanaged" COM applications will use a COM callable wrapper (CCW) to access system functionality managed by CLS-compliant library of classes, interfaces, and value types.
ASP.NET vs. Java EJB
ASP.NET is the next generation ASP's proprietary server-side web services programming model which makes use of IIS5.0. New features include the Windows Forms framework<![if !vml]> on this page<![endif]>

OBJECT ORIENTED PROGRAMMING (OOP) – INTRODUCTION2


What is the meaning of term ‘Object Oriented’ and what is the need for it?
Well…! To understand this first tell me what do you do when the battery (cell) of your torch (or any other device) runs out? Probably, you simply replace the battery with a new one. Is it? Now, what do you think, you know everything about the battery and the torch. I mean their architecture, functionality, etc. If, by any chance, you know also then does everybody who replaces the battery know about the details of the battery and the device? Obviously not.
Now think about other things that we come across in our daily lives like Cars, Computers, Telephones or anything. Whenever something breaks down it is probably repaired by the people who themselves do not know much about the internal engineering of the object. For example, a car and a car mechanic; torch and you, etc.
What we have noticed in above paragraphs is that many things in life are easy to use and maintain because to use (or repair) them we do not need to know about their internal details. I mean we don’t need to understand the engineering of car to drive it…
What we achieve by this phenomenon is revolutionary. Do you agree?
Now what is this phenomenon basically? See, if we think for while, we’ll come to know about two activities done by this phenomenon:
      - Hiding the complexity of a system
      - Providing a simple interface for the functionality of the system
For example, in a torch an interface is provided for putting the battery and same is the case with battery which has interface which we can connect to the torch. This way we easily link the two systems.
This phenomenon is named ABSTRACTION.
Because of this abstraction the life becomes easy or rather possible. If abstraction were not there, we would have to learn the chemistry of bread to eat it. The equation of water to drink… At the root of all, we would have to learn about atoms, electrons, etc. before using anything… Do you think we could survive in such a condition?
Because of this Abstraction we are where we are now… And because of this abstraction only, we are able to make progress, grow…
I hope you do agree with me? Is it? If not, please discuss… so that we can come to a common conclusion…
... Abstraction and Programming ...
The concept of Abstraction holds true for programming also. See, what does Abstraction mean? It means hiding the complexity of a system and providing a simple interface for it. If can be able to achieve Abstraction in programming, we can make the same progress as real life in programming also. This can open a window to the infinite possibilities. We will just make many systems and hide their complexities so that they can easily be used anywhere by any one and this will give the scope of doing virtually anything…
The concept of abstraction is the basic idea behind the Object Oriented Programming Paradigm. And because of this reason, this programming model is most powerful and most used model in the world of programming. This makes programming very powerful and yet very easy. And so makes our lives, as a programmer, very easy.
Basically, OOP suggests that a system must be made from simpler, independent units which are capable of handling information and functionality related to them independently. Such units are called Objects. The whole OOP revolves around such objects, hence the name ‘Object Oriented’.
In OOP model, we create and use ‘Objects’ to make our code much cleaner, efficient, robust, easy to manage and maintain, and debug.
Now, I hope, you understand the meaning of OOP and the need for it?
... Classes and Objects ...
You are already familiar with the concept of an Object. An object, as we have already seen, is a piece of code which is capable of handling information and functionality related to it independently. We can visualize objects as small components of a bigger system, which can be grouped together to develop the system. For example, Computer is a system and the Hard Disk, RAM, Motherboard are different objects used in a computer system. Often, the objects represent some entity which is able to exist independently.
If we want to use some object in our program, we only need to know what does this object do and not how it does it….Abstraction again! To use it, we will have to load the object in memory so that it can use the CPU and other resources or simply run! Now, loading an object into memory is called Instantiation, in other words, whenever we load an object we can say we have created an instance of it.
Technically, an object is called an object when it is in an instantiated state or loaded. This is so because then only we can actually use it… But there must be some definition for this object, which describes the functionality of the object. This definition is called the Class. Please note that a class is not an object. It is just a set of instructions telling how an object should work.
To understand this let us take an example. All of you must be familiar with the house map. It contains the details of a how to make a house, where to put windows, where to keep the doors, and how many rooms should be there, of what sizes, etc. Is that ‘map’ the house itself? No. A map is just the instruction set and what we create from it is a house, which is a physical/actual thing made up of cement and concrete which can be used to live in. The same relation exists between a class and an object.
Map \-----\ House
Class \-----\ Object


  • A map is instruction set for the house and similarly class is an instruction set for the object.
  • House is the actual thing we are bothered about and so is the object.
  • Many houses can be created from a map and similarly many objects can be created or instantiated from a class.
  • House occupies some space actually and not the map. Similarly, an Object gets loaded and uses the memory not the class. A class is just a set of instructions which specify how an object should look like and what should it do.
I hope now you have a clear about the class and the objects. An object is a programming unit and class is definition of the object. If still not clear, please discuss.
Now, let’s see some of the terms associated with the Object Oriented Programming Paradigm.
... Encapsulation ...
This is nothing but what we have already seen. This concept simply suggests that the code, that is, the data and the functionality must be encapsulated in a ‘black box’. Or simply we can say that the actual code must be hidden from the users of the code. Practically this is what happens when we use Objects. We don’t actually see the code behind an object, we can just use it. This concept is also called ‘Data hiding’.
... Inheritance ...
To understand the meaning of Inheritance in programming context, let’s see an example. Let us consider that there is an Animal class. It has all the features of a general animal. When I say general animal, I mean not any particular animal. The class defines 4 legs, 2 eyes, 1 tail, etc. and also the functionality like Sleeping, Running, etc. Now, if I need to get a lion, I don’t need to write the whole class all over again. I can just inherit my lion class from the animal class. When I do this I will only have to write code for the additional features of Lion like Roaring, etc.
This facility is available in the Object Oriented Programming Paradigm and it greatly supports code reuse. We can inherit from a Superclass and the class which inherits a superclass is called a Subclass in OOP.
... Polymorphism ...
Polymorphism in OOP means ‘same name different functionality’. What this means in action is that we have a same name for different functionalities. For example, we have the same name – ‘Sleep’ which we can use for making each animal sleep, be it tiger or lion or cat or anything. What I mean is that the method for sleeping is different in each of these cases/animals… Cat sleeps differently than a tiger and so on, but we still use ‘Sleep’ to make all animals sleep. This means that we have different functionalities but having the same name that is Sleep. This is Polymorphism (many + forms).
There are two terms generally used in this context:

  • Overloading
  • Overriding
Overloading
Whenever we introduce/write a new functionality with the same name as an existing functionality but changing the signature, we are implementing Overloading. In overloading we can differentiate between the two functionalities by their signatures. And the call made to that functionality depends on the context. This way both the functionalities can co-exist.
Overriding
Whenever we write a new functionality with the name and signature both same, the existing functionality gets overridden by the new functionality and hence can’t be use. When a call to the functionality is made, only the new functionality is called. This is called Overriding.
This was just an introduction to the concept of OOP and the various terms used in it. But the real fun is in using these concepts…

No comments:

Post a Comment