Thursday, November 11, 2010

Dissecting .NET Framework

I used to find WPF, WCF and such terms quite intimidating (I guess I still am). Just knowing what they are and where they are used gave me a sense of awareness of latest versions of framework. Lets see where they all fit in.

Common Language Runtime(CLR): Applications written in C#, VB.NET and other .NET languages are executed by CLR.  A program written in any of the above languages is first complied into MicroSoft Intermediate Language (MSIL or IL). Using CLR activated Just In Time(JIT) compiler, IL is then complied to an executable file. The process is illustrated below.
CLR provides support for memory management, security and exception handling.

Base Class Library: .NET framework provides a set of libraries that can be used by all the languages. These support Common Language Specification(CLS) and Common Type System(CTS). 
  • CLS describes a set of features that different languages have in common.
  • CTS defines rules concerning data types.
Following CLS and CTS helps us build cross-language applications.


WinForms: WinForms or window forms are used to develop graphical interfaces for windows environment. WinForms consists of forms which contain controls like button, textbox, menus, etc. 

ASP.NET: ASP.NET is used to develop websites or web applications using any .NET language.

ADO.NET: .NET version of ActiveX Data Objects(ADO) technology, it is used to access data and data services. It is usually used to access data in relational databases like SQL server, Oracle, etc.

.NET 3.0 version added WPF, WCF, WF and Card Space.

Windows Presentation Foundation(WPF): WPF allows us to develop rich graphical interfaces with 2D, 3D graphics, animation, audio and video. WPF introduces XAML(pronounced zammel). XAML, eXtensible Application Markup Language, is used to define and link various user interface controls. Through XAML, WPF provides a clear separation of designing user interface and business logic.

Windows Communication Foundation(WCF): Using WCF we can develop distributed applications that communicate within an in-house application or over the web.

Windows Workflow Foundation(WF): Using WF we can represent business process. It provides a designer so that developers and non-developers can define a custom workflow. These workflows can be integrated with code and can be reused in multiple applications.


Card Space: Card space was introduced into .NET for identity management. It provides a digital ID for the users which can be used across multiple applications.


LINQ(Language INtegrated Query): LINQ provides a consistent way of accessing and modifying various forms of data like relational data, XML data and even collections of objects like arrays.

Parallel LINQ and Task Parallel Library(TPL): These two components were included in .NET 4.0 framework for parallel computing. PLINQ can be used to speed up LINQ queries. TPL can be used to write multi-threaded and parallel code.

I suggest the following reading material to explore more about the .NET framework:
  • .NET Framework Essentials by Thuan L.Than Hoang Lam. This provides detailed explanation of inner workings of .NET framework and various components in it. This book included .NET 2.0 version. 
  • Wikipedia is always a great resource. Read about the framework here. You'll see that I have used the framework stack picture in this post from Wikipedia.


Tuesday, November 9, 2010

Object Oriented Programming

The very first step in learning dot net is understanding the concept of Object Oriented Programming(OOP). Whenever I come across a new concept, I always question "why?? ". I realized that I appreciate them more when I understand the problems it simplifies/solves. So lets ask why??

Why??
Before OOP languages were introduced, programs were written in "structured" languages like C and Pascal. Structured languages are not modular so they are pretty long and all code written in one file. 
  • To debug or change such a file can be frustrating. So the problem number one is maintainability
  • If we want to use a part of code in program 1 in program 2, we need to rewrite it in program 2. This results in redundancy and problem number two: reusability is not supported. 
  •  If we want to add a new functionality to an existing program, we might have to make changes in a number of places in the existing code making it a messy job. Problem number three: extensibility.
OOP addresses these problems. It makes programming modular and supports features like  Encapsulation, Polymorphism, Inheritance  and Abstraction.

Lets briefly talk about these features. At this point we will try to understand what these mean. We will know how these are supported by .NET languages when we delve into the features of C#.

Encapsulation: It is a programming mechanism that binds code and the data it manipulates together. This makes it easy to make changes to the part of code without effecting the whole program. It also helps us to provide controlled access to the data and code to outside programs. Basic unit of encapsulation in C# is class. We will discuss class in future post. 


Polymorphism: It is a quality that allows a method or action to do different things in based on the context it is used in. For example, + can be used for basic addition of two numbers or for concatenating two strings. 

Inheritance: This features allows for hierarchical classification. For example, 
Abstraction: Abstraction is hiding the details of implementation i.e., the user knows what an application does but not how it does. For example: we can use google to search for websites on dot net. We don't have to understand the search algorithm used by google to use it. This simplifies our job by allowing us to accomplish our task without any need to understand the internal details.

I hope the above post has helped you to give a basic idea of OOP. I strongly encourage you to read further about the above concepts.