DarksideCookie

Come to the dark side...we have cookies!

Introduction to setting up automated unit testing in Silverlight with NUnit

Ok, so MVVM is obviously about Unit testing right? Well, I don’t really agree, but it is definitely a part of why you chose MVVM, even if it is only a small part of the reason for me. I have been using the MVVM pattern for a while now, but I still haven’t started unit testing my code properly. I know I should, but for different reasons I never get around to it. Mostly due to time constraints.

And for all of you that tell me that writing unit tests will not take more time as there will be less bugs to fix, bug off! It does take time. It does include mocking or stubbing services. It does take time to figure out how to write useful tests. And first and foremost, it takes time to get the experience needed to do it fast… So argument ignored!

What I do do though though, is keeping it in my mind when I design my VMs. I always consider whether or no the VM is testable. If it is, then I know that I haven’t introduced any dependencies that I shouldn’t have. And even if it isn’t a fool proof way of limiting dependencies, it does help me…

More...

Posted: Mar 01 2011, 04:53 by ZeroKoll | Comments (2) |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Manage post: :)

Multithreading my way

Ok, so Silverlight is a very cool technology, and Microsoft has done a whole lot of things to make sure that it performs the way it should. They have done things like forcing you to run long running tasks, such as webservice calls, in an asynchronous fashion. But if you start doing long running tasks on your own, you need to make sure to handle the multithreading yourself. Why? Well, if you don’t, you will perform all of that stuff on the UI thread.

And why is performing heavy things on the UI thread a bad thing? Well…it just is!

More...

Posted: Feb 21 2011, 01:05 by ZeroKoll | Comments (4) |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Manage post: :)

Removing Design Time references at compile time

As you might have noticed on my blog, I like working with Silverlight, and I like using the MVVM pattern when I do so. As a part of this, I generally create design time ViewModels to get the best help from the tools (VS and Blend). VMs

The annoying thing about this, is that project containing the design time information need to be referenced by the application for the whole thing to work. But when the app is built and released, I really don’t want the extra ViewModels to be included in the xap file. I guess, in most cases, they are fairly simple and small, making the xap bloat minimal. But it still feels wrong. And it feels even worse when your design time VMs become large due to embedded resources such as images and data…

More...

Posted: Feb 07 2011, 08:44 by ZeroKoll | Comments (0) |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Manage post: :)

Sessions for MIX11

Earlier today I got word that some of my sessions, that I had sent in as a part of the Open Call for MIX11, had gone past the initial round and are on the MIX11 website for voting. And the sessions that get the most votes gets to be presented at MIX11.

So this obviously means that I need a LOT of votes. And that means that I need you to vote on any of my sessions  that you find interesting. Or all of them if you just want to help me to get the possibility to present at MIX11…

The sessions are available here: http://live.visitmix.com/OpenCall/.

And what are my sessions? Well, I am glad you asked. They are…

Silverlight and Windows Azure - Tips from the Trenches
Join Chris Klug as he share his expertise in combining Windows Azure and Silverlight. This session will provide practical insights on using Silverlight with Windows Azure. It will include guidance on using Silverlight applications with Azure Web and Worker roles as well as approaches for using Windows Azure storage directly from your Silverlight app. This session will also cover the use of Windows Azure as a delivery mechanism for Windows Phone 7 push notifications and as a delivery mechanism for streaming media. Vote

From Phone Zero to Phone Hero in 60 minutes
Join Chris Klug & Chris Auld from Intergen as they build a real Windows Phone 7 app from scratch in 60 minutes. This is a hard core, dual data projector, coding marathon. Chris and Chris will build a Windows Phone 7 series application including Windows Azure hosted push notifications, a rich Silverlight UI and partner integration. You'll see how to take an idea from concept to the Windows Phone Marketplace in just an hour. In other words, not your general 'Hello World' application. Vote

MVVM - The Naked Truth
Model-View-ViewModel is the pattern of choice when writing Silverlight, WPF and Windows Phone 7 applications. It offers the developer a structured way to implement UI functionality and logic. It especially well with the mentioned technologies, as it uses built in features to enable a clean separation between form and function. During this session you will join Chris Klug, a Silverlight Solution Specialist from New Zealand, as he tells all about how you get started with MVVM. The goal is to get an understanding of why it is useful and how it can make your life simpler. And it will be presented in a naked form, no frameworks or helpers, enabling you to focus on the basic ins and outs of the pattern. Vote

Building Composite Silverlight Applications
Silverlight is a great platform for rich internet applications, but a lot of developers seem to forget that we can use many of our advanced desktop app approaches too. By adding a plug-in architecture we can make our apps easily extensible for future requirements. This session provides an introduction to plug-in approaches in Silverlight. It explores both PRISM and MEF as tools for implementing this pattern. You'll leave with the practical knowledge you need to add a plugin mechanism to your new and existing applications. Vote

The Phone Zero to Phone Hero will probably not be presented together with Christ Auld though as he probably won’t be able to go to MIX this year. But I will try and find a worthy replacement if that session were to get picked. And I really hope it is, cause it is a very entertaining session that is very far from your normal session. And also because it seems to polarize the crowd a lot. We have got feedback that ranges from more or less “the worst session ever attended” to “the best session ever attended”. Luckily, the good feedback seems to come from people who go to a lot of conferences and have a bit of experience, which is sort of required to grasp the information at the speed that it is presented…

That’s it for now. More coming soon… I hope… I have a little too much to do at the moment…

Posted: Jan 28 2011, 10:37 by ZeroKoll | Comments (0) |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Manage post: :)

MVVM and animation, revisited

A while back, quite a while back to be honest, I wrote a blog post about using animations in the MVVM pattern. And even if the way of doing it mentioned in the post still works, I would not recommend using it.

Adding the animation support in the way that that blog post says, will couple your VM to the StoryboardManager. Not that this really matters, as it will still be quite testable and so on. But it feels wrong…and I don’t like things that feel wrong…

In this post, I aim to cover a couple of ways that we can trigger animations and state changes based on the VM. And yes, these techniques have been hashed and rehashed on several other blogs, and you might already have read about it, but I still have people come to my blog to read the old post. So apparently it is still an issue for some…

More...

Posted: Dec 31 2010, 04:14 by ZeroKoll | Comments (1) |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Manage post: :)

Referencing class library projects with references from Silverlight application projects

One “feature” in VS2010 (and 2008 I assume) that bugs the hell out of me, is the way that referenced assemblies are packaged in Silverlight projects… And please let me know if you know of any fix for this!

Imagine that you have a solution with at least 2 projects. One Silverlight application project, and one class library project. The app project references the class library project as it contains functionality it needs. The class library project in turn references another assembly (or maybe more than one) that is needed for it to be able to run. This (or these) other assemblies are not default Silverlight assemblies, so they will not be on the target machine and needs to be included in the deployment… Unfortunately, this is where VS screws up…

More...

Posted: Dec 27 2010, 01:13 by ZeroKoll | Comments (0) |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Manage post: :)

Using querystring parameters with the WebBrowserTask on WP7

I have just built a Windows Phone 7 app that is hopefully about to pop up on the marketplace within a couple of days. It is a fairly simple app, with very few impressive features. The most complicated part was to get the SQLite db used by the iPhone version of the app, to work on Windows Phone 7. Unfortunately I did not get SQLite to work on WP7. I ended up transferring the data to XML and adding some index tables, also in XML. But that isn’t the topic for this post.

The reason that I am writing this, is that I got stuck on a little thing while doing. Nothing complicated, but worth noting…

More...

Posted: Dec 19 2010, 04:58 by ZeroKoll | Comments (0) |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Manage post: :)

Sharing resources and styles between projects in Silverlight

I have lately been working on a somewhat larger Silverlight application for a client here in New Zealand. The application is being built using PRISM, which means that it is loaded in a composite/ modular way. And with this modular/composite loading, being able to share resources between different modules becomes pretty interesting as it makes it easier to get all modules to share the same look and feel. So this got me to rehash a topic I have already talked about before, merged dictionaries.

This is obviously not a PRISM only thing to do, but it often becomes a little more sought after when the application starts getting spread out over several different projects… Luckily, it is very easy to share resources between projects in Silverlight.

More...

Posted: Dec 04 2010, 03:07 by ZeroKoll | Comments (8) |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Manage post: :)

A Windows Phone 7 ComboBox

I am currently finishing off a tiny little WP7 application for a client here in New Zealand, which as such is not that very impressive. It seems like there is a LOT of apps on the way for the phone. I like it! At least the developers seem to have adopted the phone as their newborn child…or at least as a potential platform for future mobile apps…

But I am not going to be writing about that app. At least not right now. Instead, I wanted to write a little about something that surprised me. I have not been doing too much WP7 development. At least not the kind that includes a load of input controls. So I was kind of stumped when I found out that the phone does not have a ComboBox. Or rather, it does, but it doesn’t have a template suitable for the phone.

I found this to be rather odd, but could on the other hand understand that a ComboBox is probably not a control that is very well suited for a device like the phone. The OS itself seems to be using a list picker thingy instead, but that control seem to have stayed in Microsoft’s own control library and is not available. At least not that I have found.

So I guess the only solution is to do it yourself…at least after you Google it, which was what I did. I did find a couple of interesting ideas on how to style it, but they didn’t seem to follow the Metro style well enough to make me happy. Finally I found http://dotnet.dzone.com/articles/metro-style-combobox-windows, which got to act as the foundation for my control…

More...

Posted: Nov 02 2010, 22:06 by ZeroKoll | Comments (9) |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Manage post: :)

Data binding images with MVVM

The title for this post make it sound like the world’s simplest thing. And to be honest, it sort of is. It is not hard to get images from the ViewModels into the view, but there are several ways of doing it. Each with its own pros and cons.

In my world, my VMs often get urls/uris to images instead of the actual image. The reason for this I guess is sort of the same thing as why you shouldn’t store your images in the database. The models can become huge if they include the images, especially if we add a couple different image sizes and so on. And that is without considering the possibility of us transferring a whole array of these objects across the wire. And in a lot of cases we don’t even show all the images in the UI, so why would we pass the images along if we don’t need them…

More...

Posted: Oct 18 2010, 07:34 by ZeroKoll | Comments (4) |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Manage post: :)