Skip to main content

Posts

Showing posts from February, 2014

Technology Radar

As an application architect and technical lead, I not only have to keep up with current technologies but also have an eye on future and upcoming technologies and trends. One of these places I look at is the ThoughtWorks Technology Radar . A must follow for every (aspiring) architect…

Knockout: Multiple viewmodels per page

In a web application we are building we have a dashboard like functionality. To build this in a clean way, we  wanted to create multiple viewmodels in one page. I found the following jsFiddle demonstrating how to get this working using Knockout:

Durandal: jQuery and Knockout integration

Durandal is a really great SPA framework. But we had some trouble first to get it up and running. The problem was that we forgot 2 very important lines inside our Durandal main.js: It’s important to define both Knockout and jQuery as RequireJs modules. Without that Durandal remained silent…

jQuery or not; that’s the question…

jQuery is a great library, it removed the pain from JavaScript development and renewed my love for building web applications. With the increased power of modern web browsers, you can start to question if you still need jQuery as a dependency. Have a look at http://youmightnotneedjquery.com/ . It shows you a specific jQuery function and it’s equivalent in native JavaScript.

ASP.NET MVC: Injecting dependencies into views

In ASP.NET MVC you can even apply dependency injection into views. You can use the IoC framework of your choice and injecting Dependencies into your views will just work. Most of the time I create a base class to inject some common dependencies: To use this page instead of the default ViewPage, you have to register this class inside the web.config in the Views folder: Then you can just start using these dependencies inside your Razor views: Remark: The only thing you need to be aware of is that the Dependency injection does not work inside your layout view.

Task Parallel Library: Start may not be called on a promise-style task

A colleague was implementing some async stuff when he was confronted with the following error message: Start may not be called on a promise-style task Let’s have a look at his code and then explain where this error comes from: Tne problem is caused by the fact that the underlying task is already started when you call Task.Delay. So calling Start(again) on the Task will throw the error mentioned above. You can wait for the Task results using the await keyword or use the continuation style by using ContinueWith() .

Debug like a pro

As a developer there is no way around it, sooner or later you arrive in debugging land. Debugging can be time consuming so every tool and tip that can help you optimize the debugging experience is welcome. Damien Guard did a great post with some debugging tips and also have a look at Michael Parsin tips to avoid debugging when possible.

Task Parallel Library: WaitAll vs WhenAll

While implementing some async voodoo I noticed that there were 2 very similar methods on the Task class: WaitAll and WhenAll . So what’s the difference between the 2? Task.WhenAll creates a task that will complete when all of the supplied tasks have completed. It will not block the current execution but allows you to await the tasks for completion. Task.WaitAll will wait for all of the provided Task objects to complete execution.This will block the current execution until all tasks are done. So if you are inside an async method, you probably want to use Task.WhenAll and use await to get the results.

TypeScript: window.onerror

As JavaScript applications grow larger and larger, error handling becomes more important. One of the places where you can add error handling is by subscribing to the window.onerror event handler. According to the documentation, the following parameters are expected: Error message (string) Url where error was raised (string) Line number where error was raised (number) When I tried to implement this inside TypeScript, I got into trouble: TypeScript gave me the following error message: Cannot convert ‘’'(message: string) => void’ to ‘ErrorEventHandler’: Call signatures of types ‘(message: string) => void’ and ‘ErrorEventHandler’ are incompatible: Type ‘String’ is missing property ‘timeStamp’ from type ‘Event’ No clue what this message is telling me . In the end I got it working by using the following signature:

ASP.NET Session State Providers

On my current project, I’m building an (ASP.NET MVC) web application. The plan is to deploy it to a web farm, so we had to replace the default in memory session state provider with a persistent one. We did our own performance tests comparing multiple possible solutions(SQL Session State, Redis, AppFabric Caching, …). The clear winner for us was  Redis . On SlideShare I found the following presentation confirming our own conclusions: Best performing asp.net session state providers from James Smith

Visual Studio 2013 CodeLens performance issues

One of the great new features in Visual Studio 2013 is the CodeLens functionality , it brings a lot of information about your code into the Visual Studio Code Editor. However on larger projects I started to notice that my laptop slowed down a lot. When looking at the Task Manager I noticed that there were multiple Microsoft.Alm.Shared.Remoting.RemoteContainer  processes eating up almost all my resources. On Microsoft Connect I noticed that there is already a bug logged mentioning that this problem is related to CodeLens. The only solution I could find was disabling Code Lens : Go to Tools –> Options -> Text Editor ->All Languages -> Code Lens Disable  Code Lens

Web API 2.1 Global Exception Handling is missing IoC integration

Web API 2.1 brings a lot of great new features to the table. One of them is global error handling, allowing you to log all unhandled exceptions through one central mechanism This is a sample from the Web Api documentation: The annoying thing I noticed is that the IExceptionLogger interface is not resolved through the dependency injection integration mechanism that Web API offers out-of-the-box. So you explicitly have to register your implementation through the Services property on the HttpConfiguration object. Hopefully the Web API team will change this in the future...

NHibernate ConfORM: Generate the XML mapping

Since a few years, NHibernate offers a code based mapping model. So you no longer need to create and maintain long and cumbersome XML files but instead you can create your mappings from code (and even apply some conventions if you want). As I’m kind of used to the XML mapping, I find it useful to have a look at the XML for debugging purposes. Here is the required code to generate the XML mappings from the ConfORM code:

Bye Bye Package Restore(the old way)

In a more recent NuGet version, the traditional Package Restore workflow has been replaced by an alternative(better?) way of working. In the old way, you right clicked on your solution in VS and choose Enable package restore . This caused VS to modify your csproj files, and create .nuget folder containing nuget.exe and some other files. The new way is a lot cleaner and simpler. NuGet will now always restores packages before building in VS. So you no longer need any changes to your csproj files. If you want to enable this for your existing projects, have a look at the following document from the NuGet team. More information can be found in this blog post by David Ebbo .

Visual Studio Online: Remove weekends from the burndown charts

One thing that annoyed me for a long time using the Team Foundation Server burndown charts, is that the weekends were not excluded. This made the burndown charts less useful as it gave an incorrect indication of the sprint’s progress. In the latest Visual Studio Online release, you can now configure your working week to exclude weekends, or define which days you do you want to be included in the burndown: To configure this, execute the following steps: Open the project you want to configure in Visual Studio Online Go to the Administration site On the overview tab, select the Team you want to configure. On the Team Overview page, go to the Team settings and select the days you want to include in the burndown chart: Let’s hope they add this feature to Team Foundation Server soon!

Testing your website

Every web developer knows that despite web “standards” no 2 browsers behave the same. So when you create a new web application, you’ll have no choice but test it on a wide range of operating systems and browsers. For a long time we had some old desktop systems available for testing, but thanks to Microsoft this is no longer necessary. On modern.ie you can download a virtual machine for Mac, Linux or windows to test any version of Internet Explorer starting from IE6.

Nice software development quote

“Rather than construction, software is more like gardening – it is more organic than concrete.” The Pragmatic Programmers Don’t forget to read this article that further elaborates on this quote…

Windows Azure e-book: Building Real-World Cloud Apps with Windows Azure

Microsoft published an online and downloadable e-book versions of Scott Guthrie’s presentation titled Building Real-World Cloud Apps with Windows Azure (original video version is available here: part 1 , part 2 ). Along with the e-book you can find the code for the Fix It application that Scott developed to demonstrate many of the recommended cloud development patterns. If you’re curious about developing for the cloud, considering a move to the cloud, or are new to cloud development, you’ll find in this e-book a concise overview of the most important concepts and practices you need to know. The concepts are illustrated with concrete examples, and each chapter links to other resources for more in-depth information. A must read for every Windows Azure adept…

TypeScript error in Visual Studio 2012: microsoft.typescript.default.props not found

On a recent project, some developers are using Visual Studio 2012 and some are using Visual Studio 2013. We had no problems mixing Visual Studio versions until we started using TypeScript. After adding a TypeScript file in Visual Studio 2013, the project starts throwing errors when we open it in Visual Studio 2012: Microsoft.TypeScript.Default.props not found It seems there are backwards compatibility issues when using a TypeScript project. It adds an import, microsoft.typscript.default.props. which doesn't exist in VS 2012. To fix the problem, unload the project and edit the csproj file. Find the line that imports the Microsoft.TypeScript.Default.props and add an extra condition: <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion