• Blog
  • Archive
  • About
  • Contact
Sign in

Welcome to rickardnilsson.net

rickardnilsson.net is a weblog and the online home of web developer and father of three, Rickard Nilsson... More

Rickard blogs about creating software solutions using ASP.NET and agile practices.

Sites I've visited recently

  • Twitter
  • Facebook
  • Philip Wildenstam
  • Ninetech - Affärsnytta med IT
  • JetBrains ReSharper
  • Vimeo
  • dnrTV!
  • YUI Theater
  • BlogEngine.Net

Categories

  • .NET
  • Agile
  • ASP.NET 2.0
  • ASP.NET 3.5
  • ASP.NET MVC
  • BlogEngine.NET
  • C# 2.0
  • C# 3.0
  • CSS
  • Design by Contract
  • Design Patterns
  • JavaScript
  • TDD
  • Unit testing
  • User tip

Five most recent posts

  • Dependency injection in ASP.NET MVC with Unity IoC Container
  • ReSharper templates from the Code Kata Cast
  • How to unit test code which depends on HttpContext.Current.Server
  • Code Kata Cast
  • TDD Masterclass in the UK with Roy Osherove

Tag cloud

  • agile
  • ajax
  • asp.net 3.5
  • blog
  • blogengine.net
  • c#
  • code kata
  • css
  • dbc
  • dependency injection
  • design by contract
  • dom
  • douglas crockford
  • fakes
  • foto
  • getweekofyear
  • gregoriancalendar
  • highlight
  • html
  • httpcontext
  • humble dialog box
  • inversion of control
  • ioc container
  • iso 8601
  • javascript
  • jquery
  • jscript
  • julian bucknall
  • live template
  • metaweblog api
  • model-view-presenter
  • mvp
  • patterns & practices
  • photo album
  • picasa
  • recent posts
  • refactor
  • refactoring
  • release
  • resharper
  • rhino mocks
  • roy osherove
  • syntax
  • syntax highlighter
  • tdd
  • tdd masterclass
  • test coverage
  • testing
  • types
  • unit test
  • unity
  • web service
  • week
  • widget
  • word 2007
  • yahoo
  • yui

Recent comments

  • Code Kata Cast (8)
    Rickard wrote: @Marcus Eklund Classical music is royalty free sin… [More]
  • Code Kata Cast (8)
    Marcus Eklund wrote: http://creativecommons.org/ is a good place. Cl… [More]
  • Code Kata Cast (8)
    Rickard wrote: @Johan Lindfors Thanks! @Andrea I use TestDrive… [More]
  • Code Kata Cast (8)
    Marcus Eklund wrote: Nice one Rickard, A bit quiet though :P Used to t… [More]
  • Code Kata Cast (8)
    Andrea wrote: Nice one You can use the R# test runner and assig… [More]

Code Kata Cast

Tuesday, 27 October 2009 21:28 by Rickard

Have you ever come across the concept of a Code Kata?

For me it really took off after reading blog posts (1, 2, 3) by Unce Bob Martin and Pragmatic Programmer Dave Thomas. The concept is really simple: how can we, as programmers, better our selves and improve our techniques and proficiency in using the tools and processes in our every day work?

The suggested solution is inspired by the martial arts kata. You learn how to implement a solution to a specific problem and you practice all the moves in the exact same order over and over again. The point is that you should know the moves so well that you forget about them and focus on improving your key strokes and the use of your tool set. The never ending goal is to perform the kata with the least amount of key strokes.

The promice is that practicing these kata's often and regularly makes you a better and more productive programmer in that you are trained to act instinctively in certain reoccurring situations.

Calculator kata cast

Anyway, I've been practicing a kata based on a problem initiated by Roy Osherove and I decied to record it to get some feedback and maybe spread some knowledge on how I practice Test-driven development using ReSharper.

 

Calculator Code Kata Cast 1 from Rickard Nilsson on Vimeo.

Tags:   unit test, refactoring, tdd, code kata, resharper
Categories:   C# 3.0 | TDD | User tip
Actions:  
Share | Comments (8) | |

ReSharper User tip #2: Refactor rename namespace

Tuesday, 26 August 2008 09:30 by Rickard

Have you ever wanted to rename a namespace but you have too many classes in the namespace that it would be an infeasible hassle changing all of them individually. Even using a tool like ReSharper to refactor the namespaces class by class is a hassle. I'm gonna show how to rename a namespace for all of its classes in a couple of key strokes using ReSharper.

Example

Mechanics

  1. Open Class View (Ctrl + Shift + C)
  2. Choose the namespace you want to rename
  3. Press Ctrl + R, R*
  4. Pick another name
  5. Hit Next

and you're done!

Please leave a comment if you found this useful.

* Visual Studio scheme

Tags:   resharper, refactoring
Categories:   .NET | User tip
Actions:  
Share | |

ReSharper User tip: Refactor magical strings to variable

Thursday, 31 July 2008 00:28 by Rickard

I've been using Jetbrains ReSharper a while now and I love it. I can't even imagine going back to plain Visual Studio anymore because there are so many things in my daily work that involves ReSharper, even simple tasks like editing source code and navigating through code and source files, let alone creating files and running unit tests.

Now I want to share a user tip I found that isn't obvious to find nor part of any context menu. It's actually a refactoring and I call it Magical strings to variable. You can use it when you end up with multiple equal string literals in a piece of code. You would probably want to gather all of the string literals in a variable and reuse it through out the code. You can use ReSharper to do it for you in a couple of key strokes.

Example

[Test]
public void ParentPresenter_Update_should_update_view() {
    var model = new User {
                        Name = "foo"
                    };

    using (mockery.Record()) {
        Expect.Call(parentView.Username = "foo");
    }

    using (mockery.Playback()) {
        IParentPresenter presenter = new ParentPresenter(parentView) {
                                Model = model
                            };
        presenter.Update();
        Assert.That(presenter.Model.Name, Is.EqualTo("foo"));
    }
}

[Test]
public void ParentPresenter_Update_should_update_view() {
    var name = "foo";
    var model = new User {
                        Name = name
                    };

    using (mockery.Record()) {
        Expect.Call(parentView.Username = name);
    }

    using (mockery.Playback()) {
        IParentPresenter presenter =
            new ParentPresenter(parentView) {Model = model};
        presenter.Update();
        Assert.That(presenter.Model.Name, Is.EqualTo(name));
    }
}

Mechanics

1. Highlight one of the string literals

2. Press Ctrl+R, V (Ctrl+Alt+V)* to introduce a variable

3. Select to replace all occurrences (default option)

4. Pick a name for the variable

..and you're done! Please leave a comment if you find this usefull.

* Visual Studio scheme (ReSharper 2.x / IDEA scheme)

Tags:   resharper, refactoring
Categories:   C# 3.0 | User tip
Actions:  
Share | |
 
Copyright © 2008-2009 rickardnilsson.net