Visual Studio 2015 Update 2–Download

Today Microsoft has released Update 2 for Visual Studio 2015. Visual Studio 2015 Update 2 includes a variety of capability improvements and bug fixes. To find out what’s new, see the Visual Studio 2015 Update 2 Release Notes. For a list of fixed bugs and known issues, see the Visual Studio 2015 Update 2 MSDN Article.

Download:
Visual Studio Community 2015 with Update 2 – Web Installer –  ISO
Visual Studio Enterprise 2015 with Update 2 – Web Install –  ISO
Visual Studio Professional 2015 with Update 2 – Web Installer –  ISO
Visual Studio 2015 Update 2 – Web InstallerISO
Visual Studio Team Foundation Server 2015 with Update 2 – Web Installer –  ISO
Visual Studio Test Professional 2015 – Web InstallerISO
Visual Studio Express 2015 for Windows 10 – here
Visual Studio Express 2015 for Web – here
Visual Studio Express 2015 for Desktop – here

Back to Basics : Singleton Design Pattern using System.Lazy type

This article takes you to a simpler/alternative approach in making a Singleton Design Pattern implementation using System.Lazy class rather that using our traditional approach.

Singleton Design Pattern implementation without lazy initialization:

– This code is thread safe enabled

[code language=”csharp” padlinenumbers=”true”]
/// <summary>
/// Singleton class
/// </summary>
public class AppConfig
{

private AppConfig()
{

}

/// <summary>
/// Gets the current date time.
/// </summary>
/// <value>
/// The current date time.
/// </value>
public DateTime CurrentDateTime
{
get
{
return DateTime.Now;
}
}
/// <summary>
/// The _config
/// </summary>
private static AppConfig _config;

/// <summary>
/// The pad lock for maintaining a thread lock.
/// </summary>
private static readonly Object padLock = new object();

/// <summary>
/// Gets the instance.
/// </summary>
/// <value>
/// The instance.
/// </value>
public static AppConfig Instance
{
get
{

if (_config == null)
{
lock (padLock) // making thread-safe
{
//{
if (_config == null) //second level check to make sure, within the short span, another concurent thread didnt initialize the object.
{
_config = new AppConfig();
}
}
}
//}

return _config;
}
}
}
[/code]

This approach ensures that only one instance is created and only when the instance is needed. Also, the variable is declared to be volatile to ensure that assignment to the instance variable completes before the instance variable can be accessed. Lastly, this approach uses a padLock instance to lock on, rather than locking on the type itself, to avoid deadlocks.

Another variant using Lazy initialization using static constructor and thread safe since initialization is handled during runtime within readonly variable declaration.  This will be thread-safe any ways.

[code language=”csharp”]
/// <summary>
/// a Simpler version of Singleton class with lazy initialization.
/// </summary>
public class AppConfigLazy1
{
// static holder for instance, will not get initialized until first use, due to static contructor.
private static readonly AppConfigLazy1 _instance = new AppConfigLazy1();

/// <summary>
/// Prevents a default instance of the <see cref=&quot;AppConfigLazy1&quot;/> class from being created.
/// </summary>
private AppConfigLazy1()
{

}

/// <summary>
/// for Lazy Initializes the <see cref=&quot;AppConfigLazy1&quot;/> class.
/// </summary>
static AppConfigLazy1()
{

}

public static AppConfigLazy1 Instance
{
get
{
return _instance;
}
}
}
[/code]

Now with .NET 4.0 onwards there is a better way of doing this using .NET Runtime methods using System.Lazy type. System.Lazy type is mainly used in Entity Framework context, but we can use the same in implementing lazy loading where ever we have to deal with memory intensive object or collection of objects.

System.Lazy type  guarantees thread-safe lazy-construction. (By default, all public and protected members of the Lazy class are thread safe and may be used concurrently from multiple threads.)

.NET Framework Support in: 4.6, 4.5, 4

[code language=”csharp” wraplines=”false” htmlscript=”false” padlinenumbers=”true”]
/// <summary>
/// a Simpler version of Singleton class with lazy initialization.
/// </summary>
public class AppConfigLazy2
{
// static holder for instance, need to use lambda to construct since constructor private
private static readonly Lazy<AppConfigLazy2> _instance = new Lazy<AppConfigLazy2>(() => new AppConfigLazy2());

/// <summary>
/// Prevents a default instance of the <see cref=&quot;AppConfigLazy2&quot;/> class from being created.
/// </summary>
private AppConfigLazy2()
{

}

public static AppConfigLazy2 Instance
{
get
{
return _instance.Value;
}
}

/// <summary>
/// Gets the current date time.
/// </summary>
/// <value>
/// The current date time.
/// </value>
public DateTime CurrentDateTime
{
get
{
return DateTime.Now;
}
}
}

[/code]

That’s more than one way doing Singleton Pattern Implementation right?, hope that was helpful to you  Some reference links are given below:

New Certification – MCSD – Azure Solution Architect

Microsoft has made availability of new MCSD certification called as “MCSD – Azure Solutions Architect“.

Required Exams:
070-532: Developing Microsoft Azure Solutions
070-533: Implementing Microsoft Azure Infrastructure Solutions
070-534: Architecting Microsoft Azure Solutions

Once you complete the above required exams you will be awarded MCSD – Azure Solutions Architect certificate valid for 2 years.

PS: You will have to retake the renewal exam every two years to stay on as an MSDN Azure Solutions Architect.

For more details on the certification: https://www.microsoft.com/learning/en-us/mcsd-azure-architect-certification.aspx

Introduction to HTTP/2

The reason I got started with topic is that, there  were some buzz around Visual Studio 2015 RC support for HTTP/2 and Windows 8 – IIS support for HTTP/2. I was curious to learn further about the HTTP/2 and sharing my findings in this article.

About HTTP/2.

HTTP/2 is the first new version of HTTP since HTTP 1.1, which was standardized in RFC 2068 in 1997.

  • HTTP/2 enables a more efficient use of network resources and a reduced perception of latency by introducing header field compression and allowing multiple concurrent exchanges on the same connection. 
  • It also introduces unsolicited push of representations from servers to clients.
  • This specification is an alternative to, but does not obsolete, the HTTP/1.1 message syntax. 
  • HTTP’s existing semantics remain unchanged.

HTTP/2 allows the server to “push” content, that is, to respond with data for more queries than the client requested. This allows the server to supply data it knows a web browser will need to render a web page, without waiting for the browser to examine the first response, and without the overhead of an additional request cycle.

Quoting from MSDN:

HTTP/2 is a new version of the HTTP protocol that provides much better connection utilization (fewer round-trips between client and server), resulting in lower latency web page loading for users.  Web pages (as opposed to services) benefit the most from HTTP/2, since the protocol optimizes for multiple artifacts being requested as part of a single experience.

The browser and the web server (IIS on Windows) do all the work. You don’t have to do any heavy-lifting for your users.

[Source: MSDN]

HTTP v1.1 vs HTTPv2

  • HTTP/2 leaves most of HTTP 1.1’s high level syntax, such as methods, status codes, header fields, and URIs, the same. The element that is modified is how the data is framed and transported between the client and the server.

At a high level, HTTP/2:

  • is binary, instead of textual  ( the reason being is – “Binary protocols are more efficient to parse, more compact “on the wire”, and most importantly, they are much less error-prone, compared to textual protocols like HTTP/1.x, because they often have a number of affordances to “help” with things like whitespace handling, capitalization, line endings, blank links and so on. “)
  • is fully multiplexed, instead of ordered and blocking
  • can therefore use one connection for parallelism
  • uses header compression to reduce overhead
  • allows servers to “push” responses proactively into client caches

Taking help of an image visualization

http-timing-diagram

Major Milestones:

  • December 2014: The HTTP Working Group presented HTTP/2 to IESG for consideration as a Proposed Standard.
  • Feb 17, 2015: IESG approved it to publish as Proposed Standard
  • May 2015: The HTTP/2 specification was published as RFC 7540

Browser Support:

  • Chrome supports HTTP/2 by default.  (from version 41)
  • Google Chrome Canary supports HTTP/2 by default. (from version 43)
  • Chrome for iOS supports HTTP/2 by default.  (from version 41)
  • Firefox supports HTTP/2 which has been enabled by default since version 34.
  • Internet Explorer supports HTTP/2 in version 11, but only for Windows 10 beta, and is enabled by default. Currently only HTTP/2 over TLS is implemented.
  • Opera supports HTTP/2 by default (from v 28 onwards)

Reference Links:

Static vs Singleton Classes

Recently while I was attending an interview I came across a question Static vs Singleton. Though I know the differences I couldn’t answer it properly, as I was not refreshed my programming knowledge before the interview.

I would like to quote a reference to Jalpesh’s blog article (www.dotnetjalps.com) explaining the difference:

Difference between Static and Singleton classes:

  1. A singleton classes allowed to create a only single instance or particular class. That instance can be treated as normal object. You can pass that object to a method as parameter or you can call the class method with that Singleton object. While static class can have only static methods and you can not pass static class as parameter.
  2. We can implement the interfaces with the Singleton class while we can not implement the interfaces with static classes.
  3. We can clone the object of Singleton classes we can not clone the object of static classes.
  4. Singleton objects stored on heap while static class stored in stack.
  5. A Singleton class can extend the classes(support inheritance) while static class can not inherit classes.
  6. Singleton class can initialize lazy way while static class initialize when it loaded first
  7. Static classes are sealed class while Single ton classes are not sealed.

Credits to Jalpesh Vadgama  – “Computer Geek, Developer, Mentor, Life long learner, 10+ Years of Experience in Microsoft.NET Technologies, Awarded Microsoft Mvp(C#) for year 2010,11 and 2012.”