Programming

Signs You Broke the Interface Segregation Principle

Posted on

I have written quite a lot about how to follow SOLID principles, but one thing that can be useful is examples of where a principle is not being followed. What does your code look like when it wants to tell you something? Here are the signs that you broke the Interface Segregation Principle (ISP). Here […]

Programming

ASP.NET MVC Image Squishing with Picz

Posted on

Responsive images have been around for a while and have wide browser support as well as a strong fallback story for older browsers. The one thing holding us back from using them is the manual workflow… Arrive at office Create images at different sizes Upload images Write an HTML tag listing all the image sizes […]

Programming

Find Code Hotspots with ndepend

Posted on

One of the constant battles in software development is predicting where problems are in your code. There are lots of ways to cut up your codebase in order to predict where problems are likely to occur; I have been experimenting with some reports over check-in history in Visual Studio Team Services to find files with […]

Programming

Shorten Your Linq Expressions

Posted on

There is an interesting style of Linq expression that I am seeing a lot in code, including open source projects. It isn’t a big deal, but it damages readability. It looks like this: var result = someEnumerable.Where(e => e.IsCondition).FirstOrDefault(); var result = someEnumerable.Where(e => e.IsCondition).SingleOrDefault(); var result = someEnumerable.Where(e => e.IsCondition).Count(); Can you spot it? […]

Programming

Stale Data in Entity Framework

Posted on

There is a subtle bug that you can encounter when using Entity Framework on a database where updates can happen out of band. For example, the situation I discovered this issue involves a replicated SQL database, with Entity Framework running in “read only” mode against the replication subscriber databases. The data is changed in the […]

Automation

Monitor Replication with DataDog and DogStatsd

Posted on

Although DataDog comes with a healthy selection of integrations, there is always going to be something custom that you want to monitor. This is why DogStatsd has been made available. DogStatsd is a small server that aggregates your custom app metrics. Let’s look at monitoring SQL Server Replication using DogStatsd and C#. DogStatsd runs on […]

Programming

Web Farm Cookie Encryption in ASP.NET

Posted on

If you want to secure a cookie, you need look no further than the System.Web.Security MachineKey class. Using this class, you can protect and unprotect text quite simply. If you are running without load-balancing, you can skip to the wrapper methods at the bottom of the article, which give you methods for protecting and unprotecting […]