Tuesday, April 16, 2013

VS 2012 - launch multiple browsers

Pretty cool feature in Visual Studio 2012 to launch in multiple browsers at a time. This will help save time, we don't have to launch each browser once. If we make it a practice we will find less browser specific problems I guess...

Along with this feature, you would be able to test web page at many screen resolutions. This will emulate resolution on browser. If you have a high-end monitor, don't have to bother coming to lower resolution for testing the webpage.

Review below video on how-to,

Saturday, April 6, 2013

Google Maps

Here is my recent experience using Google Map API.

Using maps API, for any given longitude - latitude map could be loaded.

// include script along with API Key

// create LatLng object
var latlng = new google.maps.LatLng( 17.4155646, 78.47505330000001).val())

// Set Map Type and zoom level
var mapOptions = {
          center: latlng,
          zoom: 15,
          mapTypeId: google.maps.MapTypeId.ROADMAP 

// create map object using a placeholder div tag for loading the map.
map = new google.maps.Map(document.getElementById("map-canvas"),

// create a tag position on exact location of longitude and latitude
var tagPosition = new google.maps.Marker({
position: latlng

As simple as that ! But it's just background work - how is this useful?

1) You may use GeoCoder service to translate a location address to Longitude and Latitude. Typical way maps are used. Provide a text box to enter location. GeoCoder Service provides required information to load the map for that address.

2) Or something cool - use longitude and latitude information on an image to point out where the picture was taken. Consider following screenshot,

You could showoff images on a map in a pretty cool manner!

Friday, January 18, 2013

Intriguing JavaScript (for a C# developer like me)

Following creates and calls the function, straight away.
})('hello world');

Following mean the same!
A) object1.function1(data1);
B) object1['function1'](data);

$ is a function name. It's not any special syntax. Rocket science $#@%^$

= = Vs = = =
True for the following
var a = 10 /*integer 10 */, b ="10" /*string 10 */;
alert(a == b);

False for the following
var a = 10 /*integer 10 */, b ="10" /*string 10 */;
alert(a === b);

Undefined Vs null 
var a; 
alert(a == null); //true
alert(a == undefined); //true

But initialization defines type of variable,
var a = 10; alert(typeof(a)); //number
var a = ''; alert(typeof(a)); //string
var a = null; alert(typeof(a)); //object
var a; alert(typeof(a)); //undefined

Wednesday, January 2, 2013


How would one approach trace information in development environments? Trace I mean any additional information about call-stack, function input, output etc. Classes in the application are coded with a specification in mind. In a simple example, a class named User could be intending to create, update, delete or select one or more users (CRUD). When the Create function is called, all required user details expected to be provided by calling function. Let's say calling function didn't provide first name, should your class handle it? In an end-to-end application flow, UI validations/service validations take care of it. Should it be done across layers? That's lot of redundant code for me. 

If UI validation didn't work correctly, how about finding it in development right on our face. If it did, we avoided a bug!

Will unit tests find such problems? I'll leave it to you to answer that question.

I would think, Symbols solve this problem. We can write code that works in specific environments only; In this case Development environment - Debug. Before and after every function, let's add code that runs in Debug mode only. This code doesn't run in QA, Production so on. Which means no redundancy (where it matters). Checks(validations) are everywhere, so a UI validation failure is seen early enough. But wait I said before and after every function? - Preconditions and Post-condition checks; Is the input as expected to the function, is the output as expected from the function?

Solution Configurations:
It acts like template of settings in Visual Studio solution. By default available settings are Debug and Release. Debug configuration has a symbol called DEBUG.

One can create custom configurations. For a given project, one can add symbols for that custom configuration

Pre-Processor Directives:
They start with a hash (#), generally work in combination with symbols. These are additional instructions to compiler in code.

Consider below code line, #if verifies specific symbol exists or not. On developer machine, in Debug configuration, DEBUG symbol would exist. On Production machine, in Release configuration it wouldn't.

Complete list of Pre-processor directives here (http://msdn.microsoft.com/en-us/library/ed8yd1ha%28v=vs.71%29.aspx)
System.Diagnostics.Debug class
Runs in debug mode, no need to use pre-processor directive as far as code is specific to Debug symbol.

For the above mentioned example on creating a customer, below statement alerts when required field was not provided and stops the solution from running. Developer can't miss the error.

Or do you want to approach by logging all these errors to event log? You can do that too - 

Just for fun, why not print to console?