Software development

  • Why Static methods are bad for UnitTest?

    The whole idea behind unit testing is to isolate the system under test (SUT) so you can control all the variables and be able to simulate different scenarios to see how your system behaves.  The isolation process usually involves initializing a fake/stub instance and injecting it into the SUT.  However with statics, there is no Continue reading

  • Random C# and CLR thoughts

    – Overflow checking is Off: CLR has different instructions based on whether to perform overflow checking: add, subtract, multiply and its corresponding add.ovf, subtract.ovf and multiply.ovf.  To improve performance it does not check for overflow when performing calculations on primitive types (except System.Decimal, which we will get to later).  So, if you do not want Continue reading

  • WebApi with Ninject

    With WebApi it really sucks that you can’t add its dependencies through IoC like you normally would for any MVC project.  To get it working with WebApi there are two interfaces that you have to implement (IDependencyResolver and IDependencyScope). The IDependencyScope has two methods that you have to implement “GetService” and “GetServices” both expects a Continue reading

  • Entity Framework 5 Code First Development

    I have always been a fan of Code-First development style ever since it came out with entity framework 4.0.  What some people don’t understand is that you don’t necessarily have to start with a bunch of C# classes and then generate the database, but you could use the code-first style using the DbContext class and Continue reading

  • SqlCacheDependency via polling

    Whenever I approach a programming task my model is "first make it work", "then make it work right", "then make it work fast". Now I am not suggesting that during the first and second phase of the process that you completely ignore all performance related issues, such as looping through millions of strings or worse Continue reading

  • MVC Selected Tab

    How do you make the selected tab standout in an ASP.NET Mvc Project?  This is a fairly common task for every sort of web project, we usually do this to help the user keep track of where they are.  But unfortunately this functionality is not built-in and you have to do some manual labor to Continue reading

  • UnitTestable Singletons!

    Singletons are one of the most used (abused) design patterns that people like to use.  There will be only one instance of this class for the entire application, what a performance boost.  However, most of the times you can just use a regular class instead of a Singleton to accomplish the same task.  There are Continue reading

  • Caching with Decorator pattern

    Knowledge of software design patterns is a useful tool to have in your tool belt, and one that will come in handy from time to time.  Today I was thinking of ways of applying caching to existing repositories and the one pattern that stood out was the Decorator pattern.  The concept is fairly simple – Continue reading

  • Implementing CsvResult for ASP.NET MVC

    In MVC anytime you have to allow the user to download something (pdf, csv, excel, etc.,..) from values generated at runtime, I find it much cleaner to create a new Result type of ActionResult.  To say the least it makes the code much more cleaner by abstracting away the logic of actually transforming your data Continue reading

  • SportsStore Knockoutified

    Recently I took couple of weeks off from work because we were having a baby.  So as any good father/developer would do I took that opportunity to do something that I’ve always wanted to do but never really had the time for – learn a new technology, oh and help my wife take care of Continue reading

  • How to spin up more servers when your production servers are pegged

    As a web developer we are usually concerned with code.  We spend all our day figuring out how to solve different programming tasks, but recently I had the opportunity of adding servers to our existing production server farm because they were pegged and couldn’t handle the load.  Luckily everything went smoothly and the steps that Continue reading

  • UpdatePanel and jQuery working together???

    Ok, so you have a requirement where the user wants to auto populate certain fields based on some input they enter in a textbox.  Pop out your jQuery toolbox and get it done in few minutes, however when that textbox is inside of an UpdatePanel of a web forms project this simple task might leave Continue reading

  • Examining state of multiple checkboxes using jQuery…

    When you need to output multiple checkboxes and change certain things based on which ones are checked or unchecked only when the SAVE button is clicked or something then the easiest way to do it is to built Key/Value pairs in jQuery and accessing them in your code as Dictionary values. I have given all Continue reading

  • Ajax enabled drop down list using jQuery…

    So I needed to implement a drop down list in my project and dynamically change the values and the action of this drop down asynchronously.  First I used the code based approach to fill the drop down list with default values/actions and then based on certain selectors on the page changed its values/actions using jQuery. Continue reading

  • Customizing DateTime view templates in MVC3 to display jQuery datepicker utility

    By default MVC generates a textbox for a model property with a datetime value.  But most of the time you would rather have it generate some sort of a datepicker utility instead, here I’ll modify my project to do exactly just that.  So here I have an Address class with two DateTime properties that I Continue reading