C# – Testing some language features

Optional parameters should be placed at the end in the parameter definition. (Optional parameters is a VS 2010 feature)

Image

We can’t declare a class as private or protected. Only members within a class can have these access modifies.

Image

Automatically implemented properties must have both ‘get’ and ‘set’ accessors. We have to declare a member variable to implement get/set only feature.

Image

We could make set/get alone as private ( 2008 feature )

Image

If you have a property named MyPropery then you can’t have a function with name get_ MyPropery/set_MyProperty(int value) in the class, Hope you know the reason.

Image

An example to illustrate Javascript memory leak via closure.

An example for circular reference got created due to closure.

Image

Below diagram may help to understand the problem well.

Image

And the possible solutions for this problem are.

Solution 1 – By breaking circular reference.

Image

Solution 2 – By adding another closure.

Image

The anotherInnerFunction() creates a new closure and executes immediately. The obj reference is created with in this function and it’s scope got over when function finishes. In this solution ‘obj’ is created outside the closure of event function.

Solution 3 – By avoiding closure altogether.

Image

My favorite solution is #3 as this is a natural solution (no explanation needed); we could avoid landing up these types of problems by adding this rule to the coding standard.

I shamelessly copied the samples from this article.

Creating link to external folder in svn repository

Implementing this is simple in tortoise svn using the “Externals“. Let us see the step by step approach. ( I am using TortoiseSVN 1.7.7.)

First create the basic folder structure as planned, and commit the corresponding files in each folder.

Image

Now click on one of the platform specific folder where we need to link the common ‘www’ folder. Right click and select “Show Properties”

Image

This will display the properties window.

Image

Click on New button and choose “Externals”

Image

This will bring the externals window.

Image

Click on “New” button.

Image

In the new externals window fill the details. The local path should be ‘www’ as we want the sub folder name should appear as www in local disk.

In URL text box, enter the svn url to the external folder. ‘Revision’ is by default Head, keep it as is and click on ok. This will add the new entry in the externals window.

Image

Click ok. This will ask you to commit the changes.

Image

Enter some comments and click OK to commit.

Image

You could now view the new entry in the properties window. Click OK.

Right click and refresh the folder in repo browser to see the link.

Image

You could visually see a link to www folder here.

Image

Repeat these steps top all other folders and link the www properly.

Checkout any platform specific folder to your local disk for development. The external link will be like any other folder in local disk.

Image

Any commit to the ‘www’ folder will reflect in other platforms too. Now the developers could work on the platforms they are comfortable with.

You should take care while tagging or creating branch from this repository.  By default the tagged version will point to the master www folder. You need to manually reset to the right svn URL after crating a tag or branch.