Wednesday, July 26, 2017

Visual Studio Code – Popular Extensions

  • Visual studio code is a light weight, super-fast, free, open source and cross platform IDE developed by Microsoft
  •  It runs on windows, macOS and Linux operating systems.
  •  It has built-in support for JavaScript, Typescript and Node.js
  •  We can add wide range of extensions to VS Code for front-end development like C#, Java, Python, Angular, ReactJs, C++, PHP and etc.
  •  It has great in-built intellisence support for JavaScript, Typescript, CSS and HTML 
  •  It has in-built debug , attach process, breakpoints and watch mode inside editor 
  •  Built-in side bar with GIT commands 
  •  It has integrated terminal/command prompt to run any commands without moving out from editor 
  • We can import keyboard shortcuts from different editors using extensions 
  • Easy customization and support different themes 
  • Easy to export editor settings to make all developers to follow same standards in a team

Popular Extensions:

1. Debugger for Chrome :
It is built by Microsoft itself and used to debug JavaScript code in Google chrome without leaving the code editor. This extension has breakpoint settings, variable watching, stepping and debug console 

https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome

2. Angular Essentials:
It has packed with multiple extensions for complete Angular development.

https://marketplace.visualstudio.com/items?itemName=johnpapa.angular-essentials

3. HTML Snippets :
It gives great support for HTML with intellisence and syntax colouring.

https://marketplace.visualstudio.com/items?itemName=abusaidm.html-snippets

4. HTML CSS Class Completion:
It fetches name of all CSS classes in the current workspace and display complete list while typing

https://marketplace.visualstudio.com/items?itemName=Zignd.html-css-class-completion

5. TSLint:
It identifies issues in TypeScript code while writing and provide auto fixes too

https://marketplace.visualstudio.com/items?itemName=eg2.tslint

6. EditorConfig for VS Code:
It maintains consistent coding style for all developers. It makes easy while comparing files with equal indentation, spaces, tabs, line start and line end

https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig

7. C#
It allows writing C# code for .NET Core framework. It supports debugging, syntax highlighting, intellisence, Go to Definition, Find All reference and etc.

https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp

Learn more about VS Code from https://code.visualstudio.com/

Happy Coding :)

Tuesday, July 25, 2017

Angular CLI – Speed up Angular2/4 development

 Angular Team has re-branded the names from “Angular 2” to “Angular” and “Angular 1.x” to “AngularJS” which is now official names of these frameworks
  1. Angular CLI is a Command Line Interface to build, deploy and test angular applications. 
  2. It automates lot of development activities to improve code quality and reduce development time. 
  3. Angular CLI helps us to create new angular application, run a development server with LiveReload, run unit test cases, run E2E test cases, build and deploy as per environment specific


You can download complete documentation from the link : Download

Happy Coding :)

Wednesday, July 5, 2017

C#.NET – String Interning

If there are two identical string literals in one compilation unit then the code we generate ensures that only one string object is created by the CLR for all instances of that literal within the assembly. This process know as “string interning

CLR keeps string storage by maintaining a table called the intern pool, which contains a single reference to each unique literal string declared or created programmatically in the program. Hence, an instance of a literal string with a particular value only exists once in the system

Advantage :
  1. It decreases memory consumption 
  2. It decreases time required to compare two strings 
Disadvantage :
  1. After declaring new string literal, It needs to search all strings objects in memory to check if any one matches with in assembly
Example 1 :
                string str1=”christopher”;
                string str2=”christopher”;
    Console.WriteLine(str1 == str2); // true
    Console.WriteLine(Object.ReferenceEquals(str1,str2); // true

Here both strings (i.e. str1, str2) are having same identical text/literals. So it creates only one memory location by CLR and both strings will be pointed to same memory location (This process known as string intern).

Example 2:
                string str1=”christopher nolan”;
                string str2=”christopher” + “nolan”;
    Console.WriteLine(str1 == str2); // true
    Console.WriteLine(Object.ReferenceEquals(str1,str2); // true

Here both strings (i.e. str1, str2) are having same identical text/literals. So it creates only one memory location by CLR and both strings will be pointed to same memory location (This process known as string intern).

Example 3:
                string lastname=”nolan”
                string str1=”christopher nolan”;
                string str2=”christopher ” + lastname;
    Console.WriteLine(str1 == str2); // true
    Console.WriteLine(Object.ReferenceEquals(str1,str2); // false

Here second condition returns false, because we are assigning string object instead of string text/literal.

   If we change str2 assignment as follows
string str2=string.Intern(”christopher ” + lastname);
Console.WriteLine(Object.ReferenceEquals(str1,str2); // true
Now it returns true.

Example 4:
                string str1=”christopher nolan”;
                string str2=new StringBuilder().Append(“Christopher “).Append(“nolan”).ToString();
string str3=String.Intern(str2);
Console.WriteLine((object)str1 == (object)str2); // false
Console.WriteLine((object)str1 == (object)str3); // true

Here first condition returns false, because we are assigning string object instead of string text/literal.

Example 5:
                string str1=””;
                string str2=””;
StringBuilder sb = new StringBuilder().Append(String.Empty);
str2 = String.Intern(sb.ToString());
Console.WriteLine((object)str1 == (object)str2); // sometimes true, sometimes false

Regard to interning empty string,
.NET Framework 1.0, 1.1, and 3.5 SP1 returns true
.NET Framework 2.0 SP1, 3.0 returns false

Happy Coding :)