Category Archives: Code Samples

Strong Typing to Reduce Defect Count

A long time ago, I was having a discussion with the Director of Development in my office. He was teaching me how we can prevent errors, before they even get to QA, through better coding practices. For example, imagine that you have an integer which represents a high score. Further, imagine that you have an integer that represents loyalty points. Unfortunately, it would be too easy to goof up and pass the high score into a function that was expecting loyalty points. That would compile, and the only way to find the bug would be through Unit Tests, or a QA tester. One easy way to prevent that kind of error is to wrap the high score in a HighScore class, and the loyalty points into a LoyaltyPoints class.

Continue reading Strong Typing to Reduce Defect Count

SQL Server Database Snapshots

A snapshot is an instant read-only copy of a database that can be queried or used as a restore point. You might take a snapshot before running any modification queries in production, or to give yourself a restore point when performing a deployment. Even in a sophisticated team, I’m certain that snapshots can solve an existing problem for every developer.
Continue reading SQL Server Database Snapshots

Chained Selects in MVC4

Linked select boxes are a common requirement in line-of-business applications. Recently, I implemented the Chained Selects plugin for JQuery in an MVC4 LOB application, while utilizing two new MVC4 Helpers — HtmlHelper.IdFor and HtmlHelper.NameFor. The author of Chained Selects, Mika Tuupola, also wrote the Lazy Load plugin that I recently wrote about.
Continue reading Chained Selects in MVC4

Lazy Load in MVC4

Infinite Scrolling is a UX design pattern that can be used as an alternative to paging results. I used Mika Tuupola’a Lazy Load plugin for JQuery to implement this pattern in a photo database written using MVC4. This plugin allows efficient browsing of BLOBs being streamed from the database, without wasting server resources. In the article, I also point out the importance of using AnonymousObjectToHtmlAttributes to preserve HTML5 data-dash attributes.
Continue reading Lazy Load in MVC4

GeoServices API Implementation

The agency I work for has not deployed ArcServer. But, our biologists really need to see their dots on a map, and they need to create dots on a map, to say nothing of some of the more complicated tasks like editing geometries and linear referencing. Installing ArcServer is outside of my control. So, to provide our biologists with the geospatial tools they required, I decided to build a spatial server into my application myself.
Continue reading GeoServices API Implementation