Skip to main content

Posts

Showing posts from March, 2012

faking data in WP7 and other .Net platforms

I needed to fake some data for a WP7 app yesterday and I was about to write a couple of classes when I thought why not check out what's available out there already... There were already a couple of NuGet packages out there but I wanted to try out my forking skills on GitHub :) I had a quick conversation with Ben Smith about faker-cs   and producing a NuGet package.  Introducing Faker.Net on NuGet, with support for .Net 3.5 SP1, .Net 4.0, Silverlight & WP7. Faker.Net support loads of different ways to fake data - addresses, names, phones numbers and more: It's very simple to use, shown below is the code for the following WP7 apps: It could be used anywhere you need fake data - proof of concept, testing, demo apps...

Coupling and cohesion

I was reading ploeh's blog  this morning and it made me think about coupling and cohesion in general. These are import concepts in software development, Wikipedia has great definitions for both here & here . These are often contrasted together but they are different concepts and just because you have low coupling doesn't mean you'll have high cohesion. Using a car analogy the headlight unit for my Audi has tight (high) coupling because it's designed only to be fitted to a particular version. You could say it has high cohesion because it is part of a greater system to show light when a button is turned\clicked.... Taking another part of the car the tyre, the actual type of tyre will have low coupling to my Audi because it would suitable for several different models and makes, it would also have low coupling to the wheel, it has to fit a particular size but it could fit many wheels of this size. The tyre would still have high coh...

Integrating jasmine into Visual Studio 2010/2011 beta

Following on from my previous post about testing javascript with jasmine. I was interested to explore integration into visual studio 2010 so I could run them along side test written in another language like C#. I found the VS 2010 extension Chutpah (pronounced  'hutz-pah'). This got me up and running with the ability to run test manually and to my surprised it worked by only have the SpecRunner.html file open. I didn't a csproj or sln file containing the javascript, it's clever enough to resolve all dependencies: Test results are render in the output window of VS 2010: This is good and I appreciate the work someone has done to get this far but I want more... I want integration into Resharper... A quick squizz on the inter'webs and I end posting a request on jetBrains forum , it looks like support is coming in R# 7. Then I thought lets check out the current beta and see, so off I go and boot Win8 and install R#7 beta and see if it's there yet... ...

Playing around with jasmine

I believe like a lot of devs that javascript is going to become more prevalent in a lot if not all areas of application development, whether that be with a server side framework like  node.js or client side with frameworks like backbone.js & knockout.js . I've built a couple of sites with backbone and I'm very interested in what Derik Bailey is doing with marionette , but with all my investigations into backbone I haven't as yet put any of the javascript I've written under as serious testing strategy. A quick search for a BDD style testing framework lead me to jasmine , I've heard good things and I thought I'd give it ago. What to put under test with jasmine? Previously I implemented a simple undo-redo framework for .Net called  undoable.net , this was pushed out to GitHub and I thought I'd port this to javascript. The important issue here is not the ported-code but how easy I found it to get jasmine up and running. First off downloaded...

Building a multilingual MVVM app

Last week I built a sample multilingual app in WPF using MVVM for a proof of concept. This was the first time I've built a desktop app which supported different languages at runtime. Previously I've worked on multilingual websites and desktop apps but not ones that support changing the language of the UI dynamically via a UI control like a menu item. The app was pretty simple, a single input field representing a number where the value has to be within a fixed range (-100 to 100). If the input failed the validation an error message would be displayed. What I came up with is shown below, it supports three cultures - English, French & German. The culture (language) is selected by either the menu or the F1 - F3 keys. How I achieved this is what follows. What I wanted to achieve was the model & view model being agnostic to any concern about the currently selected culture (language). The view model used for the English version should be the same for the Fre...

Getting NLog working with Azure is as easy as 1, 2, 3...

After getting past my confusion with how to set-up diagnostics for a web sited deployed in Azure, it was actually very easy to get NLog to route all messages to the Azure diagnostics table - WADLogsTable. Firstly you need to configure the Azure role for diagnostics, there seems to be 2 ways to do this either in-code via the OnStart() method or using a config file. Obviously the use of a config file is the preferred way when dealing with large scale deployments (by a separate IT department). Code: Configuration (diagnostics.wadcfg): Secondly, you need to configure NLog, all this involves is including the trace target and defining the rule to write to the trace target: And finally browse the contents of the WADLogsTable once you've deployed to the cloud and waited the required time for the logs to be shipped. I'm using the Windows Azure Platform Management Tool (MMC) available here : I still stand by my assertion that getting diagnostics w...

Showing a message box from a ViewModel in MVVM

I was doing a code review with a client last week for a WPF app using MVVM and they asked ' How can I show a message from the ViewModel? '. What follows is how I would (and have) solved the problem in the past. When I hear the words ' show a message... ' I instantly think you mean show a transient modal message box that requires the user input before continuing ' with something else ' - once the user has interacted with the message box it will disappear. The following solution only applies to this scenario. The first solution is the easiest but is very wrong from a separation perspective. It violates the ideas behind the Model-View-Controller pattern because it places View concerns inside the ViewModel - the ViewModel now knows about the type of the View and specifically it knows how to show a message box window: The second approach addresses this concern by introducing the idea of messaging\events between the ViewModel and the View. In the example ...