• My must have (short) list programs/extensions etc posted on 24 Mar 2012

    We have all seen these lists before, but I've decided I'll make a list of all the software I use or think are a must have, blog it, then this time next year I can do the list again and see how much it's changed.

    Visual Studio 2010

    What can I say, I'm a .NET Developer :)

    ReSharper

    http://www.jetbrains.com/resharper/

    This should just ship with Visual Studio, without ReSharper I feel so unproductive in VS.

    MindScape Web Workbench

    http://www.mindscapehq.com/products/web-workbench

    This VS extension just gets better and better, I primarily got it to write LESS and CoffeeScript, but recently they added support for minifying and combining JavaScript and CSS files. Really cool stuff and I highly recommend it.

    BugAid

    http://www.bugaidsoftware.com/

    Read more...

  • OrmLite Blobbing done with NHibernate and Serialized JSON... posted on 19 Mar 2012

    There seems to be a growing trend now with these Micro ORM's, at least that is what I see with ServiceStack.OrmLite, which is the ability to persist properties of an object as a JSON, rather than in separate tables.

    Usually with a Relational approach you would create a Customer table, Address table, and most likely shove the Phone Numbers under separate columns of the customer for HomePhone and Mobile.

    This means we are limited to two types of phone numbers, and require joining or querying for the addresses.

    Do we really need separate columns for phone numbers? Do we really need to persist the addresses in another table?

    One problem I see with putting addresses into it's own table, is the temptation to relate them to an Order (assuming this is some sort of eCommerce system) when really there is no relationship between a customer's address, and the address on an order.

    Really, the order should have it's own address, otherwise you can never delete or update an address on a customer, and you can't delete the customer. However I digress and this is a topic for another day.

    Read more...

  • Service Stack Exceptions and Errors posted on 09 Mar 2012

    Note: This post on ServiceStack is to do with the C# Client. JavaScript posts will be coming in the future.

    One of the most painful experiences with WCF is exceptions, if using WCF makes you want to slit your wrists, exceptions in WCF will make you want douse yourself in petrol and light yourself on fire.

    Before you even get to your code exceptions, you have to wade yourself through piles of retarded errors to do with Contract Mismatching, Forcefully Disconnected, Binding Issues, Random Faults... The list goes on.

    Then, it all works in development, and you put it in production, and it doesn't work, and to debug it you got to modify the config file, setup the diagnostics logging, then view it and trawl through piles of crap.

    (image taken from: http://weblogs.asp.net/nmarun/archive/2011/06/10/wcf-service-trace-viewer-part-1.aspx)

    And in the end, it was probably a PEBKAC issue where you forgot to put a stupid attribute on a property...

    Read more...

  • RavenDB - Flattening Object Graphs and Projections posted on 04 Mar 2012

    One of the guys in JabbR RavenDB chat room had a pretty interesting problem that took a while to solve. The problem was that he wasn't trying to return anything to do with the original document, but get a flattened view of some information inside the document.

    The scenario was a Game Server which a collection of Connected Users.

    public class GameServer
    {
        public string Id { get; set; }
        public string ServerName { get; set; }
        public IEnumerable<User> ConnectedUser { get; set; }
        public class User
        {
            public string UserId { get; set; }
            public string Name { get; set; }
            public DateTimeOffset DateConnected { get; set; }
        }
    }
    

    Given say 3 servers with a bunch of users on each server, and searching for a user who's name begins with 'b' the expected result was along the lines of:

    Read more...

  • Service Stack... I heart you. My conversion from WCF to SS posted on 21 Feb 2012

    I've just spent the weekend ripping out that dreaded WCF abomination and replacing it with Service Stack.

    http://servicestack.net/

    A modern fresh alternative to WCF. Code-first, convention-based, codegen-free. Encourages best-practices high-performance, scalable REST & RPC web services.

    Over the past couple of months I've been fighting with WCF to the point I wanted to slit my wrists.

    So I asked JabbR and Twitter if I should use Web API. Well -no- one recommended Web API and everyone recommended Service Stack.

    It's a different way of thinking

    The first noticeable difference between WCF and SS (Service Stack) is that I'm no longer writing a single service class with a butt load of methods. Which is most likely a good thing because after a while they just become hard to manage.

    So instead of a Contract, Service, Response DTO, and Request DTO, with 9234823 methods defined in the Contract/Service. It's now 1 Request DTO per Service.

    What does that mean?

    Read more...

  • MVC 4 Project Templates are stupid posted on 19 Feb 2012

    begin rant

    Thought I would jump on the MVC 4 Beta bandwagon today, installed, create new project... And this is what I'm greeted with:

    <?xml version="1.0" encoding="utf-8"?>
    <packages>
      <package id="AspNetMvc" version="4.0.20126.16343" />
      <package id="AspNetRazor.Core" version="2.0.20126.16343" />
      <package id="AspNetWebApi" version="4.0.20126.16343" />
      <package id="AspNetWebApi.Core" version="4.0.20126.16343" />
      <package id="AspNetWebPages.Core" version="2.0.20126.16343" />
      <package id="EntityFramework" version="4.1.10331.0" />
      <package id="jQuery" version="1.6.2" />
      <package id="jQuery.Ajax.Unobtrusive" version="2.0.20126.16343" />
      <package id="jQuery.UI.Combined" version="1.8.11" />
      <package id="jQuery.Validation" version="1.8.1" />
      <package id="jQuery.Validation.Unobtrusive" version="2.0.20126.16343" />
      <package id="knockoutjs" version="2.0.0.0" />
      <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
      <package id="Microsoft.Web.Optimization" version="1.0.0-beta" />
      <package id="Modernizr" version="2.0.6" />
      <package id="System.Json" version="4.0.20126.16343" />
      <package id="System.Net.Http" version="2.0.20126.16343" />
      <package id="System.Net.Http.Formatting" version="4.0.20126.16343" />
      <package id="System.Web.Http.Common" version="4.0.20126.16343" />
      <package id="System.Web.Providers" version="1.1" />
      <package id="System.Web.Providers.Core" version="1.0" />
    </packages>
    

    This is absolutely stupid...

    I select EMPTY project template.

    EMPTY

    Read more...

  • RavenDB - Searching across multiple properties posted on 18 Jan 2012

    Ayende recently posted about Orders Search in RavenDB which got me a little bit excited, since I was pondering how I would do searching in RavenDB without having Full Text Searching from SQL Server.

    So digging into it I wanted to try it out for myself how to use it. Given the model:

    public class Post
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public IEnumerable<string> Tags { get; set; }
        public DateTime DatePosted { get; set; }
    }
    

    I've setup 10 posts (click here for the insert pastie) just with some really basic data.

    So I'm going to detail here all the data that I've setup.

    Read more...

  • RavenDB - Map Reduce posted on 22 Dec 2011

    So, learning Map Reduce in RavenDB I decided that to take what I learnt from the index created in my previous post. I think I picked something rather difficult to begin with, but I've succeeded

    Given a document Article which has a collection of Tags.

    I want to get a Count of each Tag across all Articles.

    public class Content
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public IEnumerable<Tag> Tags { get; set; }
    }
    
    public class Tag
    {
        public string Name { get; set; }
    }
    

    Note: Tag is it's own class because I added additional properties to it.

    Read more...

  • RavenDB Inheritance-Revisited posted on 14 Dec 2011

    So after my initial post on RavenDB Inheritance, and the issue I had with polymorphic queries, and seeking help from the guys in JabbR and the (RavenDB Google Group)[http://groups.google.com/group/ravendb/browse_thread/thread/c71df8f1cd92e04c], Ayende ended up doing a screen cast with me where he solved all my problems.

    One of the things he asked me was what I was trying to achieve by having a polymorphic query, which was a very good question, something I hadn't really thought about.

    The problem I was trying to solve was actually displaying search results.

    The Problem

    So I'm working on a personal project, and I need to display a few things which are similar, but different. There's 3 different types but I'll use two to keep it simple. I've also cut out most of the properties.

    So I have an abstract class Content, with two derived classes, Article and Video.

    public abstract class Content
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public DateTime DatePublished { get; set; }
    }
    
    public class Article : Content
    {
        public string HtmlContent { get; set; }
    }
    
    public class Video : Content
    {
        public string Description { get; set; }
        public string VideoUrl { get; set; }
    }
    

    Read more...

  • RavenDB Inheritance posted on 10 Dec 2011

    Note: Updated solution: http://www.philliphaydon.com/2011/12/ravendb-inheritance-revisited/

    Continuing my learning of RavenDB, I wanted to see how it handled Inheritance.

    I found: http://ravendb.net/faq/polymorphic-indexes

    Which showed what to do allow you to select over all types of Animal for the example shown. So I wanted to see what happens before and after using this method.

    So like the example shown I've created an Animal, with a Dog and Cat.

    public abstract class Animal
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
    
    public class Dog : Animal { }
    
    public class Cat : Animal { }
    

    Now if I insert a Dog and Cat:

    using (var session = documentStore.OpenSession())
    {
        session.Store(new Dog() { Name = "Test Dog" });
        session.Store(new Cat() { Name = "Test Cat" });
        session.SaveChanges();
    }
    

    Read more...