Decaying Code

Where code comes to die

Community Update 2014-03-22 – #WebAPI and #WCF

As with every weekend, things are sparse.



What is New in ASP.Net Web API 2 IHttpActionResult and CORS - Part 2 (

Difference between WCF and ASP.NET Web Service (

Measure twice, cut once – or profile before optimizing your code

Too often we see smart code. I’m not talking about a trademarked product or something science fiction here. I’m talking about code that was written with the goal of making it faster or asynchronous. By smarter I mean, too smart for its own needs. The code should be as simple as it is required to maintain it efficiently and so that other developer can maintain it.

But as the application is being developed, at some point, we realize that it’s slow. So we run the debugger a few times, identify the module from which it’s coming from, assume it’s a certain piece of code and… we optimize.

What did we just optimize? Was it the real problem? Of course since it’s gone now! But right now, the code is unreadable. You’ve added caching, async loading, static dictionary and what not. It’s 20 times faster than it was before! Of course it’s better!

What we don’t realize however is that, we patched the problem. We put a Band-Aid on an open profusely bleeding wound. It will work for now but then you’ll have other problems related to the way you resolved your problem. Caching? Your cache doesn’t invalidate properly… Async? Partial data or 100% CPU every time the task is executed… Dictionary? Thread locking and exception for already existing keys… etc.. etc.. All those problems will gnaw at your time and for what? For some performance issue that you patched by dropping quick hacks on them.

What should we do?


Your application was slow. You saw it in your browser. It took forever to load. Each page load were slow as hell. Is it coming from your application startup code? From which layer?

Most of the developer I’ve worked with will normally comment out code and try to reproduce the speed issue. Did it work? No? Comment out some more. Rinse and repeat until the performance issue is resolved. Once they found the source of the problem, they “optimize” or fix this block of code.  Most of the time, it might be a “WHERE” on a SQL query that is missing. Sometimes however, I see train wrecks.

The best way to know if your code is slow and what part of your code is slow is to use a profiler. There’s many kind of profiler but I’m going to talk about 2 kinds. Performance profiler and Database profiler.

Measuring performance

Here are some tools that most .NET Developers use: dotTrace ($), ANTS Performance Profiler ($), slimtune (open source)

Those tools will measure the time spent on each methods in your code. They will allow you to home in on code that is invoked too often or few times but that takes an eternity to answer (we’re talking seconds here). This will allow you to find the hotspots in your code. It will tell you where your time should be spent rather than modifying your code to find problems. Maybe your loading huge amount of items in memory and it’s slowing down your app. Maybe an external resource is slow…. whatever it is… those tools will find it.

But what if your code is working fast but its your ORM that is slow?

Measuring database

Here are some tools that most .NET Developers use: Hibernating Rhinos profilers for Entity Framework, NHibernate and more ($), MiniProfiler (open source)

When you realise that your problem is part of your database requests, it’s where you start using database profilers to find your problems. Maybe a badly configured ORM sends SELECT * requests to a table with millions of row while you only need one of them? What is the scenario… knowing what is slow when accessing the database could increase the performance of your application exponentially.


Once you are at that step, you know exactly what is slow and what to do to fix it. This is actually the easiest step since you already spent a lot of time understanding the problem. Okay, maybe I’m exaggerating a little but we get the point. Once you know what is the problem, it becomes a lot easier to fix it.


Measure first. Optimize. Measure again. If what you did didn’t improve the running time of your application, you only peddled code around. If you gained 2% gain in speed while making the code unreadable to anyone but yourself, you’ve only muddled the water for little to no gain.

Measuring is pretty much the main recommendation of this article. You don’t measure before optimizing, somewhere in the world a kitten dies.

Stop killing kittens.

Related articles

Community Update 2014-03-21–Follow up on Greg Young series on #Sublime, #webdev, #aspnet, #fsharp, #resharper release and more

So last post before the slow weekend. I hope that you enjoy yours as I will spend mine coding. As always.

Don’t miss out on the follow-up on Sublime by Greg young, Identity 2.0 released to RTM, ReSharper 8.2 releases and more.


Follow-up on the Sublime series by Greg Young

Sublime is Sublime 5 | Greg Young's Blog on (

Sublime is Sublime 6 | Greg Young's Blog on (

Sublime is Sublime 7 | Greg Young's Blog on (

Web development (HTML5, JavaScript, etc.)

Important Developer Resources for a JavaScript Newbie - Evangelism - Blog (


Announcing RTM of ASP.NET Identity 2.0.0 (

Social Login in ASP.NET MVC (

C# Fundamentals for Absolute Beginners: (01) Series Introduction (

Genetic Algorithms with F# - my tech blog (

Visual Studio

Open Source and Microsoft Developer Tools (

ReSharper 8.2 is Released Along with dotTrace, dotCover Updates | JetBrains .NET Tools Blog (

Methodology / Agility

The Corruption of Agile | Dr Dobb's (

Architecture / CQRS

EventStore - from streams to read models (

Windows Azure

Rockin’ Windows Azure with Visual Studio (


Elasticsearch: When giving it more memory causes more OutOfMemory errrors — Makina Corpus (

New article: Elasticsearch as a NoSQL Database (beta version) | Hadoop Magazine (

Community Update 2014-03-20 – #sublime series by Greg Young, #tdd in #javascript, #donet, #aspnet and #WindowsAzure

Guy Barrette is looking for people who want to submit video content for a website focusing on Azure. You can check it out here: Azure Rocks

Hello everyone!

So Greg Young was on fire last night/this morning. He wrote 4 blog posts on Sublime Text. A must read! I have a few links in web development, including OAuth, but most importantly, TDD in Javascript.

So with the usual .NET, ASP.NET,etc. I wish you all an happy reading.

Also, if you are not aware yet, the MVP Program is changing its guideline for admission. You can view here on YouTube. So if you are part of an Open Source project involving .NET, you might be eligible for becoming an MVP on that alone.


Sublime Series by Greg Young

Sublime is Sublime Part 1 | Greg Young's Blog on (

Sublime is Sublime 2 | Greg Young's Blog on (

Sublime is Sublime 3 | Greg Young's Blog on (

Sublime is Sublime 4 | Greg Young's Blog on (

Web development (HTML5, JavaScript, etc.)

Test-driven development in Javascript | dotnet thoughts (

webdesignrepo - a compact list of helpful webdesign links (

10 Things You Should Know about Tokens ( – We’re talking OAuth over there.


Using AutoMapper to Map Abstract Classes | Patrick Desjardins' Blog (

Successful IoC container usage | Jimmy Bogard's Blog (

C# performance tips & tricks | Raygun Blog (


Kris' blog - Designing Evolvable Web APIs with ASP.NET now as a free ebook (

LIDNUG — Katana Authentication Middleware | brockallen on (

Stopping concurrent logins | (

CORS support in WebAPI, MVC and IIS with Thinktecture.IdentityModel | brockallen on (

DarksideCookie | What is OWIN, and what is it doing in my new ASP.NET MVC project? (

ASP.NET Web API exception logging with - StrathWeb (

More HTTP Flushing in ASP.NET MVC | nik codes on (

Storage (NoSQL, SQL, or Event Stores)

Event Store 3.0.0 Release Candidate available – Event Store (

Windows Azure

Windows Azure = Security + Privacy + Compliance (

Azure Rocks! (

Search Engines (ElasticSearch, Solr, etc…)

Legume for Logstash ( Logstash 1.4.0 GA Has Been Unleashed | Blog | Elasticsearch ( Elasticsearch - The Definitive Guide | Blog | Elasticsearch (

Community Update 2014-03-19 – #webdev, #dotnet, #aspnet, #cqrs and some more #elasticsearch

First of all, I would like to mention that there is less than 19 days left until Windows XP support goes out. It’s been a nice 12 years and a half going. That means that if your child was born on the day of the release, he would now be in 7th grade. It’s been a nice and long run but it’s time to pull the plug. If your enterprise is still running Windows XP (other than in a VM to show rookies what it looked like back in the days), then it’s time to change.

That being said, here are today’s link!


Web Development

JavaScript Promises: There and back again - HTML5 Rocks ( ( – NodeJS tutorial videos

A DOM Manipulation Class in 100 Lines of JavaScript | Flippin' Awesome (

jsDelivr – The advanced open source public CDN ✩ Mozilla Hacks – the Web developer blog (

JavaScript MVC Style Guide (

.NET / ASP.NET / Web API Web Api 101 | codeCloudy on (

Being Cellfish: Tail Recursion and C# (

ASP.NET MVC – URL routing (

Obtaining Twitter Access Tokens with ASP.NET Identity Geeks With Blogs (

Using the ASP.NET Bundling Pipeline with OWIN - Michael Sarchet (

Jeff Byboth: Machine Key when load balancing web applications (

How to automatically notify the user that it's time to upgrade a Windows App - Scott Hanselman (

NuGet packages

NuGet Gallery | AspNet.Identity.RavenDB 2.0.0-beta1-01 (

Architecture and CQRS

Busting some CQRS myths | Jimmy Bogard's Blog (

Open Source

Showcasing interesting projects in Explore · GitHub (


Elasticsearch Image Demo (

Deploying Elasticsearch with OpsWorks - Application Management Blog (

Indexing Project Gutenberg with MongoDB and Elasticsearch » anystacker (

Getting Started with elasticsearch and AngularJS: Part1 - Searching (

Getting Started with elasticsearch and AngularJS: Part2 - Faceting ( This Week In Elasticsearch | Blog | Elasticsearch (

Community Update 2014-03-18 – #webdevelopment, #javascript, #dotnet, #aspnet, #testing and #opensource

Here’s a lot of new content about Javascript, CSS, .NET and ASP.NET.

I’ve included some nice article about ElasticSearch as always. Since I’m not in a chatty mood, I’ll leave you, dear reader, the time to read.


Web Development

Reassign JavaScript Function Parameters In Reverse Order, Or Lose Your Params | :derick_bailey (

(cs)spinner | pure CSS loading animations with minimal effort. (

Welcome - Polymer (

gremlins.js/ at master · marmelab/gremlins.js · GitHub ( – Simulate huge amount of click everywhere on your screen.

jQuery Mambo Plugin (


How to create a FileStreamResult from a string | andrewlocatelliwoodcock on (

EF6.1.0 RTM Available (

ASP.NET WEB API Validation (A One More Better Approach) | TypeCasted on (

Compiling your MVC views without IIS errors | Codes from the field on (

Important: Setting the Client Principal in ASP.NET Web API | on (

Using jQuery-UI Tabs With ASP.NET WebForm Validators (

WebAPI: Getting Headers, QueryString and Cookie Values - Rick Strahl's Web Log (


8 Tips For Writing a Good Bug Report (

Open Source

OSS Perks (

Up For Grabs (

Search Engines

Ecrypting Logs on Their Way to Elasticsearch | Sematext Blog on ( Kibana 3.0.0 GA Is Now Available! | Blog | Elasticsearch (

Community Update 2014-03-17 – #ioc in #webdev, #dotnet, #aspnet including #fsharp and some #windowsazure and #onenote API

As with every Monday, here’s what’s to read in the community today!


Web development

Untangle HTML and Javascript using Dependency Injection | Clark/Nikdel/Powell (


The Dangers of Implementing Recurring Background Tasks In ASP.NET - You've Been Haacked (

Enabling Cross-Origin Requests : The Official Microsoft ASP.NET Site (

Brad Wilson: Getting Started with ElasticLINQ (

How to create a pure F# ASP.NET Web API project (

Identity in Your Own Apps with Windows Azure Active Directory - Part 4 (

How Nancy made .NET Web development fun! | In Absentia (


OneNote and Microsoft's quiet API revolution - Scott Hanselman (

Windows Azure

Windows Azure AD on Azure Fridays! (II) | CloudIdentity ( – Videos!


Choosing A Backend For A Graph Store - Lithium Community (


Global Windows Azure Bootcamp | Locations ( – Available in most countries


CQRS and Event Sourcing | CQRS on (

Event Sourcing Basics · EventStore/EventStore Wiki · GitHub (


Office Lens Is a Snap - Microsoft Research (

Community Update 2014-03-16 – Upgrading an #aspnet #webforms app to #MVC

So here’s what a Sunday look like in a .NET/software developer world. One link.

The winner? Dave Paquette. He’s a fellow ASP.NET/IIS MVP and as such, he gives a very interesting read.



Dave Paquette | So you inherited an ASP.NET Web Forms application (

Community Update 2014-03-15 – #webdev with #nodejs, #aspnet, #wcf, #unittest, #jsonld and more

As it’s the weekend, I’ll keep this short. Please enjoy this small list for those who just can’t stop.

Enjoy the reading!

Web Development

JSON-LD - JSON for Linking Data (

Taking Advantage of Multi-Processor Environments in Node.js | The Carbon Emitter (

Guy Barrette | Moment.js: a great JavaScript date library (

Five Reasons ASP.NET Developers Should Care About Node.js | Wintellect (


How to Implement a Service Architecture on Windows Azure using WCF, WPF, and Unit Testing (

c# - Creating a correct absolute URL when running ASP.NET MVC application under Visual Studio Windows Azure Emulator - Stack Overflow (

Debugging .NET Backend in Visual Studio (

Immerse Yourself in Angular, MEAN, ASP.NET, and Gulp | John Papa (

How is Response.Redirect() Impacting My Site? (

Architecture and Testing

Video: Unit Testing and TDD – Why You Should Care and How to Make It Happen - Videos - Osherove (

Microservices ( – I guess the article is still under development.


Exploring FAKE, an F# Build System for all of .NET - Scott Hanselman (


How to start your first podcast - equipment, editing, publishing and more - Scott Hanselman (

Community Update for 2014-03-14 – #webdevelopment, #tdd, #rest, #dotnet, #aspnet, and much more

So last community update before the weekend! How was your week?

So this time around, yet another batch of awesome links for you! Before I let you enjoy your weekend, I want to mention the following:

Pranav Rastogi is looking for people who want to help out with the development and/or suggest things for the new Identity framework for ASP.NET. Go on Github to see what it’s all about.

Enjoy your weekend!

Web Development

Responsive & Accessible Data Table - CodePen (

Responsive Web Design Patterns | This Is Responsive (

Preserving Important Comments in Bundling and Minification (

Don't Be a Jerk. Optimize Your Site. | Alan Crissey (

TechEmpower Framework Benchmarks ( – This is the performance of webstacks on all OS/frameworks over delivering plaintext to your browser. ASP.NET still has a long way to go but we’re getting there.

ColorPicker - Packages - Package Control (

Architecture and Testing

What TDD Is and Is Not | DaedTech (

Microservices ( – Yep! Some more Microservices content!

REST is OVER! - Literate Programming (


Back to Basics: Assert your assumptions and diff your source code - Scott Hanselman (

Easy Background Tasks in ASP.NET « Blog – Stack Exchange (

Delegate-based strongly-typed URL generation in ASP.NET MVC (

Information about ASP.NET Identity & Security (

Where's the ESB? (

Azure Identity 103 - Vittorio creates an application that will authenticate against Active Directory (

Migrate away from MSBuild-based NuGet package restore - (

Visual Studio

8 Visual Studio debugging tips – debug like a boss » DamienG (

Windows Azure

Troy Hunt: The World’s Greatest Azure Demo (

Search Engines (Solr, ElasticSearch, etc.)

Dev Time: Building a Navigation from a Search Index ( 1.0.1 | Elasticsearch (

Nuget Packages

Release 1.1.0 · stefanprodan/WebApiThrottle · GitHub ( – Tools that allow you to throttle your WebAPI