Tue, Feb 5, 2013

Evaluating KnockoutJS and AngularJS – Part 2

In Part 1, I described how I was using the demo tutorial from SammyJS to get a better understanding of AngularJS and KnockoutJS.

In this blog post I will focus on what I found when using KnockoutJS.

Again if you just want to get to the code then feel free to take a look here for Angular and here for Knockout.

Knockout

Firstly Knockout should be commended on their documentation and online tutorials. Their website tutorials follows a step by step approach and once you have completed each step you can click through to the next section. You can also leave the tutorial and come back to it and it will remember where you left. There is great support in the KnockoutJS room in Jabbr and I’d like to thank David Spörri for answering my newbie JS and Knockout questions.

Thu, Jan 24, 2013

Using AngularJS/BackboneJS in Windows 8 JavaScript app

To help me expand my JavaScript knowledge as I said I would in my previous post I thought I’d write a Windows 8 application using JavaScript.

After following a few “Hello World” tutorials from Microsoft I thought I’d take a look at the ToDo list demos shown at TodoMVC.com.

This website/Github repository takes the ToDo demo and implements it in all the various JS frameworks and libraries out there. As I said previously its a minefield.

Anyhow, I thought I’d start with Backbone, copy the files, add the references to WinJS and hit F5 and bingo. However, I got the below error:

Unhandled Exception

Wed, Jan 9, 2013

JavaScript is the future…maybe!

I’m not one for New Years resolutions but I thought it was time I looked at JavaScript more in depth.

I looked at Node.js a while back and found it very interesting and I probably need to go back to it. Over the last month or so there has been a large discussion about async in .Net frameworks and there appears to be a lot of misunderstanding about it (and lets leave it at that, I don’t want to start another flame war) but the thing we can definitely say with Node.js, well JavaScript to be fair is that it is perfectly asynchronous and non-blocking.

As a web developer I have used JavaScript from the early days of Response.Write moving onto frameworks such as script.aculo.us and MooTools and finally ending up with jQuery which has come pretty much a standard these days so my JavaScript skills are not completely new.

However, there has been a large push to use JS more and more for rich user friendly applications with things like KnockoutJS, AngularJS and BackboneJS on the client and Node.js on the server. Microsoft has even taken a prominent role in helping bring Node.js to a Windows environment as it started out on *nix based platforms. They have also started contributing to and including scripts in their Visual Studio project templates for jQuery.

Wed, Dec 19, 2012

Why use NancyFX?

When a new project comes along why should you automatically choose ASP.NET MVC? Yes, its Microsoft based so you may have more of your peers fluent already in that architecture but is there an alternative, a better alternative?

I believe so and its called NancyFX. Your first reaction, what is so special about Nancy? I also believe you’ll ask what is wrong with ASP.NET MVC but maybe you should look at it differently and ask what is right with Nancy?

What is Nancy?

Nancy is a lightweight framework for building websites / services without getting in your way. It’s heavily inspired by a Ruby project called Sinatra, which happens to identify itself as not being a framework, since it doesn’t include all the plumbing of things such as an ORM, lots of configuration, etc.

Does it implement MVC?

Nancy does not force you to adhere to the model-view-controller pattern, or any other pattern. It’s nothing more than a service endpoint responding to HTTP verbs. Making it ideal for building Websites, Web Services and APIs.

Fri, Dec 7, 2012

Easily publish a NuGet package

I recently published WebAPI.Testing on Nuget but found it a bit tricky to build a package ready for NuGet.

There is documentation about how to do it but I found it hard to follow so I thought I’d document how I finally got my package ready.

The easiest way I thought was to have something built into Visual Studio. I spoke to David Fowler and he told me you can edit your *.csproj file and add <BuildPackage>true</BuildPackage> to it.

When you build your project a *.nupkg is created ready for publishing with NuGet.

Thu, Nov 29, 2012

ASP.NET Web API Testing

As the need arose to implement some kind of Web Service/HTTP API I thought I would evaluate NancyFX, ASP.NET Web API and ServiceStack.

Suffice to say all performed as expected and I was actually surprised to find that implementing ASP.NET Web API was easier than ServiceStack (I know that might be a bit of a statement to make to the ServiceStack followers, sorry). I found Nancy easiest to implement. The very simple API demos can be found on my Github page.

When it came to testing ASP.NET Web API I found it to be wanting slightly in comparison to Nancy. With WebAPI I could make direct calls to the controller methods to make sure data was returned correctly and I could mock a repository and test that the methods in the repository were being called but there was nothing I could see to test the HTTP response I would get.

Fri, Nov 23, 2012

The For Loop is the devil in disguise

I recently spoke to someone about the ‘for’ loop who opened my eyes to how unstructured the ‘for’ loop is.

I have only ever used it in the traditional sense of:

for(int i = 0; i < 10; i++)
{

}

I looked into some more and thought I’d show anybody else who may not have known about this innocent little thing in the C# language. It may exist in other languages but I am explicitly talking about C#.

for (; ; )
{
  Console.WriteLine("Hi");
}

For some reason this compiles and executes! Who knew? Smarter people than me obviously. What do you expect it to output?

The answer is it outputs “Hi” forever as there is nothing to determine when the loop should end however there is nothing to determine when it should start either.

Menu