Insights and outlooks on software development


ASP.NET MVC framework

Monday, October 15, 2007 by Thomas L

Scottgu is writing about a MVC framework for ASP.NET that they are working on right now. This may well be one of the best things that his team is doing right now; nothing is better than facilitating testability and maintainability among the users of ASP.NET.

I've noticed that the focus previously from Scott and his guys over there in Seattle has been more of easily demoed drag-drop RAD functionality than maintainability, and this change in focus may well be followed with other good decisions.

Some of the tools-y things I'd love to have are

  • Implementing extensible/replaceable mocking support into Visual Studio/TFS
  • A good unit test implementation
  • That the above MVC framework can use Winforms/WPF as view (i.e. please don't put it in the System.Web namespace as you did with the ASP.NET 2.0 caching)

I hope some of my wishes will come through.

Filed under having 0 kommentarer  

Having problems debugging in silverlight?

Wednesday, October 10, 2007 by Thomas L

Right now I'm playing around a bit with Silverlight, and I had some problems with debugging. More specifically, whenever I started a debugging session, Visual Studio would stop debugging and run as if I hadn't started to debug (e.g. using Ctrl-F5). After a bit of digging around I found the following link:

The answer is, quite simply, that VS needs to start the firefox.exe process to be able to tell which PID the process has, which it needs for debugging. So no more casual surfing while coding, please!

Technorati-taggar: , ,

Filed under having 0 kommentarer  

On using BDD methodologies in xUnit

Tuesday, October 2, 2007 by Thomas L

Say you're a developer in a shop not accepting that the co-workers install whichever tools they wish. Also say that you have eaten the BDD pill. How do you go about to make sure you are writing the best NUnit tests there is?

Well, one thing to notice is that the BDD toolset maps well to the existing xNUnit toolset. Where you have contexts in a BDD toolset it's possible to have test fixtures with setup methods making contexts in NUnit. Where you have a Test in xUnit, you have behaviours in BDD tools. This makes it possible to apply patterns for xUnit tests which somewhat satisfies the patterns in behaviour driven development. Let me show with an example.

Suppose we are writing a guestbook type of application, in a DDD fashion with the model object of Message, which is stored in the MessageRepository. We want to make sure that when the repository has messages, it's possible to find this message by its ID, but supplying an ID not in the repository should return null.

In NBehave, the BDD implementation should be somewhat like this

[TestFixture] public class BDD_FindMessageBehaviours { [Test] public void Searching_in_message_repository() { MessageRepository repository = null; Message message = null; Story searchingStory = new Story( "Searching in message repository" ); searchingStory .AsA( "Message poster" ) .IWant( "to add messages to the repository" ) .SoThat( "I later can retrieve them" ); searchingStory .WithScenario( "Having the message in the message repository" ) .Given( "an empty MessageRepository", delegate() { repository = new MessageRepository(); } ) .When( "I add message with Id", 1, delegate( int id ) { repository.Add( message = new Message( id ) ); } ) .Then( "The message should be in teh repository", 1, delegate( int id ) { Assert.AreSame( message, repository.FindById( id ) ); } ); searchingStory .WithScenario( "Not having the message in the message repository" ) .Given( "an empty MessageRepository", delegate() { repository = new MessageRepository(); } ) .When( "I add message with Id", 1, delegate( int id ) { repository.Add( message = new Message( id ) ); } ) .Then( "Searching for another message id should be impossible", -100, delegate(int id) { Assert.IsNull( repository.FindById( -100 ) ); } ); } }

In a xUnit implementation, I propose the following code

namespace OnUsingBddInXUnit.Behaviours.MessageRepositoryBehaviour { [TestFixture] public class HavingOneMessageInTheRepository { private MessageRepository _messageRepository; private Message _message; [SetUp] public void SetUp() { _messageRepository = new MessageRepository(); _message = new Message(); _message.Id = 1; //add other properties _messageRepository.Add( _message ); } [Test] public void SearchingForCorrectIdShouldReturnCorrectMessage() { Message foundMessage = _messageRepository.FindById( _message.Id ); Assert.AreSame( _message, foundMessage ); } [Test] public void SearchingForIncorrectIdShouldntReturnAnything() { Message shouldBeNull = _messageRepository.FindById( -100 ); Assert.IsNull( shouldBeNull ); } } }

In this short example I showed how it's possible to implement good NUnit-only code in a BDD-ish fashion. I hope some of you got new ideas on how to write those tests, which of course aren't tests, but specifications on behaviours.

Technorati-taggar: , ,

Filed under having 0 kommentarer  

Hello world

Monday, October 1, 2007 by Thomas L

All right, now (at last) I've started to blog. I'll use this blog for publishing thoughts and comments on technical things I read around the web.

A bit about me; I'm a software developer living in Malmö, Sweden, employed by the consulting firm Qbranch. (Although I'm employed by Qbranch, the posts on this blog are 100% my own.) I primarily focus on Microsoft technologies, and mainly .NET. I've been doing stuff around .NET Compact Framework and ASP.NET, but I've been creating winforms apps for about a year or so now. I like agile development/DDD/TDD like, well, everyone right now.

The driving thought behind my starting a blog is this post by Joel Spolsky and the idea that commenting on blogs are bad (which I fully agree with), so I decided to start commenting by posting my thoughts on my own blog. If it will turn out good, we'll just see about that, won't we?

As you may have noticed by now I write in English, although my native tongue is Swedish. I hope I can make myself clear using English, and I hope you please can disregard my language errors.

Filed under having 0 kommentarer