Code quality Good practices

The benefits of Code Reviews

On page 28 from “97 Things Every Programmer Should Know” Mattias Karlsson talks about Code Reviews and the benefits of them.

He stated that “Instead of simply correcting mistakes in code, the purpose of code reviews should be to share knowledge and establish common coding guidelines”. I thought “This is very insightful indeed and I must implement it in my team. But with caution”.

The benefits

Let me first enumerate the benefits which I got as a result. Then I will explain how to introduce your team to code reviews.


Reasonable points to consider when you are going to create your professional blog

The professional blog is a good way to :

  1. share valuable content to others from your field of expertise
  2. connect with other professionals who work on similar problems
  3. share ideas and expertise
ASP.NET MVC Test Driven Development

Mocking HttpContext when testing IActionFilters in MVC

While trying to figure out how to make a full featured implementation of ContextMock builder based solely on Moq in order to make unit tests for an implementation of IActionFilter I stumbled upon a problem :

System.NotSupportedException Invalid setup on a non-virtual (overridable in VB) member: x => x.Values

Azure Powershell

A script to export sql azure databases.

My context for the script in this case.

  1. A bug from the client is reported. A bug that does not cause exception at the back-end nor at the front-end – The font-end simply stops. It does not even freeze. So you do not have any log for this case. Now you are in check ( chess check ).
  2. You need to dump the database from the staging environment ( NO! Not the production! )

The possible solutions :

  1. Go to azure portal and export all the databases needed by hand – click-click-click….a lot.
  2. Make a powershell script and do it really quick. This helps a lot when you do it more then once.

The script :


Migrating legacy MySQL database to SQL Azure with model mismatch

We have home grown web ERP system which is operating since 2004. It is built upon the LAMP stack. The ERP started for internal use but after many years of usage and polishing we decided to offer it for free to several other companies outside our organization. It was a success. We decided to rebuild it from the ground up as a SaaS product on .NET/IIS/MVC/SqlAzure/Blobs/Tables/ServiceBus/etc – MS stack. In the new version we have corrected all the design flaws we knew of, made it modular, implemented all the desired features, etc. One of the problems we have to solve is to migrate all the companies from the old system to the new one which means all the data – operational data, users with passwords etc. One of the problems that appear is with the data mismatch – the new core domain entity hierarchy is changed a bit and the other entities are changed too. To say it another way – domain model/entities impedance mismatch. Transfer of files is another story left for another post.

Azure Entity Framework Logging

Logging Entity Framework 6 queries to Azure Tables

I wrote about Semantic Logging (SL) in MVC and after watching Rowan Miller`s video from Tech Ed 2014 I decided to implement logging Entity Framework 6 queries to Azure Tables with EventSource (aka Semantic Logging / Structured Logging).


Motivation for logging Entity Framework 6 queries to Azure Tables

By MHO the motivation behind every logging system must include :

  1. Finding and removing bugs which improves QoS and reduces Dev/Ops time to resolve an issue.
  2. Good structured log which enables a less proficient programmers to solve the problem. Better support devs => higher ops. costs.
  3. Proactive response – get into action long before the client gets to you. Or even better – you call the client first.
  4. Measuring and optimizing performance of your app. As Mark Simms and Chris Clayton say that “premature optimization is the root of all evil.” is not so relevant when designing clod apps.
Learning Test Driven Development

How to start learning Test Driven Development or Behavior Driven Development?

When you get to the point of understanding that you do not have a lifetime to spend on F5 debugging/testing and you want to be a better developer ( I beg you to get it now! ), you should ask : How to learn Test Driven Development or Behavior Driven Development? Where are the best resources?

Note : Do I declare that I have the deepest, most structured and refine knowledge about the topic? Nope. I say this in the begging in order to avoid irrelevant and inconsiderate comments.


Operation could destabilize the runtime + VerificationException comming from Azure Web Role + Intelli Trace + Castle Windsor (or Something Yours)

“Operation could destabilize the runtime”. Have you got this error after publishing your working-and-tested-in-cloud-emulator-web-app to Azure web role? Me too.


Infragistics Ignite UI upload control and MVC – Where is the HttpContext.User and how to get and set it?

To give you the context – we have SPA ERP to build and we have a very good set of jQuery/HTML5 controls for the UI – Infragistics Ignite UI. After installing the IG Ignite UI I started to experiment with the upload control and read its documentation here, here and here (A better organized documentation seated in one place is needed 🙂 ) and experimenting with the examples we got stuck because :