Showing posts with label .net framework. Show all posts
Showing posts with label .net framework. Show all posts

Thursday, 4 September 2014

Garbage Collector (GC)

Garbage Collector (GC) –
Here is how GC works and its advantages:
1.De-allocation or freeing of resources consumed by created instances.
üIn C#, the de-allocation or freeing of resources consumed by created instances occurs automatically on a system-determined schedule by an intelligent mechanism known as garbage collection.
üThe Garbage Collector (GC) is like a sweeper fish in an aquarium.
üIf you drop more food than the other fish can eat, the sweeper fish consumes the remaining food without leaving anything behind. 
üThe convenience and usefulness of GC has been known since Java.
2.Runs simultaneously with application
üThe GC in C# improves on the concept because it does not reduce the system's performance until really needed.
üIt is smarter than other garbage collectors currently on the market.
üYou can overcome the disadvantages of CG's nondeterministic behavior by using destructors and finalizers.
üYou can allocate member instances with constructors . Let's explore some important aspects of garbage collecting in .NET. 
3.Do not need to code destructors or finalizers
üIn C#, most of the time, you do not need to code destructors or finalizers because you can trust GC to clean up for you with destructors.
üThese functions are called implicitly by the C# runtime system's garbage collector. 

4.If explicit deterministic deallocation of objects is important in class and inheritance hierarchy.

Common Language Specifications (CLS)

Common Language Specifications(CLS):
Lets see what is CLS is :
1.The Common Language Specification (CLS) is a fundamental set of language features supported by the Common Language Runtime (CLR).
1.CLS is nothing but a set of rules defined for the developers that they have to follow while coding.
2.The rules like we have to use “new” keyword while creating the object of any class. Another is if we want to use any inbuilt class from framework we have to include the respective namespace of that class into an applications otherwise we will not get those classes, methods accessible in code.
3.So the developer need to take these rules in account while implementing code.
2.CLS defines the base rules necessary for any language supported  by framework.
3.CLS represents the guidelines to the compiler of a language, which targets the .NET Framework.
1.CLS is a part of the specifications of the .NET Framework. CLS was designed to support language constructs commonly used by developers and to produce verifiable code, which allows all CLS-compliant languages to ensure the type safety of code.
2.CLS is a part of the specifications of the .NET Framework. CLS was designed to support language constructs commonly used by developers and to produce verifiable code, which allows all CLS-compliant languages to ensure the type safety of code.
3.It forms a subset of the functionality of common type system (CTS) and has more rules than defined in CTS
4. CLS and CTS  enables language interoperability in dotnet. Because of CLS and CTS dotnet achieves the Language Interoperability. This means the code written in any language supported by framework can be used in any other language without converting it.
Even though various .NET languages differ in their syntactic rules, their compilers generate the Common Intermediate Language instructions (MSIL code), which are executed by CLR. Thus, CLS acts as a tool for integrating different languages into one umbrella in a seamless manner.

Common Type System (CTS)

Common Type System (CTS)
1.Common Type System (CTS) describes a set of types that can be used in different .NET languages in common 
üCTS consists of all common types of all the languages supported by dotnet framework.
üCTS contains datatyes, keyword, enums, methods of all the languages.
üThat is , the Common Type System (CTS) ensure that objects written in different .Net languages can interact with each other
ü For Communicating between programs written in any .NET supported language, the types have to be compatible on the basic level .
2.These types can be Value Types or Reference Types .
üThe Value Types are passed by values and stored in the stack.
üThe Reference Types are passed by references and stored in the heap.
3.Common Type System (CTS) provides base set of Data Types which is responsible for cross language integration.

4.The Common Language Runtime (CLR) can load and execute the source code written in any .Net language, only if the type is described in the Common Type System (CTS)

Benefits of Common Language Runtime

Benefits of Common Language Runtime 
These are the benefits of the CLR:
üIt improves the performance if the applications.
üIt has ability to use or understand the code written in other languages.
üWe can use any code in any language supported by framework with help of CLR.
üIt supports all object oriented features.
üIt supports threading, exception handling (will see these points in more detail in next modules).
üBecause of Garbage Collector not a single bit of memory wasted.
Use of delegates instead of function pointers for increased type safety and security. For more information about delegates (will see these points in more detail in next modules)

Common Language Runtime

Common Language Runtime:
Lets see what actually CLR is and why it is so important
1.The Common Language Runtime (CLR) is the virtual machine component of MS.NET framework and is responsible for managing the execution of MS.NET programs. It is a engine that runs the dotnet framework. Each and every process of a program which you write in DotNet is managed by CLR.
2.It works as a layer between Operating Systems and the applications written in MS.NET languages. Dotnet framework is platform dependant. It only executes on WINDOWS operating system. This CLR is acts as a layer between OS and our application to execute it.
3.The Common Language Runtime (CLR) 's Just In Time (JIT) compilation converts Intermediate Language (MSIL) to native code on demand at application run time.
üIn CLR there are different compilers for different languages.
üThese compilers converts the program code into MSIL (Mircosoft Intermediate Language) code. This MSIL is special language developed by the Microsoft which is understand by framework.
üNow in CLR there are JTI’s (Just In Time) compilers which converts this MSIL code into native code which is understand by machine and our program executes and we are able to see the output.
4.During the execution of the program ,the Common Language Runtime (CLR) manages memory, Thread execution, Garbage Collection (GC) , Exception Handling, Common Type System (CTS), code safety verifications, and other system services.
üCLR performs code management, code execution, memory management, memory allocation, memory de-allocation etc.
üAll processes from program compilation to execution will be handled by CLR.
üCLR also having one most important block called as Garbage Collector (GC) which runs simultaneously with your application. The task of this is, it frees the memory of unused object in the application. So that developer does not need to explicitly take care of memory management it can be done by CLR implicitly.
5.The Common Language Runtime (CLR) environment is also referred to as a managed environment, because during the execution of a program it also controls the interaction with the Operating System.
üCLR operates with the help of operating system and works as a layer between OS and dotnet framework that’s why dotnet is platform dependent it only works in WINDOWS Operating systems like XP, Windows 7, Server etc.
The code which is compiled by the CLR is called as Managed Code. If we are using any third party code which is called by Unmanaged code because that is not compiled by CLR.





Base Class Library

What is Base Class Library -
  Base class library is a Common Language Infrastructure (CLI) standard library available to all the languages supported by dotnet framework..
More details about base class library –
1.The MS.NET Framework Class Library (FCL) includes a huge collection of reusable classes , interfaces, and value types that expedite and optimize the development process and provide access to system functionality. For example its has windows libraries also so that we can easily access windows features like word, power point etc through dotnet applications.
2.All of these classes are logically grouped in to “Namespaces”.
3.The definition of the Namespace is, it is a logical grouping of related classes. That means a namespace contains related classes and those classes are logically grouped. There are thousands of classes in dotnet and those classes are logically grouped in a Namespace.
4.There are lots of namespaces in dotnet and these namespaces are arranged in hierarchical manner. “System” is a namespace which is at top most hierarchy. Under this System namespace all other namespaces are defined.
5.These namespaces contains classes which are as per the object oriented concepts and one can easily play with those as per their needs.


.NET Framework

Define .NET Framework:
›The .NET Framework is a new computing platform that simplifies application development in the highly distributed environment of the Internet.

The .NET Framework is designed to fulfill the following objectives:
•Firstly it is designed to provide a consistent object-oriented programming environment for object is stored and executed locally or executed remotely.
•Next to provide code-execution environment that minimizes software deployment activity like it provides inbuilt code samples.
•It also provides a code-execution environment that eliminates the performance problems of scripted or interpreted environments for example application performance tools like debugging and tracing.
•Next it makes the developer experience consistent across widely used applications, such as Windows-based applications and Web-based applications.
•Finally to build communication as per industry standards to ensure that the code developed in .NET Framework can integrate with any other code.

Wednesday, 20 August 2014

.NET Framework

The .NET Framework is a new computing platform that simplifies application development in the highly distributed environment of the Internet. The .NET Framework is designed to fulfill the following objectives:
Objectives of NET Framework:
To provide a consistent object-oriented programming environment whether object code is stored and executed locally, executed locally but Internet-distributed, or executed remotely.
To provide a code-execution environment that minimizes software deployment
To provide a code-execution environment that eliminates the performance problems of scripted or interpreted environments.
To make the developer experience consistent across widely varying types of applications, such as Windows-based applications and Web-based applications.
To build all communication on industry standards to ensure that code based on the .NET Framework can integrate with any other code.