Some developers made this mistake when they catch an Exception and later rethrow them.

try {
  // something went wrong here
} catch (Exception ex)
{
    throw ex; //mistake here
}

How many of you do this? Do you know what is wrong here?

When you code throw ex; you are essentially throwing an except from this point onwards, discarding the original exception and information that you catch earlier. The trace from this point onwards would only go to where you are issuing the throw ex; statement.

What is the correct statement then?

try {
  // something went wrong here
} catch (Exception ex)
{
    throw;
}

Hope this helps!

NullPointerException is one of the most common error to crash an application. Everyone of us made this same mistake, the code runs fine although we did not check for null explicitly before calling toString() when we first code it because all the properties are instantiated during creation. It slips our mind and we checked in the code.

Uri myWebAddress = new Uri(“http://sirhoe.github.io”);
    …  //some flow
Console.Writeline(myWebAddress.toString());

After awhile, someone else modified the code and now the object’s properties are not instantiated immediate after creation.

Uri myWebAddress = new Uri();
    …  //some flow
Console.Writeline(myWebAddress.toString()); //throws exception

Now it crashes, because the System.Net.Uri object is null. This is just one example and there are many scenarios where similar error can happen.

Q: What is a Interface?

A: It has a structure of a Class, contains all the declarations but no implementations.

Why? What is the point of a Interface?

It serves as a contract for derived Classes. It dictates a set of public methods that implementing Classes must have, what arguments they get and what they return.

Please explain in non technical jargon, When and How do we use Interface as a contract?

When someone else is going to provide you the implementation later. You get to start working with your own code against a Interface because you already know what to pass in and get out of object’s methods which must surely exist in Classes that implement the agreed Interface. When you intend to swap out objects. To allow objects from different Classes to be interchanged, they have to implement the same Interface.

When I was migrating my development database with mock data to Azure to setup my portfolio site, I faced a migration issue while using the SQL Import and Export Wizard provided by my MSSQL Server 2014 installation. When I ran the wizard, it failed with a message complaining that Azure do not allow insertion in table which is created without a clustered index. The fix is obivious here, I will need to alter the table creation script, each one of them.

Thats alot of manual work for some mock data.

Luckily for me, I found a tool called SQL Database Migration Wizard which will analyze your database for Azure compatibility and in my case, automatically suggest adding Clustered Index to my tables while they are moved to the Azure cloud. Fantastic!

I would highly recommend this tool for development purpose and do be extra careful if you are moving production data. Here is the link to the tool.

Manipulating strings is probably the most performed task in programming yet most developer are not doing it efficiently. Developers tend to use the ‘+’ operand to concatenate strings because it is an easy syntax and they are not aware of better options.

One of the most common NHibernate mapping used is one-to-many, which is slightly more complex than the straight up one-to-one. There are a few things to take note of when we deal with such mapping especially when using FluentNHibernate.

For this demo, I am going to use FluentNHibernate 1.4 and NHibernate 3.3, particulary the FluentNHibernate.Mapping.Classmap class

I have been working on a ASP.NET MVC pet project of my own for a while, following tutorial from PrideParriot to build a blog engine from scratch. Ultimately, I intend to divert from the tutorial to add more functionalities as I get more comfortable.

Default Octopress installation came with github support, as a widget-like plugin called ‘aside’. The aside plugin will list your github repositores based on the account name you configured in Octopress’s _config.xml.

Now I needed another one for Bitbucket and luckily I found plugin developed by Izacus. The installation steps are clear and direct but the resulted Aside was ugly because it didnt include the necessary HTML class tag for my bootstrap css theme to work. Not a big deal, I got it fixed and the last thing I am going to do is contribute the changes back to the project. If you installed the plugin and faced similar issue, feel free to clone from my fork while the pull request is pending review.

Recently, I was looking to start a portfolio site to present my development work. I was contemplated to use the usual Wordpress blogging platform until I found out about the whole static page thing with Octopress via Github Pages. Imagine your blog being versioned in a rock solid SVN such as github and hosted free, I am sold.