Hot Towel SPA Is a Great Starter

A few months ago, John Papa released a Visual Studio template called Hot Towel SPA, which Scott Hanselman kindly pointed out to me. SPA, as all the hip kids will tell you, stands for Single Page Application. That is, the kind of application that you start by visiting a web page, and you stay on that same page for as long as you use the application. As opposed to most web applications, where you skip from page to page as you interact with the site.

People have been doing this for a long time, of course,  but the Hot Towel SPA starter really is a nice introduction to the style. In a SPA, you really  need to think of the browser as “the client,” a standalone entity that communicates with your server via (web) API calls. Once you get used to it, it’s really rather refreshing, and it allows you to take advantage of all the computing power on the client machine in a way that can be quite liberating.

Hot Towel uses a JavaScript application framework called Durandal to structure the client side code. It divides the world up into services (JavaScript modules, basically), views, and view models. All of this is just for the JavaScript side of things, remember – you may also have views and view models and so on on the server side, but that’s a different thing – you’ll interact with those via AJAX calls, usually using JSON to encode the data.

Hot Towel uses HTML for the views and lets Knockout do the view composition and data binding, which makes it a good source of examples for learning Knockout as well.

The JavaScript code is nicely modular, in the style of require.js. If you’ve not seen this style, it’s worth checking out. Basically, you declare all your dependencies for your JavaScript module, and the framework asynchronously loads them as necessary, as passes them to your module. It’s great documentation, great for structuring the code so you don’t get circular dependencies, and makes for easier unit testing too, since can easily supply alternative (mock) implementations of your module’s dependencies.

On the server, the MVC code is well organized as well, and it’s straightforward to plug in your new Web API controllers and start coding.

I’ve been playing with this starter for a while, working on a proof of concept for a new series of articles on my blog. I found Hot Towel to be a great starting point, and it opened my eyes to some interesting new techniques on the client side. Give Hot Towel a try for your next project, it’ll be fun.

Building an Azure Web Site Application, Part 2: Diagnostics and Logging

In the previous article, we created a very simple starter web application and published it to Windows Azure. In this post, we’ll look at how to diagnose problems with that application. Since we’re deploying our application to Azure , we don’t have access to the Windows event log, or to log files that we might 

Building an Azure Web Site Application, Part I

In this series, I’ll be discussing the process of building a simple, but complete, .Net 4.5 web application, and how to host and manage it in Windows Azure. We won’t be skipping anything in this series – this will be a real application that will be live on the web, so it will have to

Transactional Objects

Every now and then, developers run into a situation where they need an in-memory object to participate in a transaction, and do all the things that transactional things do. One example of a situation that calls for transactional objects is caching. Suppose you’re in a transaction, inserting, updating, deleting things in a database. After making

My F# Wish List

F# is a lovely language. I’m really glad it exists, and I love working with it. However, there is some room for improvement! I’ve gathered a list of all the things that I think are “missing” from F# today. A few of these I’ve found on UserVoice since I started compiling this list, and I’ll

Snap on Azure

Yesterday I started experimenting with Haskell on Azure by putting up a Snap server. It doesn’t do much, it’s just the default starter application you get when you do “snap init,” but it’s up and running on Azure. Here’s how it works. Start with the latest Haskell Platform. Then install the Snap packages with cabal.

Snap on Windows

Snap is a web framework for Haskell. Here are some notes on what I had to do in order to make it work on Windows. Caveat emptor, your mileage may vary. Hopefully this is of use to someone. 1. Install the Haskell Platform. You want version 2012.2.0.0 or later. 2. Install Git. You’ll need this

When Type Constraints Meet Reflection In F#

When you use a “type constraint” in F#, the kind of constraint that specifies that the type has to extend from some other type, it’s possible to confuse the compiler (or more accurately: confuse yourself) into allowing some code that is guaranteed to fail at runtime. Here’s how it can happen. If you have a

Outnumbered by Robots

I heard a piece on the radio the other day about robots. One reporter told the story of how he’d driven across the United States almost without speaking to another human being the whole time. Food via self-checkout at the grocery store, hotels via robots check-in systems, etc. This was all very amusing at first.

powershell: Upgrade All Your .Net Projects

Here’s a quick PowerShell script you can use to update all your projects to a new version of .Net. Lots faster than opening the properties window for each project in Visual Studio and then reloading.   function set-frameworkversion($version) { #scan current directory and below for project files #Add project types as desired $projects = dir