Friday, November 30, 2012
Wednesday, November 28, 2012
Compilation basics in .NET
Compiler is a computer program that transforms the source code into a target language which can be executed directly.
Following are few concepts behind compilation
- JIT - Just In Time compiler
- Ahead of time compilation
Compilation in ASP.NET #
Intermediate language (IL)
Also known as MSIL (Microsoft Intermediate Language). All .NET source code is compiled to IL which is then converted to machine code.
Intermediate language (IL)
Also known as MSIL (Microsoft Intermediate Language). All .NET source code is compiled to IL which is then converted to machine code.
Resources
Thursday, November 22, 2012
C# Tips and Tricks
For a seasoned software developer, knowing just the basics and theories of programming is going to do any good. They must also be aware of little tricks which makes development easy and fun. In this article I'll share few tips which we can use to improve our coding. (I'll be focusing on C# here.)
Null-Coalescing operator
Rather than explaining its better to show it using an example.You can also chain these
Stackoverflow :What do ?? means in C#
yield method
using yield you can return each element one at a time for a list. (Lazy) (MSDN, SO, CodeProject easy to understand)
IEnumerable<int> Integers()
{
List<int> list = new List<int> { 1, 2, 3 };
foreach (var item in list)
{
yield return item;
}
}
Extension methods
Allows you to add methods to existing types without creating new derived type. These are special kind of static method. The most common extension methods are LINQ standard query operators that add query functionality to existing System.Collections.IEnumberable and System.Collections.Generic.IEnumerable<T> types.
You can use extension methods to extend a class or interface, but not to override them. An extension method with same name and signature as an interface or class method will never be called. At compile time extension methods always have low priority than instance methods.
Defining extension method on Object will make the method available to all objects. This won't have any performance cost. Basically it won't get attached to each object. Rather you can call the extension method from any object. (See SO article)
Defining extension method on Object will make the method available to all objects. This won't have any performance cost. Basically it won't get attached to each object. Rather you can call the extension method from any object. (See SO article)
I'll update this list continually. Hope this list will be useful for you.
P.S: Find out more Hidden features of C# (SO)
image credit : blastmobilefitness
Saturday, November 10, 2012
JavaScript prototyping
In JavaScript, every object has a prototype property. Prototype property is also an object. All JavaScript objects inherit there properties and methods from there prototypes.
Using prototypes makes object creation faster.
When an inherited function is executed, the value of
this
points to the inheriting object, not to the prototype object where the function is an own property.
Object.create : Create a new object with specified prototype object and properties
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain
hasOwnProperty is an own property of Object.prototype. When we create an object, it inherits hasOwnProperty from Object.prototype.
Arrays inherits from Array.prototype (it has methods like forEach, call)
// f ---> Function.prototype ---> Object.prototype ---> null
The lookup time for properties that are high up on the prototype
chain can have a negative impact on performance, and this may be
significant in code where performance is critical. Additionally, trying
to access nonexistent properties will always traverse the full prototype
chain.
Also, when iterating over the properties of an object, every property that is on the prototype chain will be enumerated.
Saturday, November 3, 2012
Introduction to IIS
IIS is a web server software developed by Microsoft. IIS provides a request processing architecture. IIS includes,
- A customizable web server engine by adding or removing modules
- Windows Process Activation Service (WAS) which enables sites to use protocols other than HTTP and HTTPS
- Integrated request processing pipelines from IIS and ASP.NET
Components in IIS
Performs important functions in IIS. Some components of IIS are protocol listeners (HTTP.sys) and services such as World Wide Web publishing service (WWW Service) Windows Process Activation Service (WAS).
Protocol listeners
These receive protocol specific requests, send them to IIS for processing and returns responses. One example is HTTP.sys HTTP listener which listens to both HTTP and HTTPS. You can also use protocol listeners for WCF etc.
Following video will show you how to host WCF services in IIS.
Managed code modules that implements IHttpModule has access to all events in request pipeline. In IIS6 and IIS7 classic mode, ASP.NET request pipeline was separate from Web server pipeline. But in IIS 7, it is a unified pipeline which handles the requests.
In ASP.NET application life cycle, firstly
Automatic Deployment using Microsoft Web Deploy
http://weblogs.asp.net/scottgu/automating-deployment-with-microsoft-web-deploy
These receive protocol specific requests, send them to IIS for processing and returns responses. One example is HTTP.sys HTTP listener which listens to both HTTP and HTTPS. You can also use protocol listeners for WCF etc.
Windows Process Activation Service (WAS)
By default IIS only supports HTTP protocol. You can use WAS component to enable other protocols. Also see http://www.iis.net/learn/manage/provisioning-and-managing-iis/features-of-the-windows-process-activation-service-wasFollowing video will show you how to host WCF services in IIS.
Pipelines
In IIS 7 there are 2 request processing pipelines. Classic and Integrated pipeline. Classic was the only existed in IIS 6 and below. With Integrated pipeline it is tightly integrated as ASP.NET request pipeline. (SO)Managed code modules that implements IHttpModule has access to all events in request pipeline. In IIS6 and IIS7 classic mode, ASP.NET request pipeline was separate from Web server pipeline. But in IIS 7, it is a unified pipeline which handles the requests.
In ASP.NET application life cycle, firstly
- The ApplicationManager and HostingEnvironment objects gets created
- Application objects such as HttpContext, HttpRequest gets created
- HttpApplication object is created (if one doesn't exist to use) and assigned to the request
Automatic Deployment using Microsoft Web Deploy
http://weblogs.asp.net/scottgu/automating-deployment-with-microsoft-web-deploy
Resources
http://www.c-sharpcorner.com/uploadfile/suresh_g_v2002/introduction-on-iis-7/
https://msdn.microsoft.com/en-us/library/bb470252(v=vs.140).aspx
https://msdn.microsoft.com/en-us/library/bb470252(v=vs.140).aspx
Subscribe to:
Posts (Atom)
Powered by Blogger.
Software Architect at Surge Global/ Certified Scrum Master
Experienced in Product Design, Software Engineering, Team management and Practicing Agile methodologies.