Decaying Code

Where code comes to die

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

As with every weekend, things are sparse.

Enjoy!

ASP.NET

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

Difference between WCF and ASP.NET Web Service (www.dotnet-tricks.com)

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?

Measure.

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.

Optimizing

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.

Conclusion

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

http://alexandrebrisebois.wordpress.com/2013/08/29/friends-dont-let-friends-use-lazy-loading-on-windows-azure/

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.

Enjoy!

Follow-up on the Sublime series by Greg Young

Sublime is Sublime 5 | Greg Young's Blog on WordPress.com (goodenoughsoftware.net)

Sublime is Sublime 6 | Greg Young's Blog on WordPress.com (goodenoughsoftware.net)

Sublime is Sublime 7 | Greg Young's Blog on WordPress.com (goodenoughsoftware.net)

Web development (HTML5, JavaScript, etc.)

Important Developer Resources for a JavaScript Newbie - Evangelism - Infragistics.com Blog (www.infragistics.com)

.NET/ASP.NET

Announcing RTM of ASP.NET Identity 2.0.0 (blogs.msdn.com)

Social Login in ASP.NET MVC (www.simple-talk.com)

C# Fundamentals for Absolute Beginners: (01) Series Introduction (channel9.msdn.com)

Genetic Algorithms with F# - my tech blog (stefanalfbo.github.io)

Visual Studio

Open Source and Microsoft Developer Tools (blogs.msdn.com)

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

Methodology / Agility

The Corruption of Agile | Dr Dobb's (www.drdobbs.com)

Architecture / CQRS

EventStore - from streams to read models (mirkobonadei.com)

Windows Azure

Rockin’ Windows Azure with Visual Studio (blogs.msdn.com)

ElasticSearch

Elasticsearch: When giving it more memory causes more OutOfMemory errrors — Makina Corpus (makina-corpus.com)

New article: Elasticsearch as a NoSQL Database (beta version) | Hadoop Magazine (blog.hadoopmag.com)

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.

Enjoy!

Sublime Series by Greg Young

Sublime is Sublime Part 1 | Greg Young's Blog on WordPress.com (goodenoughsoftware.net)

Sublime is Sublime 2 | Greg Young's Blog on WordPress.com (goodenoughsoftware.net)

Sublime is Sublime 3 | Greg Young's Blog on WordPress.com (goodenoughsoftware.net)

Sublime is Sublime 4 | Greg Young's Blog on WordPress.com (goodenoughsoftware.net)

Web development (HTML5, JavaScript, etc.)

Test-driven development in Javascript | dotnet thoughts (www.dotnetthoughts.net)

webdesignrepo - a compact list of helpful webdesign links (www.webdesignrepo.com)

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

.NET

Using AutoMapper to Map Abstract Classes | Patrick Desjardins' Blog (patrickdesjardins.com)

Successful IoC container usage | Jimmy Bogard's Blog (lostechies.com)

C# performance tips & tricks | Raygun Blog (raygun.io)

ASP.NET / WebAPI

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

LIDNUG — Katana Authentication Middleware | brockallen on WordPress.com (brockallen.com)

Stopping ASP.net concurrent logins | teknohippy.net (teknohippy.net)

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

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

ASP.NET Web API exception logging with Raygun.io - StrathWeb (www.strathweb.com)

More HTTP Flushing in ASP.NET MVC | nik codes on WordPress.com (nikcodes.com)

Storage (NoSQL, SQL, or Event Stores)

Event Store 3.0.0 Release Candidate available – Event Store (geteventstore.com)

Windows Azure

Windows Azure = Security + Privacy + Compliance (blogs.msdn.com)

Azure Rocks! (azurerocks.com)

Search Engines (ElasticSearch, Solr, etc…)

Legume for Logstash (www.legume.md)

Elasticsearch.org Logstash 1.4.0 GA Has Been Unleashed | Blog | Elasticsearch (www.elasticsearch.org)

Elasticsearch.org Elasticsearch - The Definitive Guide | Blog | Elasticsearch (www.elasticsearch.org)

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!

Enjoy!

Web Development

JavaScript Promises: There and back again - HTML5 Rocks (www.html5rocks.com)

nodeschool.io (nodeschool.io) – NodeJS tutorial videos

A DOM Manipulation Class in 100 Lines of JavaScript | Flippin' Awesome (flippinawesome.org)

jsDelivr – The advanced open source public CDN ✩ Mozilla Hacks – the Web developer blog (hacks.mozilla.org)

JavaScript MVC Style Guide (blog.sourcing.io)

.NET / ASP.NET / Web API

Asp.net Web Api 101 | codeCloudy on WordPress.com (codecloudy.wordpress.com)

Being Cellfish: Tail Recursion and C# (blog.cellfish.se)

ASP.NET MVC – URL routing (blogs.msdn.com)

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

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

Jeff Byboth: Machine Key when load balancing asp.net web applications (www.byboth.org)

How to automatically notify the user that it's time to upgrade a Windows App - Scott Hanselman (www.hanselman.com)

NuGet packages

NuGet Gallery | AspNet.Identity.RavenDB 2.0.0-beta1-01 (www.nuget.org)

Architecture and CQRS

Busting some CQRS myths | Jimmy Bogard's Blog (lostechies.com)

Open Source

Showcasing interesting projects in Explore · GitHub (github.com)

ElasticSearch

Elasticsearch Image Demo (demo.elasticsearch-image.com)

Deploying Elasticsearch with OpsWorks - Application Management Blog (blogs.aws.amazon.com)

Indexing Project Gutenberg with MongoDB and Elasticsearch » anystacker (anystacker.com)

Getting Started with elasticsearch and AngularJS: Part1 - Searching (www.fullscale.co)

Getting Started with elasticsearch and AngularJS: Part2 - Faceting (www.fullscale.co)

Elasticsearch.org This Week In Elasticsearch | Blog | Elasticsearch (www.elasticsearch.org)

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.

Enjoy!

Web Development

Reassign JavaScript Function Parameters In Reverse Order, Or Lose Your Params | ThoughtStream.new :derick_bailey (lostechies.com)

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

Welcome - Polymer (www.polymer-project.org)

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

jQuery Mambo Plugin (www.valeriobarrila.com)

.NET / ASP.NET

How to create a FileStreamResult from a string | andrewlocatelliwoodcock on WordPress.com (andrewlocatelliwoodcock.com)

EF6.1.0 RTM Available (blogs.msdn.com)

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

Compiling your MVC views without IIS errors | Codes from the field on WordPress.com (gyorgybalassy.wordpress.com)

Important: Setting the Client Principal in ASP.NET Web API | leastprivilege.com on WordPress.com (leastprivilege.com)

Using jQuery-UI Tabs With ASP.NET WebForm Validators (blog.codesigned.com)

WebAPI: Getting Headers, QueryString and Cookie Values - Rick Strahl's Web Log (weblog.west-wind.com)

Testing

8 Tips For Writing a Good Bug Report (blog.bughuntress.com)

Open Source

OSS Perks (ossperks.com)

Up For Grabs (up-for-grabs.net)

Search Engines

Ecrypting Logs on Their Way to Elasticsearch | Sematext Blog on WordPress.com (blog.sematext.com)

Elasticsearch.org Kibana 3.0.0 GA Is Now Available! | Blog | Elasticsearch (www.elasticsearch.org)

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!

Enjoy

Web development

Untangle HTML and Javascript using Dependency Injection | Clark/Nikdel/Powell (clarknikdelpowell.com)

.NET / ASP.NET

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

Enabling Cross-Origin Requests : The Official Microsoft ASP.NET Site (www.asp.net)

Brad Wilson: Getting Started with ElasticLINQ (bradwilson.typepad.com)

How to create a pure F# ASP.NET Web API project (blog.ploeh.dk)

Identity in Your Own Apps with Windows Azure Active Directory - Part 4 (blogs.msdn.com)

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

Office

OneNote and Microsoft's quiet API revolution - Scott Hanselman (www.hanselman.com)

Windows Azure

Windows Azure AD on Azure Fridays! (II) | CloudIdentity (www.cloudidentity.com) – Videos!

Storage

Choosing A Backend For A Graph Store - Lithium Community (community.lithium.com)

Event

Global Windows Azure Bootcamp | Locations (global.windowsazurebootcamp.com) – Available in most countries

CQRS

CQRS and Event Sourcing | CQRS on WordPress.com (cqrs.wordpress.com)

Event Sourcing Basics · EventStore/EventStore Wiki · GitHub (github.com)

Research

Office Lens Is a Snap - Microsoft Research (research.microsoft.com)

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.

Enjoy!

.NET/ASP.NET

Dave Paquette | So you inherited an ASP.NET Web Forms application (www.davepaquette.com)

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 (json-ld.org)

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

Guy Barrette | Moment.js: a great JavaScript date library (blog.guybarrette.com)

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

.NET

How to Implement a Service Architecture on Windows Azure using WCF, WPF, and Unit Testing (blogs.msdn.com)

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

Debugging .NET Backend in Visual Studio (blogs.msdn.com)

Immerse Yourself in Angular, MEAN, ASP.NET, and Gulp | John Papa (www.johnpapa.net)

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

Architecture and Testing

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

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

F#

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

Podcasts

How to start your first podcast - equipment, editing, publishing and more - Scott Hanselman (www.hanselman.com)

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 (codepen.io)

Responsive Web Design Patterns | This Is Responsive (bradfrost.github.io)

Preserving Important Comments in Bundling and Minification (mikesmithdev.com)

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

TechEmpower Framework Benchmarks (www.techempower.com) – 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 (sublime.wbond.net)

Architecture and Testing

What TDD Is and Is Not | DaedTech (www.daedtech.com)

Microservices (martinfowler.com) – Yep! Some more Microservices content!

REST is OVER! - Literate Programming (blog.steveklabnik.com)

.NET & ASP.NET

Back to Basics: Assert your assumptions and diff your source code - Scott Hanselman (www.hanselman.com)

Easy Background Tasks in ASP.NET « Blog – Stack Exchange (blog.stackoverflow.com)

Delegate-based strongly-typed URL generation in ASP.NET MVC (maxtoroq.blogspot.ae)

Information about ASP.NET Identity & Security (gist.github.com)

Where's the ESB? (channel9.msdn.com)

Azure Identity 103 - Vittorio creates an application that will authenticate against Active Directory (channel9.msdn.com)

Migrate away from MSBuild-based NuGet package restore - xavierdecoster.com (xavierdecoster.com)

Visual Studio

8 Visual Studio debugging tips – debug like a boss » DamienG (damieng.com)

Windows Azure

Troy Hunt: The World’s Greatest Azure Demo (www.troyhunt.com)

Search Engines (Solr, ElasticSearch, etc.)

Dev Time: Building a Navigation from a Search Index (blog.florian-hopf.de)

Elasticsearch.org 1.0.1 | Elasticsearch (www.elasticsearch.org)

Nuget Packages

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