I am among top 10 authors of 2014 on c-sharpcorner.com

Read official announcement here

I am pleased and excited to share that I have been selected among top 10 authors of the 2014 of the esteem community site C-SHARPCORNER. It is one of the most popular site among the developers with the numbers of users in the millions. It is founded by Mr. Mahesh Chand and run by team of sheer professionals. I thank readers, Mahesh sir and the C# corner team for the support and motivation.

Read official announcement here

clip_image002

I am glad to see myself among top authors and highly motivated community. Aspired to add more value in 2015. This year I will focus on MEAN stack along with CLOUD

Thank you C# Corner Team

11 things about JavaScript functions .NET developers must know: Part 1

I have often seen .NET developers struggle with the JavaScript. They try to compare C# functions with the JavaScript functions and usually do some minor but conceptual mistakes while using it. As we all will agree that JavaScript functions are the backbone of the JavaScript programming language, and if one has good understanding of the function then using JavaScript is easier. So in this two parts series, I will focus some important concepts of JavaScript functions.

In this part of the series, we will cover the following six topics:

  1. JavaScript function as an expression
  2. JavaScript function as a statement
  3. Return statement in the JavaScript function
  4. Parameters in the JavaScript function
  5. Arguments object in the JavaScript function
  6. Varargs JavaScript function

JavaScript functions can be an expression

A JavaScript function can be an expression. You can create a JavaScript function as an expression as shown below:

image

A function expression creates an instance of the function object. It can be passed as an argument to a function, it can be returned from a function, and it can be assigned to a variable or an array. A function expression can be created with the name as shown follows:

Read full article on the Infragistics blog

Getting started with Unit Testing JavaScript using QUnit

It is good to have automated unit tests for the codes while developing. In unit test we test smallest unit of the code for a particular behaviour. The Unit test helps us to find bugs in the code early in the development cycle. Essentially unit test is the piece of code which verifies behaviour of a particular unit of the code in the development phase. Unit tests can be run by the test runner multiple times to verify behaviour of a particular unit of code for different set of input. Now a day’s most of the application development are adhering to Agile and TDD approach. In the test driven development approach, first you write a unit test, it will fail, then write application code to pass the test. Unit testing is not different in JavaScript than other programming languages. To do unit testing or TDD in JavaScript, you need a testing framework. There are many popular JavaScript testing framework available. Some of them are as follows:

  • · Mocha
  • · Jasmine
  • · QUnit
  • · JSUnit

In this article we will focus on QUnit. QUnit is a unit testing framework provided by the jQuery team. It provides a rich set of test assertions, highly informative test suite UI, support of synchronous and asynchronous call back, support of test module etc. In this post we will cover the following topics,

  • Write first unit test
  • Understating the test suite UI
  • A look into the assertions
  • Grouping the tests

Writing the first test

Let us start with setting up the QUnit for the JavaScript unit testing. You need to add reference of the two QUnit files on the HTML page. Either you can have files locally in the project or you can use the reference of the jQuery CDN. I am going to use the CDN option as shows below:

Read full article here on Infragistics blog

Launched Video Blog: Watch to Learn with Dhananjay Kumar

I am excited to announce that, I have started a new video blog

WATCH TO LEARN WITH DHANANJAY KUMAR

clip_image002

On this blog, I will  focus on MEAN stack, C#, Azure, JavaScript etc. To start with I have published 5 episodes. Feel free to provide feedback such that we can together learn better.

I will try to keep Watch to Learn free. However you can support me with the donations. Feel free to subscribe and share.

So let us WATCH TO LEARN WITH DHANANJAY KUMAR  :) :)

Hindi Video : Create Azure based ASP.NET MVC application in 30 minutes

 

Subscribe here to YouTube channel for all episodes

image

Cloud has been a buzz word for a while now. As a developer, we focus on converting the customer requirements to the code and sometimes find ourselves behind with the industry buzz words. The cloud is everywhere and perhaps the future. However as a developer, you won’t have to write very different code for cloud than codes you have been writing for the in-premise applications. In this post, I assume that you are already aware about MVC applications, hence I will focus on demonstrating how building for cloud is not very much different. I will follow step by step approach and create end to end MVC application completely hosted in the cloud (data and application both).

In this article, we will follow the following steps,

  • Setting up the database in the SQL Azure
  • Creating the MVC application
  • Building the application using MVC and the Entity framework
  • Publishing the application to Azure web site

Read full article on Infragistics blog

Subscribe here to YouTube channel for all episodes

 

 

 

 

 

Read article based on this video here

Subscribe here to YouTube channel for all episodes

I hope you like this video. Do not hesitate to leave comment or any feedback. Happy coding.

Discount for my blog readers for video tutorial on WatchMeCode

image

Many of you have asked me recently that how I learn JavaScript and other related stuff. One of the resource, I heavily rely and learn from is WatchMeCode videos by Derick Bailey. I watch videos published here. Clearly videos demonstrate deep understanding of Derick on the subject and certainly you will be benefited by his teaching.

About WatchMeCode

WatchMeCode is a video tutorial site by Derick. He publishes various episodes here. You can find videos on following topics to learn.

clip_image002

As of now there are total 60 episodes and counting. Out of 60, few episodes are free to watch. There are episodes on JavaScript, Node, MongoDB etc. I am sure these episodes from none other than Derick will add lot of values to your learning and in your projects.

Find all episodes here

About Derick Bailey

Derick is a popular author, blogger and JavaScript lover. He blogs at http://derickbailey.com/ and you can follow his tweets at https://twitter.com/derickbailey .

How I can help to get subscription?

WatchMeCode monthly subscription is of $ 14 (roughly 840 RS. Per month). I can help you in getting the subscription in $9(roughly less than 500 RS. Per month). To get the discount coupon send me a mail on debugmode[at]outlook[dot] com or tweet me at https://twitter.com/debug_mode

I would say WatchMeCode worth much more than 500 RS and you must transact 500 RS per month to learn from one of the best in our industry.

C# basics: why we override Equals method

You may have come across questions,

  • Why to override Equals method?
  • How to determine whether two object are equal?
  • How to determine whether two objects are identical?

To get answer of all the above questions, let us consider Product class as listed next:

 


class Product
    {
        public int Price { get; set; }
        public string Name { get; set; }
            
    }

We are creating two instances of the Product class, foo and loo. The foo is assigned to loo. Both objects are pointing to the same reference, hence we will get true as expected output for all the Equals.

 


Product foo = new Product {Price = 10,Name= "foo"};
            Product loo = new Product();
             loo = foo; 
             var valueEqual = foo.Equals(loo);
            Console.WriteLine(valueEqual); 

            var objRefEqual= Object.ReferenceEquals(foo, loo);
            Console.WriteLine(objRefEqual);

            var objEqual = Object.Equals(foo,loo);         
            Console.WriteLine(objEqual);
            Console.ReadKey(true);

Expected output is,

clip_image002

Now let us go ahead and modify the instances as listed next:

 


Product foo = new Product {Price = 10,Name= "foo"};
            Product loo = new Product();
            loo.Price = 10;
            loo.Name = "foo";
            var valueEqual = foo.Equals(loo);
            Console.WriteLine(valueEqual); 

            var objRefEqual= Object.ReferenceEquals(foo, loo);
            Console.WriteLine(objRefEqual);

            var objEqual = Object.Equals(foo,loo);         
            Console.WriteLine(objEqual);
            Console.ReadKey(true);


This time you will get output as false for all the three Equals method.

clip_image002[6]

However if you closely observe, value of the both properties of both objects are exactly the same. Price and the Name property is set to 100 and foo respectively. But still we are getting Equals returns false for the foo and the loo object.

We can observe that, even though properties values are same Equals returns false. Essentially, when arguments are referring to different objects. Equals don’t check for the values and always returns false. We can say that by default Equals check for IDENTITICAL OBJECTS rather than EQUAL OBJECTS

Understanding Internal

To understand this behavior, let us examine the System.Object class. It contains,

  1. One virtual Equals method.
  2. One static Equals method. This takes two arguments. Returns true if they are identical otherwise false.
  3. One static ReferenceEquals method. This takes two arguments. Returns true if both arguments are same instance otherwise false.

Clearly CLR Equals method does not check for the values, when arguments refers to different objects. So by default it checks for the Object Identity rather than Object Equality.

Why to override Equals()

We may come across the requirement to check for object equality. To check whether both objects contains same properties value or not. This can be done by override the Equals method. We can override Equals method as listed next:

 

class Product
    {
        public int Price { get; set; }
        public string Name { get; set; }
        public override bool Equals(object obj)
        {
           if (obj == null)
                return false;
            if (this.GetType() != obj.GetType()) return false;

            Product p = (Product)obj;
            return (this.Price == p.Price) && (this.Name == p.Name);
        }        
    }


While overriding the Equals method, you should consider the followings

  • If object argument is null, return false
  • If type of object argument is different than type of this, return false
  • If object argument is neither null nor its type is different check for the values of the instance fields. If they are equal return true else return false

We have overridden Equals method, now if you compare the objects which is listed next, you will find that Equals returns true if Objects are equal whereas ReferenceEquals returns false when objects are different.

 

Product foo = new Product {Price = 10,Name= "foo"};
            Product loo = new Product();
            loo.Price = 10;
            loo.Name = "foo";
            var valueEqual = foo.Equals(loo);
            Console.WriteLine(valueEqual); 

            var objRefEqual= Object.ReferenceEquals(foo, loo);
            Console.WriteLine(objRefEqual);

            var objEqual = Object.Equals(foo,loo);         
            Console.WriteLine(objEqual);
            Console.ReadKey(true);


You will get the expected output true, false and true.

clip_image002[8]

Summary

We started with the question that why to override Equals method? We learnt that by default System.Object Equals method does not check for the equality of the objects. It checks only for the objects identity. To check objects equality, we override the Equals method.