Showing posts with label internals. Show all posts
Showing posts with label internals. Show all posts

Sunday, November 9, 2014

.NET Book : Visual Studio 2013 Expert Development Cookbook

Friends, It gives me immense pleasure to tell you that my new book "Visual Studio 2013 and .NET 4.5 Expert Development Cookbook" has been released few days back. It is the continuation to my previous book "Visual Studio 2012 and .NET 4.5 Expert Development Cookbook" which has released last year. In this post, I will discuss some of the interesting parts of the book and help you understand what exactly you are expected to learn from this book. It has been tremendous effort for last 1 year which let me release this book for you. I hope this book will stand out to your expectation.

After tremendous success on my first book, presenting the next version of the book. Visual Studio 2013 enables you to develop and manage consumer-focused and business-oriented apps. It provides best-in-class tools that propel developers to create new apps or evolve existing ones. In conjunction, .NET 4.5 provides expansive capabilities for developers to work on all forms of apps and services, from client to mobile and from web to cloud, enabling them to focus solely on business logic rather than architecture.

This practical guide teaches you how to work with new changes in technology under the arena of .NET. It provides in-depth analysis and expert advice on various elements of .NET, applying them in code using detailed practical examples, and helping you understand the entire technology in easy, small steps. This book provides solutions to common development problems that you as a developer often face, thereby helping you to adapt the latest technologies as well as get grips on modern app development using .NET 4.5.


Visual Studio 2013 Expert Development Cookbook

What you will learn from this book

  • Get to grips with Visual Studio 2013 IDE and its various components utilizing its tools to debug your code better
  • Get to grips with Visual Studio 2013 IDE and its various components utilizing its tools to debug your code better
  • Understand the Windows Phone 8 development environment and gain practical experience on app development on the platform
  • Create service-oriented applications using WCF and study advanced use cases on implementing a RESTful service with WCF
  • Test your application inside Visual Studio 2013 IDE and advanced use case scenarios to handle testing issues
  • Effectively utilize the various components of Team Foundation Server for better management of code
  • Extend Visual Studio 2013 IDE to add your own custom changes enhancing your experience
  • Discover the advanced usage of cloud computing with Windows Azure and its various components

Sunday, April 21, 2013

.NET Book : Visual Studio 2012 and .NET 4.5 Expert Development Cookbook (Must Read)

Friends,

It is my great honor to tell you that my book has finally been released this week. If you have ever liked any of my blogs or internals, you would like this book for sure. There are lot of things to learn from the book and I can assure you that you wont be upset with this book if you buy it.

The "Visual Studio 2012 and .NET 4.5 Expert Development Cookbook" is a book that guides you through steps to ensure you enrich the best experience with the latest technology in the best amount of time possible. The book focusses to give you under the hood expertise in .NET technologies it tends to cover and adapts you the best to face common problems of these technologies. The book is divided in forms of recipes. Each of these recipes gives you clear insight of the problem and step by step process to solve the issue practically. It also addresses the advanced features associated with each of those recipes that gives you additional advantage on getting precise knowledge about the problem and its associated issues.

What you will learn from this book



  • Basic usage of Visual Studio 2012 IDE and its various components and better utilization of the tool while writing code
  • Understand memory management techniques to build better applications
  • Understand the .NET infrastructure with in-depth analysis of its internals
  • Architect solutions that leverage the full power of .NET language gems, understanding when to use what
  • Implement multithreaded / asynchronous applications using recent updates on .NET 4.5 and compare the past approaches
  • Create secure ASP.NET web based applications in .NET 4.5 with use of JQuery and HTML5 for rapid application development
  • Architect advanced .NET client applications using MVVM with WPF 4.5
  • Understand touch sensitive devices and leverage skills to develop multi-touch applications inside Windows 8

Monday, September 26, 2011

Internals of .NET Objects and Use of SOS

Well, now getting deeper into the facts, lets talk about how objects are created in .NET and how type system is laid out in memory for this post in my Internals Series.  As this is going to be very deep dive post, I would recommend to read this only if you want to kill your time to know the internal details of .NET runtime and also you have considerable working experience with the CLR types and type system.


Recently I have been talking with somebody regarding the actual difference between the C++ type system and managed C# type system. I fact the CLR Type system is different from the former as any object (not a value type) is in memory contains a baggage of information when laid out in memory. This makes CLR objects considerable different from traditional C++ programs.

Classification of Types

In .NET there are mainly two kind of Types.
  1. Value Types (derived from System.ValueType)
  2. Reference  Type (derived directly from System.Object)
Even though ValueTypes are internally inherited from System.Object in its core, but CLR treats them very differently.  Indeed from your own perception the Value Types are actually allocated in stacks (occationally) while reference types are allocated in Heaps. This is to reduce the additional contension of GC heaps for Heap allocation, GC cycles, occasional call to OS for additional memory needs etc. The object that is allocated in managed Heap is called Managed Object and the pointer that is allocated in stack to refer to the actual object in heap is called Object Reference (which is sometimes called as Managed Pointer). 

Saturday, September 24, 2011

Internals of Interface and its Implementation

As many of my followers requested me to write few things that I missed out from the Internals Series, I should continue with it. In this post, I will cover the internals of Interface implementation and mostly talk about explicit interface implementation, as most of the developers seems to be in confusion with it. I hope you will like the post.

Beginning from the basics, Interfaces are the most important part of any application. Interfaces are language construct that does not implement anything but declares a few members upfront. Generally we use interfaces to create a contract between the two or more communication agents. Another important thing that everyone would be knowing already, Interfaces are meant to be implemented. That means whenever you are creating a class, all the members that were there in the interface are meant to be implemented completely. .NET (or probable any other standard language) disallows the creation of objects on types that are not fully defined. Hence abstract classes also coming into play here. They are classes that have few members undefined or abstract. Once you don't have concrete implementation, you cannot create an instance of a type. Notably, you can say "Interface is a types that does not belong to the System.Object or implement it when it reside inside an assembly". But ironically you could also says that once the type is implemented, it would probably inherit from System.object by default.


Sunday, July 31, 2011

Internals of Dependency Property in WPF

WPF introduces new property system to us. Every WPF objects that is inherited from DependencyObject inherently supports Dependency property containers within it. That means you can define your own dependency property in your code which can take part in some of the interesting features of WPF like Binding, Styles, Triggers, Animation, Property Inheritence etc. Today I will concentrate on how Dependency Property system is actually built and what are the benefits we get instead of using CLR property system.

Note : If you are really new in WPF and don't know about Dependency Property, it would be nice to read my post on Dependency Property or you can also try WPF Tutorial series to start on.



So lets start on using the most basic code of creating your own Dependency Property.

Sunday, July 17, 2011

ValueType and ReferenceType : Under the Hood Part 2

Well, if you have read my previous post, you should be already clear how memory of ValueTypes and ReferenceTypes are allocated and De-allocated internally in terms of IL. Here in this post, I am going to cover some more concepts behind ValueTypes and ReferenceTypes and what exactly comprises of them.

In my previous post on the series, I have told you that any type that inherits from System.ValueTypes is stored in Stack while any type that is not inherited from System.ValueType is stored in Heap. Well, the statement is not correct totally.

Saturday, July 16, 2011

ValueTypes and ReferenceTypes : Under the Hood

In .NET, Value Type and Reference Types are forms an element of confusion between both developers and the students. Many of us take this as granted that Value Types are allocated in Thread Stack ( a 1 MB local stack created per Thread) and on each method calls the local value types are allocated in the Stack such that after the call ends, the object is deallocated. On the contrary, the reference types we know are those which are always allocated in heap (which is not always true, I will discuss later) and even though they are used as locals, and will be deallocated only after an interval by a separate Thread that is running with any .NET process (called finalizer thread) which occationally starts finding the memory blocks on Heap storage and compact and store only the reachable objects called Garbage Collector. Well, in this post, I am not going to cover the details of Garbage Collection, but rather I will focus more on Value Types and Reference Types that I know personally to clear any doubt regarding them in terms of IL constructs. So after reading the post, you will know some of the basics of IL too.

Saturday, June 25, 2011

Some facts about Null in .NET

As I am tweeting around the facts on Nulls for last couple of days, I thought of writing a blog on that as many of you have already requested me on this regard. This post is basically dealing with Nulls and will go through only with basic C# stuffs, so for geeks, it is not recommended and you might end up knowing a little or almost nothing. So if you just here for time pass, then I refer to read on.

Considering the fact Nulls appear on any objects, we have mainly two categories of programmable storage in .NET.

  1. Nullables (generally mutable with exceptions like strings)
  2. Value Types / struct (generally immutable)
Nullables are types that either user defined or in framework in which one of its value can be null. .NET treats null specially. Say for instance :

Concept Overide vs Method Hiding in terms of C#

Overriding is one of the most interesting topic that many software professionals are dealing with quite regularly. Most of the applications we write in .NET or other languages somehow uses overriding. While you write your class, one of the most important thing that you need to consider is overriding ToString() to ensure that your class does not produce the “Name of the class” rather you produce something useful on your context. Method hiding is another concept similar to Overriding but is actually different in many respect. But I saw many people does have a little confusion among these two concepts and does not know when to use what. Here is some sample which would help you deal with these concepts easy.

Overriding

Overriding means redefining an existing method that comes inherited from parent class. Say for instance, you have defined a class Animal. Animal can move and eat. So let’s define the class :


public class Animal
    {
        public virtual void Walk()
        {
            Console.WriteLine("Animal is now Walking");
        }
        public void Eat()
        {
            Console.WriteLine("Animal eats for living.");
        }
    }


So this is quite a simple class that provides two methods. The first one is Walk which prints a message, and another is Eat, which again prints another message. Now notice, I have made the Walk method of Animal Virtual. Virtual means, the method will be bound at runtime, hence no compile time binding will be produced and runtime object will take over compile time bindings.

Saturday, June 4, 2011

Playing with Reflection and Async

Hi Guys,

Task Asynchronous Pattern as you already know from my article, is one of the major change of next generation .NET applications. As this is already discussed in detail in the article, I will not repeat the same again here in this post. If you don't know what is it, please go ahead and read the article. In this post, I will try to use reflection to invoke our own async method. 
So to start, let us take a look at one of the simplest Async method. 
static void Main(string[] args)
{
    Program p = new Program();

    Task t = p.TryCallAsync(10000);
    t.Wait();

    Console.ReadLine();
}

public async Task TryCallAsync(int delay)
{
    Console.WriteLine("TaskEx.Delay is called : will wait for {0} milliseconds", delay);

    await TaskEx.Delay(delay);

    Console.WriteLine("Finished execution Return to the caller");
}

In this code I have just put a delay of 10 seconds. Now after the execution is finished, another message will be printed on the screen.

Thursday, June 2, 2011

Internals of Array

Arrays are most important part of your program. Almost most of the collection that you work with in .NET framework is internally maintains Array. Say for instance, if you take the List it actually internally represents T[], while Dictionary is actually an array of structure KeyValuePair internally. Hence, array forms a very important part of your program. 

Few days back while browsing over internet when I found an article written one of my buddy Dhananjay Kumar here, I thought how could I forget this important section of C# language, hence in this post, I will cover some of the important things that you need to remember while you use arrays in .NET.


Arrays Vs IEnumerables


Well, when working with Collections, the first thing that will come in your mind is the IEnumerables. Well, IEnumerable is the generic implementation of any iterators. In .NET every array internally implements an IEnuerable. You may think IEnumerable as a iterable sequence, which could be applied to anything that is iterable while array on the other hand has a fixed set of values contiguously allocated. By the way, each arrays actually implements an IEnumerable internally, so eventually in .NET every array is by default an IEnumerable.


Monday, April 4, 2011

Internals of LINQ

If you remember my post on Annonymous Types, I have already stated that there is no concept of annonymous types in MSIL. Every generated type will be mapped to a concrete type produced by C# compiler during the runtime. In this post, I am going to cover few basics of LINQ, and how it is been maintained in IL. If you are very new to Linq, it is recommended to learn the basic usage of it first. You can read my article on Linq Basics, to know more about it.

LINQ means Language Integrated Query is one of the major step forward to .NET framework to support queries to work on objects. LINQ allows you to write custom query statements on .NET objects or more specifically any IEnumerables to filter or fetch data from it.

In this post, I am not covering the basics as I have already discussed it in a separate article. Lets start with internals.

Tuesday, March 15, 2011

Internals of Events

If you are looking already at my internal series, you must by now know what does an entry from Internal series means. Yes, In each of those articles, I have tried to at least give some basic idea about the usage and later tried to show you some of the internal process that is happening to achieve the technique. In this post, as the name suggest, I will show how the event system works in .NET (or rather C#) and how this system is actually achieved into the system.

The Basics

Event is a special object in .NET which allows you to give notification to the external world. As far as I am concerned, its a means of communication between the object to the external world, or rather a means of inversion of control to the caller. Now what exactly an event does ?


Sunday, March 13, 2011

Internals to .NET

C# is a language which most of us like the most. I like to code in C# and want to delve deep into its internals. I wrote few posts too regarding Internals of C# language. Here in this post I am going to jot down all the links on Internal Series.for you. If you havent started reading them, its time to go on with it.

Internals of .NET Objects and use of SOS

Internals to C# Language Basics

Internals of Interface and its Implemention
Internals of LINQ
Internals of Events
Internals of Annonymous Method
Internals of Exception Handling
Internals of C# iterators
Internals to Convert and Cast
Internals to C# loops
Internals to Extension Methods
Internals to Delegates
Internals to Array

Internals of ValueType and Reference Types
Value Types and Reference Type : Under the Hood
Value Types and Reference Type : Under the Hood Part 2

ADO .NET internals 
Part 1
Part 2

Miscellaneous Entries

Internals to Code Contracts in .NET 4.0
Hidden Facts of C# structures in terms of MSIL
C# 5.0 vNext - Asynchronous Pattern Made Easy

I hope you did like the series. I will update the post as soon as there is any new post on the subject. Please stay tuned with me for more internals.

Also I have recently released a book which would be worth trying for you.


You can get the book from the link below :
http://www.packtpub.com/visual-studio-11-and-dotnet-4-5-expert-development-cookbook/book

Also you can read more about it from :
http://www.abhisheksur.com/2013/04/net-book-visual-studio-2012-and-net-45.html


Thanks for appreciating my posts.

Monday, March 7, 2011

All about .NET Timers - A Comparison

Threads and Timers are the most common things that you need for your application. Any work that needs to be done in background without intervening the work that is running in the foreground needed to be done using a Thread. We create Threads to delegate a long running process in background so that the UI remains unblocked. Timers on the other hand is a special module which runs after a certain interval of time in background. So you would think Timers will also create a new Thread in background and runs the module associated with it after a certain time. This is not always true.
In this post, I will compare most of the timers available with .NET right now, and later on discuss about DispatcherTimer in WPF.

Difference between Concurrency and Asynchrony?

Now if you look back when Microsoft introduced async CTP in PDC 2010,  or my own article on Async, it is clearly stated that Asynchrony and Concurrency are two different concepts. Asynchrony means running a job without blocking the Thread where it is working at. Concurrency is actually a special kind of asynchrony where it is achieved by creating a new Thread. Hence you can say, all sorts of concurrency is asynchrony while all asynchrony is not concurrency. You can have asynchrony without concurrency and it is really worth doing that, as you all know it is not good to put every work in Separate thread. ThreadPools could somewhat help by allowing you to manage threads but still Threads are for long running background processes, so beware to use it only when you absolutely require it.

Going ahead with this thought, lets compare the existing Timers.There are a number of Timers available with .NET before. Many of us might not know what is the basic difference between them. Lets put a comparative analysis on them one by one.

Sunday, February 20, 2011

Inversion of Control : Practical usage of Interface, Delegate or Events

Inversion of control is an architectural design principle which modifies the general flow of control of a program. You can say a program is a sequence of instructions that are running in a predefined sequence. Hence the sequence of execution of the program representing a sub-routine is defined when the class is actually implemented. Therefore, when the object is produced, it would have a sequence of instruction through which the control moves when it is called to execute. Inversion of control is a special circumstance where you will invert the predefined control flow to some arbitrary call defined way down the stream by the user who actually using the component. In this post, I will show you how you can implement inversion of control in your code and also approaches which help you while implementing your own class.

You can generally implement inversion of control in C# using 3 approaches :

  1. Interface
  2. Delegate
  3. Event

Here I will implement each of them with sample code.

Download Sample Code : 39KB

Sunday, February 13, 2011

Code Contracts in .NET 4.0 & its Internals

After I have introduced you the Internals of Exception handling, I have mentioned that I will cover some of the features that is coming as an improvement to it. Code Contract in .NET 4.0 is one among them. In this post, I will cover how you could use code contract in your application and also take the way through to its internals later on.


One can argue with me, that code contract is a part of unit testing and might be included as a part of.NET test projects, but according to me, it is not restricted only for testing frameworks, you could use it more likely for your own libraries so that you could have better code handling and also some way of separation between the validation logic for which the library is built in and how you would react with the outside world. Now let us discuss, how to use it in your program, and later on I will build an application to use it.

Sunday, February 6, 2011

Internals of Anonymous Types

.NET comes with lots of new features as it introduces new features. Many of them are quite useful while others might be very specific to an issue. One of the features that came up recently with the introduction of .NET 3.5 in C# is anonymous method. Anonymous means an object with no name. Before .Net 3.5 we had concept of anonymous delegates in C#. If you read about internals of delegate, you must already know how anonymous delegates are declared to CLR. In fact, there is no concept of anonymous in MSIL. Hence everything that you see as anonymous is actually a level of abstraction to us, and lets us to avoid the complexity to maintain unnecessary types to our program. In this post, I will discuss about anonymous type in terms of MSIL.


The Basics

Anonymous types are those types which are not declared before they are used. Say while you are doing your program, you want a temporary storage of your data, what you need to do, you need either declare a concrete class for the storage of the same, or you can use any collection like ArrayList, HashTable etc to store the key value collection. C# 3.5 and onwards allows you to dynamically create a type and use it directly in your program. You can use ‘var’ or implicit type declaration to ensure you could use the properties just like normal types.

var myruntimeObject = new { FirstProperty = 10, SecondProperty = new DateTime(), ThirdProperty = "string type" };

Console.WriteLine("Type of myruntimeObject is {0}", myruntimeObject.GetType().Name);
Console.WriteLine("Type of FirstProperty is {0}",       myruntimeObject.FirstProperty.GetType().Name);
Console.WriteLine("Type of SecondProperty is {0}", myruntimeObject.SecondProperty.GetType().Name);
Console.WriteLine("Type of ThirdProperty is {0}",        myruntimeObject.ThirdProperty.GetType().Name);

Console.Read();

In the above example I have created one anonymous type using var. The var will give you a chance to get intellesense in your code. You can see the variable holds an object of an anonymous type generated runtime. The power of var in code can also be tested. Just hover over the var keyword and you will see that the type is defined as anonymous.

Monday, January 31, 2011

Internals of Exception Handling

Exceptions are runtime bugs that occur due to illegal action taken by the user. The Exception occurs whenever the object state is corrupted and which causes the program to terminate. Based on the severity of the exception we choose either to continue with the program by proper handling the code or rethrow the exception again to the parent block and eventually terminate the whole program.

In this post, I am not going to talk about how to throw/re-throw exceptions or even write the best practices on Exception handling, but I will go on with some of the hidden facts of exception handling which you might want to know and later on will involve IL to check how exceptions are generated.

The Basics

Exception handling is one of the weakest section of CLR. Even though I like most of the things that CLR brings to us, but I definitely disagree if the exception handling is one amongst it. Even the exception handling as been evolved with the system is enhanced very well recently with the introduction of Uncatchable Exceptions, RuntimeWrappedException, code contacts etc. Lets discuss some of the major enhancements to the exception system.

The .NET exception handling is made up of three sections :

  1. try : In this segment you need to write only the portion which can potentially throw errors. 
  2. catch : This section can overload based on the type of Exception and will be used to handle the exception which occurred in the Try block.
  3. finally : This block executes irrespective of try and catch. We write the clean up tasks here as it ensures to run even anything occurs. 

Monday, January 24, 2011

Internals to C# iterators

Hi Folks,

Hope you all are good.  If you are new to this post, I would recommend to red my other post too from the Internals series. In this series I am trying to cover the basic C# programming and also relate them with the compiled MSIL. In my previous post while I am going through with the internals of foreach loop I told you to cover more on iterators in my next post. It is time to cover the basis on which the C# IEnumerable stands and the iterators.

If you ask me why I like to work on C# not VB.NET or other languages, I would point to some of the flexibilities that I get with C#. Even though in VB.NET vNEXT, iterators are coming into being but still C# is the primary language which introduced yield.

In this post I am going to demonstrate the basic feature behind the C# iterators and also introduce you the secret behind the yield keyword of C#.

Author's new book

Abhishek authored one of the best selling book of .NET. It covers ASP.NET, WPF, Windows 8, Threading, Memory Management, Internals, Visual Studio, HTML5, JQuery and many more...
Grab it now !!!